-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from fusion-energy/develop
added version to init and setup.cfg metadata
- Loading branch information
Showing
5 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |