diff --git a/.gitignore b/.gitignore index 6bf416a..1f199f1 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,6 @@ _skbuild/ # Ignore ctags tags + +# setuptools_scm +_version.py diff --git a/setup.cfg b/setup.cfg index 545eeec..0017ddf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = python-multem -version = 0.3.0 description = A Python wrapper for MULTEM long_description = file: README.md diff --git a/setup.py b/setup.py index 0bc3b39..ad64fed 100644 --- a/setup.py +++ b/setup.py @@ -58,11 +58,12 @@ def main(): package_dir={"": "src"}, packages=find_packages(where="src"), install_requires=["numpy"], - setup_requires=["pytest-runner"], + setup_requires=["setuptools_scm", "pytest-runner"], tests_require=tests_require, test_suite="tests", ext_modules=[Extension("multem_ext", [])], cmdclass={"build_ext": CMakeBuild}, + use_scm_version={"write_to": "src/multem/_version.py"}, extras_require={ "build_sphinx": ["sphinx", "sphinx_rtd_theme"], "test": tests_require, diff --git a/src/multem/__init__.py b/src/multem/__init__.py index eedb347..f9a1e24 100644 --- a/src/multem/__init__.py +++ b/src/multem/__init__.py @@ -8,6 +8,14 @@ # This code is distributed under the GPLv3 license, a copy of # which is included in the root directory of this package. # + + +try: + from multem._version import version as __version__ +except ImportError: + __version__ = "unknown" + + import numpy from multem_ext import * # noqa