-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
setuptools version
latest
Python version
Python 3.13
OS
Arch Linux
Additional environment information
No response
Description
In entry_point extra dependency specification, it doesn't work to use _ instead of -.
Expected behavior
It should probably either work or raise a loud warning for the user instead of silently ignore.
How to Reproduce
create a Python virtual environment.
python -m venv a
cd a
. bin/activate
create the following folder structure in /tmp/my_project.
./my_project
./my_project/__init__.py
./setup.py
where
[my_project]$ cat my_project/__init__.py
def main():
pass
[my_project]$ cat setup.py
from setuptools import setup, find_packages
setup(
name='my_project',
version='0.1',
packages=find_packages(),
install_requires=[
],
extras_require={
'a_b': [],
'ab': [],
},
entry_points={
'my_project.xyz': [
'test1 = my_project:main [a_b]',
'test2 = my_project:main [ab]',
],
},
)
install my_project and `setuptools
pip install '/tmp/my_project[a_b,ab]' setuptools
run a test program
(a) [a]$ python -c "import pkg_resources; print(pkg_resources.load_entry_point('my_project', 'my_project.xyz', 'test1'))"
<string>:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources; print(pkg_resources.load_entry_point('my_project', 'my_project.xyz', 'test1'))
Traceback (most recent call last):
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 3108, in requires
deps.extend(dm[safe_extra(ext)])
~~^^^^^^^^^^^^^^^^^
KeyError: 'a_b'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
import pkg_resources; print(pkg_resources.load_entry_point('my_project', 'my_project.xyz', 'test1'))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 535, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 3208, in load_entry_point
return ep.load()
~~~~~~~^^
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 2777, in load
self.require(*args, **kwargs) # type: ignore[arg-type]
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 2804, in require
reqs = self.dist.requires(self.extras)
File "/tmp/a/lib/python3.13/site-packages/pkg_resources/__init__.py", line 3110, in requires
raise UnknownExtra(f"{self} has no such extra feature {ext!r}") from e
pkg_resources.UnknownExtra: my-project 0.1 has no such extra feature 'a_b'
note that the other feature (without the _) works
(a) [a]$ python -c "import pkg_resources; print(pkg_resources.load_entry_point('my_project', 'my_project.xyz', 'test2'))"
<string>:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources; print(pkg_resources.load_entry_point('my_project', 'my_project.xyz', 'test2'))
<function main at 0x79401e74a020>
Background: Plover uses this https://github.com/openstenoproject/plover/blob/main/setup.cfg#L67 , as well as pkg_resources to get a list of entry points and load them, and for some reason it works for me until some recent changes. So not sure whose fault this is.
Discussion in Plover repo: opensteno/plover#1704
- should be equivalent to _ right? https://discuss.python.org/t/what-extras-names-are-treated-as-equal-and-why/7614/3
Output
see above