diff --git a/.travis.yml b/.travis.yml index 51de344..2d605a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,8 @@ stages: - lint - test - coverage - - name: test_deploy - if: (NOT type IN (pull_request)) AND (repo = steven-murray/hankel) - name: deploy - if: (NOT type IN (pull_request)) AND (repo = steven-murray/hankel) AND (branch = master) AND (tag IS present) + if: (NOT type IN (pull_request)) AND (repo = steven-murray/hankel) jobs: include: @@ -69,7 +67,7 @@ jobs: name: Coverage on Linux # Test Deploy source distribution - - stage: test_deploy + - stage: deploy python: 3.8 name: Test Deploy install: python -m pip install -U setuptools wheel twine @@ -79,6 +77,7 @@ jobs: # Deploy source distribution - stage: deploy + if: tag IS present python: 3.8 name: Deploy source distribution install: python -m pip install -U setuptools wheel twine diff --git a/hankel/__init__.py b/hankel/__init__.py index 37a2756..1cbca3a 100644 --- a/hankel/__init__.py +++ b/hankel/__init__.py @@ -22,14 +22,12 @@ get_h """ -from pkg_resources import DistributionNotFound, get_distribution - from hankel.hankel import HankelTransform, SymmetricFourierTransform from hankel.tools import get_h try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: # pragma: nocover + from hankel._version import __version__ +except ModuleNotFoundError: # pragma: nocover # package is not installed pass diff --git a/setup.py b/setup.py index 2c80f96..c17df6e 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,11 @@ def read(*names, **kwargs): return fp.read() +def local_scheme(version): + """Truncate the local version (eg. +xyz of 1.0.1.dev1+xyz) for Test PyPI.""" + return "" + + CLASSIFIERS = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -51,7 +56,14 @@ def read(*names, **kwargs): author_email="steven.murray@curtin.edu.au", license="MIT", extras_require={"dev": test_req + doc_req, "tests": test_req, "docs": doc_req}, - use_scm_version=True, + use_scm_version={ + "root": ".", + "relative_to": __file__, + "write_to": "hankel/_version.py", + "write_to_template": "__version__ = '{version}'", + "local_scheme": local_scheme, + "fallback_version": "0.0.0.dev0", + }, setup_requires=["setuptools_scm"], url="https://github.com/steven-murray/hankel", )