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

Support file: for requires statements #161

Open
johnnv1 opened this issue Sep 19, 2022 · 3 comments
Open

Support file: for requires statements #161

johnnv1 opened this issue Sep 19, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@johnnv1
Copy link

johnnv1 commented Sep 19, 2022

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:
@asottile asottile added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 10, 2022
danielhollas added a commit to danielhollas/aiidalab-qe that referenced this issue Dec 3, 2022
Conflicts with current setup.cfg due to
asottile/setup-cfg-fmt#161
@mxr
Copy link
Contributor

mxr commented Dec 16, 2022

Currently values under options.extra_requires get rendered as lists. Should dev be special-cased?

@mxr
Copy link
Contributor

mxr commented Dec 16, 2022

Sorry nevermind, dev is just an arbitrary name. I realize the issue is in this part of the code

normalized = sorted(
(_normalize_req(req) for req in require_group),
key=lambda req: (';' in req, _req_base(req), req),
)
normalized.insert(0, '')
return normalized
def _normalize_req(req: str) -> str:
lib, _, envs = req.partition(';')
normalized = _normalize_lib(lib)
envs = envs.strip()
if not envs:
return normalized
return f'{normalized};{envs}'
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?

@chien-liu
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants