question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

I’m porting a setup.py file to declarative setup.cfg. In this package, an extra contains a hyphen. This works when defined in setup.py but does not when defined in setup.cfg. If I change the hyphen to an underscore, it works again, but this would break the extra for users.

To reproduce:

setup.py:

from setuptools import setup

setup()

setup.cfg:

[options.extras_require]
extra-a =
    pytest
extra_b =
    pytest

tox.ini (to automate the virtual env creation)

[testenv:a]
extras = extra-a

[testenv:b]
extras = extra_b

Then run:

$ tox -e a
$ tox -e b

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jaracocommented, Mar 1, 2021

When this bug was filed, setuptools relied on distutils to parse the config files. Since then, in 24be5abd4cbd9d84537c457456f841522d626e14, 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.

0reactions
melissa-kun-licommented, Mar 1, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to put extras_require in setup.cfg - Stack Overflow
You need a config section: [options.extras_require] test = faker; pytest. Syntax is documented here. Share. Share a link to this answer.
Read more >
setuptools.txt - Collection of Repositories
``extras_require`` A dictionary mapping names of "extras" (optional features of your project) to strings or lists of strings specifying what other distributions ...
Read more >
setuptools-0.6.14devdev.egg.darcspatch.txt - Tahoe-LAFS
misc/dependencies/setuptools-0.6c12dev.egg oldhex ... + """Distribution doesn't have an "extra feature" of the given name""" + +_provider_factories ...
Read more >
venv/Lib/site-packages/setuptools/dist.py
from setuptools.config import parse_configuration ... 'extras_require' -- a dictionary mapping names of optional "extras" to the.
Read more >
CHANGES.rst - platform/external/python/setuptools - Google Git
#1207: Add support for ``long_description_type`` to setup.cfg. declarative config as intended ... #732: Now extras with a hyphen are honored per PEP 426....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found