Packages installed with setuptools
with identical entry points are loaded incorrectly
#3989
-
I have two packages that have been installed using the for dist in list(importlib_metadata.distributions()):
for ep in dist.entry_points:
....
plugin = ep.load()
.... The issue is that when creating the >>> import importlib_metadata
>>> for dist in list(importlib_metadata.distributions()):
... for ep in dist.entry_points:
... if ep.name.startswith('pytest_plugin'):
... print(ep)
... print(ep.load())
...
EntryPoint(name='pytest_plugin1', value='src.plugin', group='pytest11')
<module 'src.plugin' from '/home/user/pytest_plugins/pytest_plugin1/src/plugin.py'>
EntryPoint(name='pytest_plugin2', value='src.plugin', group='pytest11')
<module 'src.plugin' from '/home/user/pytest_plugins/pytest_plugin1/src/plugin.py'> Is this expected behaviour after installing a package using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Hi @dgard1981, if I had to guess, I would say that it seems that the configuration of the packages you are creating is a bit off, and as a result they are overwriting each other. For both cases, both projects seem to want to install the I would recommend the following layout structure: <pytest_plugin1_project_dir>
├── pyproject.toml
└── src
└── pytest_plugin1
├── __init__.py
└── plugin.py
<pytest_plugin2_project_dir>
├── pyproject.toml
└── src
└── pytest_plugin2
├── __init__.py
└── plugin.py Then if you are using # <pytest_plugin1_project_dir>/pyproject.toml
...
[project.entry-points.pytest11]
pytest_plugin1 = "pytest_plugin1.plugin"
# <pytest_plugin2_project_dir>/pyproject.toml
...
[project.entry-points.pytest11]
pytest_plugin2 = "pytest_plugin2.plugin"
# Ref: https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#entry-points If you are using You might also have to change your If in doubt, you can always double check by installing the projects without using the |
Beta Was this translation helpful? Give feedback.
This is a "cached build temporary artifact" generated by setuptools. It should not be very relevant and if you remove it the only thing it does is to clear the cache.
pip
is a complicated (very useful) beast on its own...pip
was supposed to always adopt the "isolated builds" behaviour (e.g. PEP 517 and PEP 660) by default after23.1
. However they are still holding it back to avoid breaking old distributions that have not adapted yet. They have a custom logic that…