Skip to content
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

DM-42391: Make use of packages_distributions() in utils.packages #178

Merged
merged 7 commits into from Jan 8, 2024

Conversation

erykoff
Copy link
Contributor

@erykoff erykoff commented Jan 8, 2024

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d9c83c1) 94.31% compared to head (494e735) 93.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
- Coverage   94.31%   93.98%   -0.34%     
==========================================
  Files          46       46              
  Lines        3186     3206      +20     
==========================================
+ Hits         3005     3013       +8     
- Misses        181      193      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erykoff erykoff requested a review from timj January 8, 2024 17:05
@erykoff
Copy link
Contributor Author

erykoff commented Jan 8, 2024

Also on this PR I removed support for python 3.9 (since packages_distributions() requires 3.10), and pinned the documenteer version to 0.8.2.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this.

For the attrs/attr case do we still end up requesting the version from attr twice? Or is the second time skipped because of cache access?

@@ -49,7 +50,9 @@
# Python modules to attempt to load so we can try to get the version
# We do this because the version only appears to be available from python,
# but we use the library
PYTHON = {"galsim"}
PYTHON: set[str] = set()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some sense we should delete all this stuff since it's a bit unreliable and for us conda reports all these versions directly. Not for this ticket of course.

namespace = name.split(".")[0]

# package_dist is a mapping from import namespace to distribution
# package names. This may be a one-to-many mapping due to namespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such as:

sphinxcontrib: ['sphinxcontrib-bibtex', 'sphinxcontrib-autoprogram', 'sphinxcontrib-htmlhelp', 'sphinxcontrib-qthelp', 'sphinxcontrib-serializinghtml', 'sphinxcontrib-devhelp', 'sphinxcontrib-jsmath', 'sphinxcontrib-applehelp', 'sphinxcontrib-doxylink', 'sphinxcontrib-jquery']
lsst: ['ts-xml']

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. This is somewhat described in https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#packaging-namespace-packages but it's not strictly required but it is the convention for every set that I've seen.

# Check if the components start with the namespace; this is
# needed because (at least) lsst.ts packages do not use
# ``lsst`` in the package name.
if dist_name_parts[0] != namespace:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to install ts-xml in the action so you can get code coverage? It would be nice if we always had the lsst prefix in the public distributions of things like this...


if not found:
# Fall back to name.
dist_name = name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what happens currently in the EUPS case? Maybe mention that in the comment?

…ble.

This new version uses importlib.metadata.packages_distributions()
to get mappings from namespace to packages installed. There are
extra comparisons that are needed to properly handle namespace
packages which are still a little janky with this system.
This way we can track that everything works when there is a conda package using
the lsst namespace.
@erykoff
Copy link
Contributor Author

erykoff commented Jan 8, 2024

Re: attr/attrs. The attrs package supplies both attr and attrs and so each of these gets listed in the imported modules if they've both been imported. And each gets its own version lookup (but just once each). I don't know if the package metadata lookup is cached or not in this situation.

@erykoff erykoff merged commit 1e4d8a3 into main Jan 8, 2024
15 of 16 checks passed
@erykoff erykoff deleted the tickets/DM-42391 branch January 8, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants