diff --git a/conda/meta.yaml b/conda/meta.yaml index b518240..b53a698 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -11,11 +11,15 @@ source: build: number: 0 script: python setup.py install --single-version-externally-managed --record=record.txt + + # could be changed to use pip install in the future + # script: python -m pip install --no-deps --ignore-installed . requirements: build: - python {{ python }} - - setuptools + - setuptools>=46.4.0 + - setuptools_scm>=6.3.1 run: - python - moab [not win] diff --git a/pyproject.toml b/pyproject.toml index bc3ecea..4121496 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [build-system] requires = [ - "setuptools >= 45", + "setuptools >= 46.4.0", "wheel", - "setuptools_scm[toml] >= 6.2", + "setuptools_scm[toml] >= 6.3.1", ] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index b02e5b4..4b3af10 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [metadata] name = stl_to_h5m +version = attr: stl_to_h5m.__version__ author = The stl_to_h5m Development Team author_email = mail@jshimwell.com description = Converts STL files to a DAGMC h5m file using PyMoab diff --git a/stl_to_h5m/__init__.py b/stl_to_h5m/__init__.py index d32ba26..538e63d 100644 --- a/stl_to_h5m/__init__.py +++ b/stl_to_h5m/__init__.py @@ -1 +1,16 @@ +try: + # this works for python 3.7 and lower + from importlib.metadata import version, PackageNotFoundError +except (ModuleNotFoundError, ImportError): + # this works for python 3.8 and higher + from importlib_metadata import version, PackageNotFoundError +try: + __version__ = version("stl_to_h5m") +except PackageNotFoundError: + from setuptools_scm import get_version + + __version__ = get_version(root="..", relative_to=__file__) + +__all__ = ["__version__"] + from .core import stl_to_h5m diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..7db2b73 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,20 @@ +import stl_to_h5m + + +def test_version(): + """Check that __version__ exists and is correctly formatted""" + version = stl_to_h5m.__version__ + # Ensure it is given as a string + assert isinstance(version, str) + # Ensure is has at least two parts -- major and minor version -- separated by '.' + # Ideally we would aim for major.minor.patch, but this has a tendency to break + # CI tests for unknown reasons. + + # develop is used as the default version name in the dockerfile + if version != "develop": + version_bits = version.split(".") + assert len(version_bits) >= 2, f"Version number is {version}" + # Ensure both of the first two parts is convertable to int + # (The third/fourth part, if it exists, may be a development version) + for bit in version_bits[:2]: + assert bit.isdigit(), f"Version number is {version}"