Comments (4)
Since the directory does appear to be importable and since the package is explicitly reporting it as a top-level directory installed by the package, I'm going to say importlib_metadata is doing the right thing here and should be reflecting the presence of that top level name. I'd like to avoid special cases where possible.
Feel free to advocate for making a case for excluding that name. In particular, I'd like to know how the presence of this name causes harm (beyond a little surprise).
from importlib_metadata.
I doubt this has anything to do with the builder - pip generates pyc
files on install as per the wheel spec, which it appends to the RECORD
so that it will know to uninstall them. Because typing_extensions
is not a package but a single-file module, its __pycache__
is at the top level, which is why it is being returned by packages_distributions
.
from importlib_metadata.
Hmm. I agree - that's a little annoying that the .pyc file is showing up in the RECORD file, but that sounds like a bug in the builder. If a project legitimately wishes to install a __pycache__
into site-packages, it will be importable, so it probably should show up as a top-level module installed by that distribution.
draft $ mkdir __pycache__
draft $ py -q
>>> import __pycache__
>>> __pycache__.__path__
_NamespacePath(['/Users/jaraco/draft/__pycache__', '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/__pycache__', '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/__pycache__'])
You may be right that it makes sense to explicitly exclude __pycache__
, as it's commonly going to exist in sys.path
even when it wasn't installed by a package. But as long as it's explicitly mentioned in the RECORD, I'm tempted to say that importlib metadata should honor that record.
Is there a legitimate reason for the __pycache__
entry to be present in RECORD?
from importlib_metadata.
Your argument makes sense to me from the POV of importlib_metadata. I agree that it rather sounds like a bug in the builder.
The context I'm coming from is doing dependency checking where we need to be able to map from an import name we find in the user's code to a package name to be found in the user's declared dependencies (e.g. requirements.txt
, pyproject.toml
or similar). In this case, a package reporting __pycache__
as an "extra" import name is probably not going to create much of a problem for us, as we don't expect the user to import __pycache__
in their code. If this does end up becoming problematic, we can easily enough special-case it in our use of importlib_metadata.
Thanks for your consideration!
from importlib_metadata.
Related Issues (20)
- Change build backend to flit-core? HOT 2
- 6.8.0: pytest is failing in tests/test_api.py::APITests::test_prefix_not_matched` unit HOT 3
- PackageNotFoundError No package metadata was found for <myproject> HOT 1
- Question: parsing package names & versions from METADATA file instead of dist-info directory HOT 1
- Provide a helper for "is distribution present" HOT 2
- Mypy tests failing on Windows only HOT 1
- 6.9.0: `DiscoveryTests.test_package_discovery` fails HOT 7
- distributions() finds two packages for editable installs HOT 2
- MetadataPathFinder has `find_distributions` as a classmethod in CPython HOT 1
- Intersphinx mapping for stdlib version
- API incompatibility with `importlib.metadata` (or at least the API is not type-safe?) HOT 5
- AttributeError changed to AssertionError for invalid identifiers HOT 1
- Ensure stale empty python module directories don't break the build HOT 16
- 7.2.0: pytest fails in exercises.py units HOT 4
- importlib metadata 8.0 causes unusual errors in startup for twine, others(?) HOT 6
- .metadata is an empty message even for missing metadata HOT 3
- Make `importlib_metadata._meta.SimplePath` public HOT 4
- Vulnerability issue CVE-2024-5569 HOT 4
- Consider adding back a warning instead of KeyError HOT 2
- Tests started failing in main HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from importlib_metadata.