-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve info tool dependencies option #2303
base: main
Are you sure you want to change the base?
Improve info tool dependencies option #2303
Conversation
b16e27c
to
f2e4c43
Compare
It seems that the online tests fail to find the Locally it works as expected. |
The tests are run on the installed ctapipe, which doesn't have a setup.cfg |
Dammit... And I guess this Can't we run the tests on the development version and in a separate job just test that the user installation simply doesn't crash? The code to test is the same. |
It seems that there is at least |
You can't read setup.cfg in The main issue I have with that is that |
In general, any functionality like this should use the new importlib.metadata (importlib_metadata before 3.9) module prodiving such information independently of the setup.cfg / pyproject.toml or whatever packaging system is used. |
I used The internal approach is somewhat more brute-force than I wished: it appears that from Python3.10 that library allows using JSON to explore the metadata and simplifies it a bit, but since we test from 3.9 I had to keep things compatible with the older API. The unit-tests I added based on pytest-console-scripts now work as intended for some reason. |
On a side note: shouldn't |
It does: > ctapipe-info --resources
*** ctapipe resources ***
CTAPIPE_SVC_PATH: (directories where resources are searched)
no path is set
RESOURCE NAME : LOCATION
----------------------------------------------------------------------
ASTRICam.camgeom.fits.gz : ~/.cache/ctapipe/cccta-dataser
CHEC.camgeom.fits.gz : ~/.cache/ctapipe/cccta-dataser
DigiCam.camgeom.fits.gz : ~/.cache/ctapipe/cccta-dataser
FACT.camgeom.fits.gz : ~/.cache/ctapipe/cccta-dataser |
for package in all_dependencies: | ||
if "extra" in package: | ||
for extra in extras: | ||
if extra in package: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is the same if twice here
version = get_module_version(name) | ||
print(f"{name:>20s} -- {version}") | ||
meta = metadata("ctapipe") | ||
extras = [v for k, v in meta.items() if k == "Provides-Extra"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be:
In [10]: meta.get_all("Provides-Extra")
Out[10]: ['all', 'dev', 'docs', 'tests']
While porting this for SWGO software I modified the code to read the dependencies at runtime from
setup.cfg
(like we do already for the Sphinx documentation configuration).While doing this I noticed that the code using
importlib.import_module
sometimes gives rise to aModuleNotFoundError
exception, so I added it to the firsttry/except
block to fallback toimportlib.metadata.version
and only if that also fails we give up.I also used pytest-console-scripts to create 1 test for each flag (but see this issue I opened there, even though I tested each of them separately).