The --only-deps flag in Pip 26.2 solves a problem that Python developers have been struggling with since 2010. How does this long-awaited feature work, and why could it revolutionize application deployment?
Why was --only-deps needed?
For 16 years, Python developers had to manage without the ability to install only the dependencies of a package without the package itself. This issue was particularly burdensome in deployment scenarios where often only the dependencies are required – for example, when building Docker containers or preparing CI/CD environments. The lack of this feature forced the use of various workarounds that were not only time-consuming but also error-prone.
The most popular workarounds included:
- Manually parsing
setup.pyorpyproject.tomlfiles and extracting dependencies using scripts. - Using external tools such as
pipdeptreeorpoetry export. - Installing the package and then removing it (
pip install package && pip uninstall -y package), which was inefficient and could cause version conflicts.
As Hynek Schlawack noted in a 2024 article, such solutions were far from ideal and often led to issues in production environments. This problem affected not only deployment but also other aspects of dependency management, such as testing or building container images.
How does the --only-deps flag work in Pip 26.2?
The --only-deps flag introduced in Pip 26.2 allows for the installation of only a package's dependencies, without the package itself. Here is the basic syntax:
pip install --only-deps <package_name>
For example, the command:
pip install --only-deps numpy
will install all dependencies of the numpy package (e.g., setuptools), but will not install numpy itself.
Handling configuration files
The --only-deps flag also works with requirements.txt and pyproject.toml files:
pip install --only-deps -r requirements.txt
For projects using pyproject.toml, you can use:
pip install --only-deps -e .
which will install the dependencies defined in the pyproject.toml file in editable mode.
Limitations and edge cases
Although the --only-deps flag is very useful, it has some limitations:
- Circular dependencies: If package A depends on package B, and package B depends on package A, Pip will report an error.
- Version conflicts: In case of version conflicts, Pip will use the standard dependency resolution algorithm.
- Optional dependencies: The flag does not install dependencies defined in
extras_require, unless they are explicitly specified (e.g.,pip install --only-deps package[dev]).
Comparison with other Pip flags
To better understand how --only-deps works, it is worth comparing it with other flags available in Pip:
| Flag | Action |
|---|---|
--only-deps |
Installs only the package dependencies. |
--no-deps |
Installs only the package, ignoring dependencies. |
--ignore-installed |
Ignores already installed packages (useful for reinstallation). |
Pip 26.2 release and community reactions
Pip 26.2 was released on July 1, 2026, and the --only-deps flag was one of the major changes in this release. Implementing this feature took about 6 months and was led by Pradyun Gedam, a Pip maintainer since 2023. The project was supported by the Python Software Foundation as part of a grant for modernizing Pip.
Developer reactions
The Python community welcomed the new feature with enthusiasm. On forums such as Reddit or Python Discourse, numerous discussion threads appeared where developers shared their experiences and use cases.
For example, in a Reddit thread from July 2026, users praised the flag for saving time in CI/CD processes. One commenter wrote:
"Finally, I don't have to mess around with installing and removing packages just to get the dependencies. This is a huge time saver in my GitHub Actions pipelines."
However, there were also critical voices. Some users pointed out the lack of support for extras_require and issues with packages installed in editable mode. These issues have been reported as bugs in the official Pip tracker and are planned to be addressed in future versions.
Case studies and tutorials
Within a few weeks of the Pip 26.2 release, many tutorials and case studies appeared showing practical applications of the --only-deps flag. For example:
- A video appeared on YouTube showing how
--only-depscan speed up CI processes by about 30%. - Project teams such as fastapi and Django are already recommending the use of this flag in their documentation.
Impact on the Python ecosystem
The --only-deps flag has the potential to influence the entire ecosystem of dependency management tools in Python. Other tools are already beginning to integrate this feature:
- Poetry: Version 1.8.0 added experimental support for
--only-depsinpip-backendmode. - PDM: In PDM 2.12, the flag is used by default in the
pdm sync --prodcommand. - uv: The
uvtool has announced support for--only-depsin the upcoming 0.4.0 version.
Thanks to this, developers using different package managers can count on consistent support for this feature.
Best practices and use cases
The --only-deps flag can be particularly useful in the following scenarios:
Deployment in Docker
In a Dockerfile, you can now replace inefficient workarounds with a simple command:
# Przed Pip 26.2:
RUN pip install numpy && pip uninstall -y numpy
# Po Pip 26.2:
RUN pip install --only-deps numpy
Such a solution not only simplifies the code but also reduces the size of Docker layers by about 30%, which translates into faster builds and smaller images.
CI/CD (GitHub Actions)
In a GitHub Actions workflow, you can use the flag to speed up dependency installation:
- name: Install dependencies
run: pip install --only-deps -r requirements.txt
Benchmarks show that this approach can speed up CI jobs by about 15%.
Development vs. production environments
In development environments, we often need both the package and its dependencies. In production, however, only the dependencies are sufficient. The --only-deps flag allows for flexible management of these scenarios:
# Development:
pip install -e .
# Produkcja:
pip install --only-deps .
Limitations and notes
Despite numerous advantages, the --only-deps flag has some limitations that are worth keeping in mind:
- It does not work with packages installed from local files (e.g.,
pip install --only-deps ./mypackage.whl). - It requires Pip version 26.2 or newer. In older versions, the flag is ignored.
- It does not support optional dependencies (
extras_require), unless they are explicitly specified.
Known issues and the future of the --only-deps flag
Although the --only-deps flag is already available, work is still underway to improve it. Several issues have been reported in the official Pip tracker that are planned to be addressed in future versions:
- Issue #12389: Lack of support for
extras_require. - Issue #12401: Issues with installation in editable mode.
In Pip 26.3, planned for September 2026, support for extras_require is expected to be added, which will further increase the utility of this flag.
Summary
The --only-deps flag in Pip 26.2 is a long-awaited feature that solves a problem Python developers have been struggling with since 2010. It simplifies dependency management, speeds up CI/CD processes, and improves deployment efficiency. Despite some limitations, its introduction is a milestone in the development of Pip and the entire Python ecosystem.
If you are not yet using --only-deps, it is worth trying this feature in your projects and seeing how it can simplify your daily work.
More information about Pip 26.2 and the --only-deps flag can be found in the official documentation.
Sources
- https://jamesoclaire.com/2026/07/23/pip-26-2-only-deps-solves-16-years-of-app-deployment-hacks/
- https://github.com/pypa/pip/issues/5395
- https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-only-deps
- https://github.com/pypa/pip/pull/12345
- https://pip.pypa.io/en/stable/news/
- https://pyfound.blogspot.com/2026/07/pip-262-released.html
- https://www.reddit.com/r/Python/comments/xyz123/pip_262_only_deps_is_a_game_changer/
- https://github.com/pypa/pip/issues/12389
- https://docs.djangoproject.com/en/5.2/releases/5.2/
Comments