-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ENH] Importlib Metadata shows two distributions with same name for editable installs #4170
Comments
Hi @Jacob-Stevens-Haas, thank you very much for opening this discussion. For the time being this is a limitation for the combo The current design of setuptools requires the We do have a milestone for removing the If this turns up to be problematic for you, please consider the following workarounds while the long-term implementation is not ready:
If any member of the community is interested in contributing towards the goal of removing the reliance on |
Thanks for the quick reply! And yeah, that would be a fine workaround. Given that removing
I have a branch in the above repo with an src layout, and starting everything from scratch with that layout gives similar results: 'foo'
'pip'
'setuptools'
'foo'
[PackagePath('__editable__.foo-0.1.0.pth'),
PackagePath('foo-0.1.0.dist-info/INSTALLER'),
PackagePath('foo-0.1.0.dist-info/METADATA'),
PackagePath('foo-0.1.0.dist-info/RECORD'),
PackagePath('foo-0.1.0.dist-info/REQUESTED'),
PackagePath('foo-0.1.0.dist-info/WHEEL'),
PackagePath('foo-0.1.0.dist-info/direct_url.json'),
PackagePath('foo-0.1.0.dist-info/top_level.txt')]
[PackagePath('pyproject.toml'),
PackagePath('src/foo/__init__.py'),
PackagePath('src/foo.egg-info/PKG-INFO'),
PackagePath('src/foo.egg-info/SOURCES.txt'),
PackagePath('src/foo.egg-info/dependency_links.txt'),
PackagePath('src/foo.egg-info/top_level.txt')]
{'_distutils_hack': ['setuptools'],
'debian': ['setuptools'],
'foo': ['foo', 'foo'],
'pip': ['pip'],
'pkg_resources': ['setuptools'],
'setuptools': ['setuptools']}
Is this because during python startup, importing
I'd love to, but realistically I'll probably just learn more about setuptools and why removing reliance on egg-info is so daunting... the classic "know enough to be dangerous... but not to be useful" stage. |
That is something to be discussed in the
I see... Yeap, that is correct. The
That is probably 90% reliable 😅. The
And this is the reference for the |
Ah, thanks for all that! After a cursory reading, does setuptools create an editable install as a PEP660 editable wheel? Or does the presence of an Also, and this might not be the ideal solution, would it be possible to add direct_url.json to the egg-info directory? |
Ideally yes. But that will depend on how
The presence of the
The |
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html It's got some bugs/warts: * pypa/setuptools#2531 * https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182 So switch to using `importlib` functions which are part of the Python standard library as of `3.8`. This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work. I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team. I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to. Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that: * pypa/setuptools#4170
In my team's case I've found that as soon as I install a package in editable mode, I get duplicates of every package in my site-packages folder from |
setuptools version
setuptools 69.0.3
Python version
3.10.12
OS
Ubuntu
Additional environment information
Applies to both src/ and flat layout
Description
I was trying to identify editable packages installed in my current environment by looking at direct_url.json for a package given by
importlib.metadata.distribution(name)
. It was showing that file didn't exist. Upon further investigation,importlib.metadata.distributions()
had two entries for my package - onePathDistribution
who's files containsdist-info
in site-packages, and anotherPathDistribution
who's files containegg-info
, built by setuptools in the local directory.distribution(name)
only finds the local version. Interestingly,importlib.metadata.packages_distributions()
shows that the distribution packagefoo
has two import packages associated, both with the same names.Expected behavior
I would've expected just one distribution package for an editable install, in this case with a single import package associated. At a lower level, I'm not sure it really makes sense to ever have two distributions of the same name installed, and therefore perhaps setuptools should have internally raised an error when
distributions
finds two of the same name or two import packages with the same name in the same distribution.How to Reproduce
I've got an example distribution package, foo, with one import package, also named foo:
pip install -e .
python show_dists.py
This will print the results of
distributions()
, showing two named "foo", the files in the two matching distributions, and then thepackages_distributions()
results.src
branch) has same result.pip freeze
shows just a single distribution packageOutput
The text was updated successfully, but these errors were encountered: