-
Notifications
You must be signed in to change notification settings - Fork 1
Support collecting editable distributions #117
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
Conversation
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.
I don't really understand what the code does beyond loosely "gets the packages that are editable-y installed by inspecting some python file path names available in some metadata" but the code itself looks clean
from __future__ import annotations | ||
|
||
import re | ||
from importlib.metadata import Distribution, distributions |
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.
Are there docs for this distributions
function https://docs.python.org/3/library/importlib.metadata.html? Presumably it gets all packages in the current env or?
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.
Huh, right. I’m pretty sure it’s safe given that it’s in __all__
and therefore meant to be exported: python/cpython#110937
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.
Yup, @jaraco said so: python/importlib_metadata#494 (comment)
|
||
def _top_level_editable(dist: Distribution) -> Generator[str, None, None]: | ||
"""Find top-level packages in an editable distribution.""" | ||
for pth_file in dist.files or (): |
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.
Not sure I follow what is in files
given https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.Distribution. It's just all the files in the package or?
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.
Fixes #63
I just tested it on my scanpy dev environment, and it works!
>>> import scanpy, anndata; scanpy.logging.print_header() scanpy 1.12.0.dev128+g6bfc3323.d20250616 (1.12.0.dev93+gaef3e9e1.d20250724) anndata 0.11.4 ---- ---- asttokens 3.0.0 matplotlib 3.10.3 scikit-learn 1.7.0 …