Skip to content
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

Provide support for dash-separated keys in setup.cfg, warns for future incompatibility of certain keys #2588

Merged
merged 7 commits into from
Mar 3, 2021

Conversation

melissa-kun-li
Copy link
Contributor

@melissa-kun-li melissa-kun-li commented Mar 3, 2021

Summary of changes

Closes #1608

This change will preserve dashes in the keys of setup.cfg. This will also implement a compatibility method which will warn users through UserWarning if they use an alias involving a dash which should technically be underscore separated (e.g. using author-email instead of author_email). After warning for these types of aliases, dash to underscore conversion will be performed for compatibility, but in the future Setuptools will no longer support the alias conversion.

Pull Request Checklist

Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great. Nice work on creating tests for the warning as well as for the condition that led to this change. Also nice work on the guidance. I'm a little concerned about the explicit list of options. Let's mull over the tradeoffs there and we're good to go.

setuptools/dist.py Outdated Show resolved Hide resolved
@jaraco
Copy link
Member

jaraco commented Mar 3, 2021

Looks great. Well done!

@jaraco jaraco merged commit 729c45d into pypa:main Mar 3, 2021
joguSD added a commit to joguSD/botocore that referenced this pull request Mar 5, 2021
joguSD added a commit to joguSD/botocore that referenced this pull request Mar 5, 2021
joguSD added a commit to joguSD/boto3 that referenced this pull request Mar 5, 2021
@hugovk
Copy link
Contributor

hugovk commented Mar 6, 2021

Hi! I checked https://setuptools.readthedocs.io/en/latest/history.html#v54-1-0 but I wasn't entirely clear: is this meant to warn for all keys using hyphens in setup.cfg? For example, I see warnings for these Flake8 options:

$ cat setup.cfg
[flake8]
extend-ignore = E203
max-line-length = 88

[isort]
profile = black

[tool:pytest]
addopts = -ra --color=yes
testpaths = Tests
$ python setup.py --version
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/dist.py:633: UserWarning: Usage of dash-separated 'extend-ignore' will not be supported in future versions. Please use the underscore name 'extend_ignore' instead
  warnings.warn(
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/dist.py:633: UserWarning: Usage of dash-separated 'max-line-length' will not be supported in future versions. Please use the underscore name 'max_line_length' instead
  warnings.warn(
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/dist.py:633: UserWarning: Usage of dash-separated 'extend-ignore' will not be supported in future versions. Please use the underscore name 'extend_ignore' instead
  warnings.warn(
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/setuptools/dist.py:633: UserWarning: Usage of dash-separated 'max-line-length' will not be supported in future versions. Please use the underscore name 'max_line_length' instead
  warnings.warn(
8.2.0.dev0

Flake8 themselves say both underscores and hyphens are fine in setup.cfg:

https://flake8.pycqa.org/en/latest/user/configuration.html#project-configuration

Thanks!

@melissa-kun-li
Copy link
Contributor Author

melissa-kun-li commented Mar 7, 2021

@hugovk
Hi! So prior to v54.1.0, setup.cfg read hyphens as underscores internally which is why flake8 said that you can use either hyphens or underscores because it was being converted to underscores in the background anyway. However this caused bugs for users who needed dashes to be preserved in setup.cfg. The recent warning is to warn for future deprecation of dashes in keys of setup.cfg for those keys which should actually be underscores. So the flake8 documentation was right before, but maybe now we should let them know so they can update it. edited from what Jason said below, I'll work on a fix so it doesn't warn for flake8 and others :)

@jaraco

@jaraco
Copy link
Member

jaraco commented Mar 7, 2021

Oh, this was a case I hadn't considered during the review. I had expected it would only apply to sections that setuptools is using.

The setup.cfg file serves as a home for many projects outside the scope of distutils/setuptools. In that case, Setuptools probably shouldn't be as opinionated about the format of the keys. I'd like to avoid other projects needing to mirror this change.

I believe we should come up with a patch to avoid these warnings. I'll convert Hugo's comment to an issue. @melissa-kun-li Would you be interested in working on the patch? In this case, I'd say a test is optional. Use misc for the changelog.

@melissa-kun-li
Copy link
Contributor Author

@jaraco Sure! I'll work on a fix, I have an idea in mind

cf-natali added a commit to cf-natali/ntplib that referenced this pull request May 29, 2021
Update description_file key in setup.cfg to silence deprecation warning.

For reference, the setuptools change was introduced by pypa/setuptools#2588
ammgws added a commit to ammgws/deck.gl that referenced this pull request Oct 25, 2021
Dash-separated options in 'setup.cfg' will become unsupported at some
point in the future: pypa/setuptools#2588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extras_require in setup.cfg doesn't allow hyphen in extras name
3 participants