Skip to content

Conversation

flying-sheep
Copy link
Member

@flying-sheep flying-sheep commented Jul 24, 2025

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
…

@flying-sheep flying-sheep linked an issue Jul 24, 2025 that may be closed by this pull request
@flying-sheep flying-sheep marked this pull request as ready for review July 24, 2025 14:24
@flying-sheep flying-sheep requested a review from ilan-gold July 24, 2025 14:25
Copy link

@ilan-gold ilan-gold left a 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

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?

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

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


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 ():

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah:

image

also a candidate for python/cpython#110937

@flying-sheep flying-sheep merged commit 4c2b057 into main Jul 24, 2025
5 checks passed
@flying-sheep flying-sheep deleted the pa/editable-dists branch July 24, 2025 15:28
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.

Editable package support

2 participants