diff --git a/.gitignore b/.gitignore index 56b8976..398a8f4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ __pycache__ *.c # Other generated files -*/version.py */cython_version.py htmlcov .coverage diff --git a/astrowidgets/_astropy_init.py b/astrowidgets/_astropy_init.py index 216d31a..486e940 100644 --- a/astrowidgets/_astropy_init.py +++ b/astrowidgets/_astropy_init.py @@ -1,6 +1,6 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -__all__ = ['__version__', '__githash__'] +__all__ = ['__version__'] # this indicates whether or not we are in the package's setup.py try: @@ -17,11 +17,6 @@ from .version import version as __version__ except ImportError: __version__ = '' -try: - from .version import githash as __githash__ -except ImportError: - __githash__ = '' - if not _ASTROPY_SETUP_: # noqa import os diff --git a/astrowidgets/version.py b/astrowidgets/version.py new file mode 100644 index 0000000..71b9634 --- /dev/null +++ b/astrowidgets/version.py @@ -0,0 +1,12 @@ +version = 'unknown.dev' +try: + from importlib_metadata import version as _version, PackageNotFoundError + version = _version('my-package') +except ImportError: + from pkg_resources import get_distribution, DistributionNotFound + try: + version = get_distribution("my-package").version + except DistributionNotFound: + pass +except PackageNotFoundError: + pass diff --git a/pyproject.toml b/pyproject.toml index 54a891e..0889579 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,5 @@ [build-system] requires = ["setuptools", + "setuptools_scm", "wheel"] build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index bf3a075..b277fae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ github_project = astropy/astrowidgets [options] zip_safe = False packages = find: +setup_requires = setuptools_scm install_requires = astropy ginga