Idea: use automatic list of dependencies for pytest display plugin
See original GitHub issueCurrently, the pytest display plugin we have shows a fixed set of packages in the pytest header, and allows other packages using the astropy test runner to configure this. I would like to suggest an alternative which would remove the need for packages to customize this, which is to show the list of all direct dependencies by default. With the following code:
from pkg_resources import working_set
def list_dependency_versions(name):
pkg = working_set.by_key['astropy']
requirements = pkg.requires(pkg.extras)
for req in sorted(requirements, key=lambda x: x.name.lower()):
if req.name in working_set.by_key:
req_pkg = working_set.by_key[req.name]
print(f" {req.name}: {req_pkg.version}")
else:
print(f" {req.name}: Not installed")
list_dependency_versions('astropy')
I can get:
asdf: Not installed
beautifulsoup4: 4.7.1
bintrees: Not installed
bleach: 3.1.0
bottleneck: 1.2.1
coverage: Not installed
h5py: 2.9.0
html5lib: Not installed
ipython: 7.5.0
ipython: 7.5.0
jplephem: Not installed
matplotlib: 3.1.0
mpmath: 1.1.0
numpy: 1.16.4
objgraph: Not installed
pandas: 0.24.2
pytest: 4.6.2
pytest-astropy: 0.5.0
pytest-mpl: Not installed
pytest-xdist: Not installed
pytz: 2019.1
PyYAML: Not installed
scikit-image: Not installed
scipy: 1.3.0
skyfield: Not installed
sortedcontainers: Not installed
sphinx-astropy: Not installed
We could still keep the option to override this in other packages if we want, but at least this should make it so that in practice it should never be needed - and we could actually remove it from the package template and just document how to do it in the package-template docs since it should be rare. If people are on board with the idea, I could update the pytest display plugin to do something like this.
(related thought: is there a reason the display plugin is still in astropy rather than a plugin package?)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:27 (27 by maintainers)
Top GitHub Comments
For me that’s an argument for the automated list - as then people might fix this kind of outrageous behavior!
Just copy/paste into python session 😃