[5.0RC1] utils.minversion("astropy", "5.0") doesn't work (and seems unneeded?)
See original GitHub issueDescription
When building the Debian package, the tests are run on the built but not installed package. In this case, I get the following error:
cd '/build/astropy-5.0~rc1/.pybuild/cpython3_3.9/build'; python3.9 -m pytest
[…]
astropy/utils/introspection.py:157: in minversion
module_version = metadata.version(module_name)
/usr/lib/python3.9/importlib/metadata.py:551: in version
return distribution(distribution_name).version
/usr/lib/python3.9/importlib/metadata.py:524: in distribution
return Distribution.from_name(distribution_name)
/usr/lib/python3.9/importlib/metadata.py:187: in from_name
raise PackageNotFoundError(name)
E importlib.metadata.PackageNotFoundError: astropy
During handling of the above exception, another exception occurred:
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
???
<frozen importlib._bootstrap>:1007: in _find_and_load
???
<frozen importlib._bootstrap>:972: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:228: in _call_with_frames_removed
???
<frozen importlib._bootstrap>:1030: in _gcd_import
???
<frozen importlib._bootstrap>:1007: in _find_and_load
???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:680: in _load_unlocked
???
<frozen importlib._bootstrap_external>:850: in exec_module
???
<frozen importlib._bootstrap>:228: in _call_with_frames_removed
???
astropy/cosmology/tests/__init__.py:7: in <module>
import mypackage
astropy/cosmology/tests/mypackage/__init__.py:1: in <module>
from . import cosmology, io
astropy/cosmology/tests/mypackage/io/__init__.py:20: in <module>
ASTROPY_GE_5 = minversion("astropy", "5.0")
astropy/utils/decorators.py:547: in wrapper
return function(*args, **kwargs)
astropy/utils/introspection.py:164: in minversion
module_version = metadata.version(dist_names[module_name][0])
E KeyError: 'astropy'
Aside from the error itself, I am wondering why we need to check for the version here at all?
Expected behavior
Tests should pass; I would expect this even on a non-installed Astropy.
Actual behavior
See above
Steps to Reproduce
- Build the package with
python3 setup.py build
- cd to the build dir;
python3.9 -m pytest
System Details
Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
Platform: Linux-5.14.0-2-amd64-x86_64-with-glibc2.32
Full Python Version: 3.9.7 (default, Sep 24 2021, 09:43:00) [GCC 10.3.0]
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8 byteorder: little float info: dig: 15, mant_dig: 15
Package versions: Numpy: 1.19.5 Scipy: 1.7.1 Matplotlib: 3.3.4 h5py: not available Pandas: not available PyERFA: 2.0.0 Cython: 0.29.24 Scikit-image: not available asdf: not available pyarrow: not available
Using Astropy options: remote_data: none.
Matplotlib: 3.3.4 Freetype: 2.11.0 ARCH_ON_CI: undefined IS_CRON: undefined
rootdir: /build/astropy-5.0~rc1, configfile: setup.cfg plugins: astropy-header-0.1.2, hypothesis-5.43.3, arraydiff-0.3, mpl-0.11, filter-subpackage-0.1.1, cov-3.0.0, doctestplus-0.11.0, remotedata-0.3.2, mock-3.6.1, openfiles-0.5.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Thanks to @nstarman for the quick fix!
I don’t understand why this is needed in the
cosmology
tests, @nstarman ? If we need to keep it, we could use insteadimport astropy; minversion(astropy, ....)
sinceminversion
would then use the__version__
attribute.