setup-cfg-fmt
setup-cfg-fmt copied to clipboard
Support `file:` for requires statements
Setuptools have added support file:
for requires statements (as a beta feature)
I don't know if it makes sense to add support for this already, I just noticed it when going to test this feature.
Example
A simple setup.cfg
(which works fine):
[metadata]
name = hi
version = 0.1.0
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
[options]
packages = find:
python_requires = >=3.8
[options.extras_require]
dev = file:requirements-dev.txt
Then run $ setup-cfg-fmt setup.cfgt
[options.extras_require]
-dev = file:requirements-dev.txt
+dev =
+ file:requirements-dev.txt
Then try to install the package (with pip install -e .[dev]
), and setuptools will raise an error because can't parse this. Also, if we have a space between :
and the filename, setup-cfg-fmt will exclude the filename.
[options.extras_require]
-dev = file: requirements-dev.txt
+dev =
+ file:
Currently values under options.extra_requires
get rendered as lists. Should dev
be special-cased?
Sorry nevermind, dev
is just an arbitrary name. I realize the issue is in this part of the code https://github.com/asottile/setup-cfg-fmt/blob/acc732d13a11c70e23f887586060c1ee28e0d7f7/setup_cfg_fmt.py#L222-L238 but it's not clear what the right behavior is supposed to be. Is it valid to specify file: requirements-dev.txt
in addition to other library dependencies? Or must it be on its own?
Hi, I did some tests to explore the correct behaviors, here are my findings.
According to the documents of setuptools 68.2.2,
file:
- Value is read from a list of files and then concatenated.
After some testing, I found the following formats are valid
[options]
install_requires = file:requirements.txt
install_requires = file: requirements.txt ; The <space> after colon is optional
install_requires = file:
requirements.txt
install_requires = file: requirements.txt, other_requirements.txt
install_requires = file:
requirements.txt, other_requirements.txt
The following format is invalid, which causes error when installing the package (with pip install .
)
[options]
install_requires =
file: requirements.txt, other_requirements.txt
The following format is also invalid. Although it doesn't trigger error when installing, the requirements will not be installed as expected.
[options]
install_requires =
requirements.txt
other_requirements.txt