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

Add --extra-index-url option to pyproject.toml to install requirements.txt #13000

Closed
1 task done
sglbl opened this issue Oct 11, 2024 · 4 comments
Closed
1 task done
Labels
resolution: duplicate Duplicate of an existing issue/PR resolution: needs standard Should be agreed as a standard before implementation type: feature request Request for a new feature

Comments

@sglbl
Copy link

sglbl commented Oct 11, 2024

What's the problem this feature will solve?

My requirements.txt file:

fastapi==0.109.0
torch==2.3.1+cpu

I am trying to switch to pyproject.toml as suggested so that I don't have to use setup.py, setup.cfg and pip.conf. But at the same time I still want to use the simlicity of pip freeze to requirements.txt file so I don't have to add dependencies by hand in pyproject.toml and I will not have to use poetry like package.

[project]
name = "sg-project"
version = "0.1"
dynamic = ["dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

Running it with:
pip install -e .

Describe the solution you'd like

dependencies = {file = ["requirements.txt"]} works if I didn't have torch+cpu but now it doesn't work.

I would like the solution to be one of these or something that I will not use other files like pip.conf

  1. When I want to add extra-index-url to the requirements.txt it doesn't work anymore.
  2. I tried to add it to dependencies like this and it didn't work:
dependencies = [
    "torch==2.3.1+cpu @ https://download.pytorch.org/whl/cpu"
]
  1. Another solution that might be helpful
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"], extra-index-url = ["https://download.pytorch.org/whl/cpu"]}

Alternative Solutions

I know creating pip.conf and moving the filled file inside the virtual environment works but it would be better without needing this.

Additional context

No

Code of Conduct

@sglbl sglbl added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Oct 11, 2024
@notatallshaw
Copy link
Member

Everything outside the [tool.*] section of a pyproject.toml is defined by standards, and pip follows those standards, to add something new you start a discussion for a new standard, that discussion is done on the Python discuss board: https://discuss.python.org/c/packaging/14

Pip configuration is all currently read out of pip.[conf|ini] files, if pip were to read pip specific configuration out of a pyproject.toml it must be done from a section [tool.pip]. I have not seen any proposal that pip should start reading configuration out of pyroject.toml, I agree it would be a quality of life improvement for many users, but there would also be a lot of design choices to make and it would be a non-trivial project. I imagine someone would really need to step up in terms of providing resources for that project.

@notatallshaw
Copy link
Member

@notatallshaw
Copy link
Member

I've created a dedicated issue for reading pip configuration out of pyproject.toml: #13003

As mentioned, making index urls a standard part of pyproject.toml would need to be discussed on: https://discuss.python.org/c/packaging/14

@notatallshaw notatallshaw closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2024
@notatallshaw notatallshaw added resolution: duplicate Duplicate of an existing issue/PR resolution: needs standard Should be agreed as a standard before implementation and removed S: needs triage Issues/PRs that need to be triaged labels Oct 12, 2024
@sglbl
Copy link
Author

sglbl commented Oct 14, 2024

I've created a dedicated issue for reading pip configuration out of pyproject.toml: #13003

As mentioned, making index urls a standard part of pyproject.toml would need to be discussed on: https://discuss.python.org/c/packaging/14

Thank you for creating a dedicated issue for reading pip configuration out of pyproject.toml

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR resolution: needs standard Should be agreed as a standard before implementation type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants