-
-
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
extras_require in setup.cfg doesn't allow hyphen in extras name #1608
Comments
It looks like distutils automatically converts hyphens to underscores internally when reading |
@jdufresne According to this guide, underscores, hyphens and periods are all supposed to be treated equivalently.when normalizing names, referencing PEP 508, but I don't see anything about that there or in PEP 423. Presumably if |
Thanks for taking a look. In that case, do you think this is an issue in pip and not setuptools? If I run the command:
The extras are not installed. But if I run the command
The extras are installed. Should I file this issue with pip? |
I'm not quite sure if there's an authoritative claim that those should be treated the same or if it was describing the behavior of a specific tool. It could be that pip is not normalizing correctly or it could be that we should be normalizing to We'll at least leave this ticket open until we get to the bottom of this. Presumably a change needs to be made in at least one of: setuptools, pip, the packaging tutorials. |
When I read that reference, I see explicit mention of "project" names, but not necessarily other names. I'm strongly in favor of honoring the user's intention here and if for nothing other than feature parity, support untransformed names for extras from declarative config. |
That distutils code isn't readily tweakable. I think the preferred solution is for setuptools not to rely on distutils to parse the options. |
Ugh. The |
Here's the start of the idea I have in mind: diff --git a/setuptools/dist.py b/setuptools/dist.py
index 7062ae8d..e92e7779 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -30,7 +30,7 @@ from . import SetuptoolsDeprecationWarning
from setuptools.depends import Require
from setuptools import windows_support
from setuptools.monkey import get_unpatched
-from setuptools.config import parse_configuration
+from . import config
import pkg_resources
from .py36compat import Distribution_parse_config_files
@@ -563,8 +563,10 @@ class Distribution(Distribution_parse_config_files, _Distribution):
"""
_Distribution.parse_config_files(self, filenames=filenames)
- parse_configuration(self, self.command_options,
- ignore_option_errors=ignore_option_errors)
+ cfg = config.read_configuration(
+ filenames=filenames, ignore_option_errors=ignore_option_errors,
+ )
+ config.apply_configuration(self, cfg)
self._finalize_requires()
def parse_command_line(self): I'm suggesting a refactor of |
This breaks
will install the file to |
When this bug was filed, setuptools relied on distutils to parse the config files. Since then, in 24be5ab, the code was inlined, so it should be straightforward to adjust the parsing behavior. I believe it's worth seriously considering just dropping that substitution. |
As Jason mentioned, since the config parsing code is now within Setuptools, I believe this line is responsible for turning hyphens to underscores: https://github.com/pypa/setuptools/blob/main/setuptools/dist.py#L601. I wonder if we can simply remove the line, but I'm not sure if there are disadvantages to doing this. |
I'm porting a
setup.py
file to declarativesetup.cfg
. In this package, an extra contains a hyphen. This works when defined insetup.py
but does not when defined insetup.cfg
. If I change the hyphen to an underscore, it works again, but this would break the extra for users.To reproduce:
setup.py
:setup.cfg
:tox.ini
(to automate the virtual env creation)Then run:
Notice the extras are installed in the "b" environment but not the "a" environment. AFAICT, the only difference is the use of a hyphen instead of an underscore.
The text was updated successfully, but these errors were encountered: