diff --git a/astropy/__init__.py b/astropy/__init__.py index c13469d0f88..3f49bec2ecf 100644 --- a/astropy/__init__.py +++ b/astropy/__init__.py @@ -26,6 +26,8 @@ import os from warnings import warn +from .version import version as __version__ + __minimum_python_version__ = '3.6' __minimum_numpy_version__ = '1.16.0' # ASDF is an optional dependency, but this is the minimum version that is @@ -75,18 +77,6 @@ def _is_astropy_setup(): _is_astropy_source(main_mod.__file__)) -try: - from .version import version as __version__ -except ImportError: - # TODO: Issue a warning using the logging framework - __version__ = '' -try: - from .version import githash as __githash__ -except ImportError: - # TODO: Issue a warning using the logging framework - __githash__ = '' - - # The location of the online documentation for astropy # This location will normally point to the current released version of astropy if 'dev' in __version__: diff --git a/docs/conf.py b/docs/conf.py index 0914d286a3f..4fe0dd91f45 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -106,11 +106,7 @@ # |version| and |release|, also used in various other places throughout the # built documents. -# The short X.Y version. -version = astropy.__version__.split('-', 1)[0] -# The full version, including alpha/beta/rc tags. -release = astropy.__version__ - +release = version = astropy.__version__ # -- Options for the module index --------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 289e0707476..ee4030da68b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,6 @@ [build-system] requires = ["setuptools", + "setuptools_scm", "wheel", "cython", "jinja2", diff --git a/setup.cfg b/setup.cfg index 1dc6c1088fb..63199898ad6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = astropy -version = 4.1.dev provides = astropy author = The Astropy Developers author_email = astropy.team@gmail.com @@ -26,6 +25,7 @@ packages = find: requires = numpy zip_safe = False tests_require = pytest-astropy +setup_requires = setuptools_scm install_requires = numpy>=1.16 python_requires = >=3.6 diff --git a/setup.py b/setup.py index f4a672b6f08..05edfd0879d 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst +import os import builtins from setuptools import setup @@ -15,4 +16,4 @@ # programmatically. from extension_helpers import get_extensions -setup(ext_modules=get_extensions()) +setup(use_scm_version={'write_to': os.path.join('astropy', 'version.py')}, ext_modules=get_extensions())