Skip to content

Commit

Permalink
Merge pull request #15 from fusion-energy/develop
Browse files Browse the repository at this point in the history
added version to init and setup.cfg metadata
  • Loading branch information
shimwell authored Apr 27, 2022
2 parents 8baf258 + 78a838b commit 7b9ad64
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
6 changes: 5 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions stl_to_h5m/__init__.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit 7b9ad64

Please sign in to comment.