-
-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
micropip.freeze
currently checks for the non-standard top_level.txt
file to fill the imports
field. This has a few issues:
- When the file is missing, no imports are included
- For namespace packages, the top-level imports is just the name of the namespace, but we want the imports field to name the package, e.g.
namespace.package
instead
A brief online search didn't reveal any good solutions:
- https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.packages_distributions can provide a top-level -> packages mapping for already-imported packages (which is good enough for freezing), which would solve (1) but not (2)
- https://discuss.python.org/t/determining-top-level-import-package-names-programmatically/45055/2 suggests reading the
RECORDS
file to extract all non-special directories. I would suggest to go even one step further and extract the common prefix for all non-special directories so that we could also translatenamespace/package
intonamespace.package
. To allow several adjacent namespace packages, perhaps the rule would be to look for directory prefixes until we find the first__init__.py
Metadata
Metadata
Assignees
Labels
No labels