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

Instruct pip to install only a specific section of the pyproject.toml file. #11489

Closed
1 task done
wiseaidev opened this issue Oct 5, 2022 · 2 comments
Closed
1 task done
Labels
type: feature request Request for a new feature

Comments

@wiseaidev
Copy link

wiseaidev commented Oct 5, 2022

What's the problem this feature will solve?

Hey everyone. Using a pyproject.toml file, I am trying to find a way to tell pip to install a specific set of dependencies without installing the required ones. This would make sense when you have docs, and you want to install packages related to generating the docs. In this case, it is not mandatory to install the required core dependencies of a given package. Take the following as an example of pyproject.toml file:

[project]
dependencies = [
    "alembic==1.8.1",
    "APScheduler==3.9.1",
    "asyncpg==0.25.0",
]

[project.optional-dependencies]
docs = [
    "mkdocs-material==8.2.7",
    "mkdocs-minify-plugin==0.4.0",
    "mkdocs-render-swagger-plugin==0.0.3",
    "mkdocs-click==0.5.0",
    "mkdocs-git-revision-date-plugin",
    "mike==1.1.2",
]

Running pip install -e ".[docs]" will result in dependencies being installed first. I also tried pip install --no-deps -e ".[docs]" which resulted in the same behavior.

Describe the solution you'd like

Allow pip to install a specific set of dependencies without the dependencies section as described above, something like:

pip install --no-deps-install -e ".[docs]"

Alternative Solutions

Not sure at the moment.

Additional context

The main reason for this is to get rid of every instance of the requirements.txt file and emphasize following the pep-0631 specs. I am not sure if this feature already exists in pip. That's pretty much it. Have a nice day/evening.

Code of Conduct

@wiseaidev wiseaidev added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Oct 5, 2022
@pradyunsg
Copy link
Member

pradyunsg commented Oct 5, 2022

Thanks for filing this!

My take on this is that project.optional-dependencies is not meant for managing requirements for alternative environments; but rather for gating optional features behind presence of additional packages (eg: yaml support behind pyyaml). It's exposed to the end-users of the package, and not meant to be used in the manner elaborated here (i.e. package sets for development workflows).

As of today, higher level tools like Hatch, PDM, Poetry, and pipenv support some concept of "dependency groups" and pip allows you to manage requirements for different environments in different files that can be passed in to -r.

Consider using an environment management tool that's a higher level of abstraction on top of pip (I'd suggest hatch), or using separate files for this instead (pip's own codebase has a docs/requirements.txt and tests/requirements.txt).

@pradyunsg
Copy link
Member

Duplicate of #8049.

@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Nov 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants