Introduction: The 16-Year Itch in Python Dependency Management
For over a decade and a half, Python developers have grappled with a deceptively simple problem: how to install dependencies for projects that aren’t meant to be packaged. Think application backends, REST APIs, or standalone scripts—projects where the code itself isn’t distributed as a Python package, but still relies on third-party libraries. The core issue? Pip, Python’s package installer, was designed to install both the package and its dependencies simultaneously. For non-package projects, this forced developers into a corner: either install the dependencies manually (error-prone and tedious) or hack around pip’s behavior with workarounds that ranged from fragile to outright dangerous.
The Mechanical Breakdown of the Problem
Here’s the causal chain: When you run pip install . in a project directory, pip reads the pyproject.toml file, identifies the project as a package, and installs both the package and its dependencies. For non-package projects, this behavior is mechanically incompatible with the developer’s intent. The internal process fails because pip lacks a mechanism to distinguish between "install the package" and "install only what the package depends on." The observable effect? Developers resort to workarounds like:
-
Manually copying dependencies into a
lib/folder, which breaks version consistency. - Using
pip install -r requirements.txt, which bypassespyproject.tomlmetadata and ignores dependency resolution logic. - Creating a dummy package just to install dependencies, adding unnecessary complexity.
Each workaround introduces friction points: version conflicts, missing transitive dependencies, or deployment inconsistencies. The risk? Projects become harder to maintain, deploy, and scale.
The --only-deps Flag: A Surgical Fix
Enter pip 26.2’s --only-deps flag, slated for release at the end of July. This feature decouples dependency installation from package installation by directly parsing the pyproject.toml file and resolving dependencies without touching the project itself. Mechanically, it bypasses the package installation step, executing only the dependency resolution and installation pipeline. The impact? Workarounds become obsolete. Developers can now run pip install --only-deps . and achieve the same result as their hacks—but with pip’s full dependency resolution logic intact.
Edge-Case Analysis: Where --only-deps Shines (and Where It Doesn’t)
This solution is optimal for projects where the code is not distributed as a package but requires a consistent dependency environment. However, it’s not a silver bullet. If your project is intended to be installed as a package, using --only-deps would defeat pip’s purpose. The rule? If your project isn’t a package, use --only-deps; if it is, stick to standard pip install.
Professional Judgment: Why This Matters Now
The timing of this update is critical. As Python continues to dominate backend development, REST APIs, and scripting, the lack of a native solution for dependency management has become a systemic bottleneck. The --only-deps flag eliminates this bottleneck, reducing deployment complexity and developer frustration. It’s not just a feature—it’s a paradigm shift in how Python projects are managed. For the first time in 16 years, developers have a tool that directly addresses the root cause of the problem, not just its symptoms.
The Problem: 16 Years of Deployment Hacks
For over a decade and a half, Python developers have grappled with a deceptively simple problem: how to install dependencies for projects not intended to be distributed as packages. Think application backends, REST APIs, or standalone scripts—projects where the code itself isn’t meant to be installed via pip, but its dependencies absolutely are. This seemingly minor oversight in Python’s packaging ecosystem has spawned a labyrinth of workarounds, each more brittle than the last.
The Mechanical Failure: Pip’s Dual-Purpose Design
At the heart of the issue lies pip’s core behavior. When you run pip install ., it reads the project’s pyproject.toml, identifies it as a package, and installs both the package and its dependencies. Mechanically, this process is inseparable—pip lacks a mechanism to distinguish between “install this code” and “install only what this code needs.” For non-package projects, this design is fundamentally misaligned with developer intent, forcing them into contorted solutions.
Workarounds: A Catalog of Inefficiency
Developers have resorted to three primary hacks, each with its own failure mode:
- Manual Dependency Copying: Developers copy dependency files directly into their project. Impact: Breaks version consistency. Mechanism: Without a resolver, updates to transitive dependencies (dependencies of dependencies) go unnoticed, leading to silent incompatibilities.
-
pip install -r requirements.txt: Bypassespyproject.tomlentirely. Impact: Ignores metadata-driven dependency resolution. Mechanism: Loses access to features like PEP 517 builds or dynamic dependencies, increasing the risk of unresolved dependencies. - Dummy Packages: Creating a placeholder package solely to install dependencies. Impact: Adds unnecessary complexity. Mechanism: Introduces a redundant artifact that must be maintained, versioned, and distributed, even though the actual code isn’t a package.
Risk Formation: The Domino Effect of Workarounds
These methods don’t just add friction—they create systemic risks. For example, version conflicts emerge when manual copying fails to track upstream changes. Causal chain: Outdated dependencies → unresolved imports → runtime failures. Similarly, missing transitive dependencies occur when requirements.txt bypasses pyproject.toml’s resolver. Mechanism: The resolver’s logic is skipped, leaving gaps in the dependency tree that manifest as ModuleNotFoundError at runtime.
The Optimal Solution: Decoupling Dependencies with --only-deps
The --only-deps flag in pip 26.2 addresses the root cause by decoupling dependency installation from package installation. Mechanism: It parses pyproject.toml, activates the resolver, and installs dependencies without touching the project code. This preserves the full dependency resolution logic while eliminating the need for workarounds.
Rule for Solution Selection
If your project is not intended to be installed as a package (e.g., backends, scripts, APIs) → use pip install --only-deps .
Conditions where this fails: Projects that are meant to be distributed as packages (e.g., libraries) should continue using standard pip install.
Professional Judgment
The --only-deps flag is not just a convenience—it’s a correction of a 16-year-old design oversight. By addressing the mechanical incompatibility between pip’s behavior and developer intent, it eliminates systemic risks and reduces deployment complexity. Developers should adopt this flag immediately for non-package projects, retiring workarounds that have long inflated maintenance costs and deployment failures.
Pip 26.2’s --only-deps: A Game-Changer
For over a decade, Python developers have grappled with a deceptively simple problem: how to install dependencies for projects not intended to be distributed as packages. Think application backends, REST APIs, or scripts—projects where the code itself isn’t meant to be installed, but its dependencies are critical. Pip’s core behavior—installing both the package and its dependencies when running pip install .—has been mechanically incompatible with this use case. The result? A proliferation of workarounds that break version consistency, ignore metadata, or introduce unnecessary complexity.
The Mechanical Failure of Existing Workarounds
Let’s dissect why the common hacks fail at a mechanical level:
- Manual Dependency Copying: Developers often manually copy dependencies into a project directory. This breaks version consistency because transitive dependencies (dependencies of dependencies) aren’t tracked. When a transitive dependency updates, the developer remains unaware, leading to silent incompatibilities that surface as runtime errors.
-
pip install -r requirements.txt: This bypasses
pyproject.tomlentirely, ignoring PEP 517 builds and dynamic dependency resolution. The resolver logic in pip—which handles version conflicts and transitive dependencies—is disabled. This increases the risk of unresolved dependencies, causingModuleNotFoundErrorat runtime. - Dummy Packages: Creating a dummy package to install dependencies introduces redundant artifacts that require maintenance, versioning, and distribution. This expands the attack surface for version conflicts and increases deployment complexity.
How --only-deps Fixes the Root Cause
The --only-deps flag in pip 26.2 decouples dependency installation from package installation. Here’s the mechanical process:
-
Parsing
pyproject.toml: Pip reads the project’s metadata, including dependencies and build requirements. - Activating the Resolver: The dependency resolver—the same logic used in standard installs—is activated to handle version conflicts and transitive dependencies.
- Installing Dependencies: Dependencies are installed into the environment without touching the project code itself. This ensures version consistency and full resolution of the dependency tree.
The observable effect is a clean, consistent dependency environment for non-package projects, eliminating the risks and inefficiencies of manual workarounds.
Edge Cases and Limitations
While --only-deps is transformative, it’s not a universal solution. Here’s where it fails:
-
Projects Meant to Be Installed as Packages: If your project is intended for distribution (e.g., a library),
--only-depsis mechanically incompatible. Use standardpip install .instead. -
Missing
pyproject.toml: If your project lacks apyproject.tomlfile,--only-depswill fail. The flag relies on this file for metadata and dependency resolution.
Professional Judgment: When to Use --only-deps
Adopt the following rule:
If your project is not intended to be installed as a package (e.g., backends, scripts, APIs) and has a pyproject.toml → use pip install --only-deps ..
This rule eliminates systemic risks like version conflicts and missing transitive dependencies, reducing deployment complexity by orders of magnitude. For projects meant for distribution, stick to standard pip behavior.
Impact: Retiring 16 Years of Hacks
The introduction of --only-deps marks a paradigm shift in Python dependency management. By addressing the root cause of the problem—pip’s inability to distinguish between package and dependency installation—it renders manual workarounds obsolete. Developers can now deploy non-package projects with the same efficiency and consistency as packaged ones, reducing development time and frustration.
As pip 26.2 rolls out at the end of July, this feature isn’t just an incremental improvement—it’s a correction of a 16-year-old design oversight. For Python developers, it’s time to retire the hacks and embrace a simpler, more reliable workflow.
Real-World Scenarios: 6 Use Cases for --only-deps
The introduction of the --only-deps flag in pip 26.2 marks a pivotal shift in Python dependency management, particularly for non-package projects. Below, we dissect six practical scenarios where this feature eliminates historical pain points, backed by causal explanations and edge-case analyses.
1. Application Backends: Decoupling Dependencies from Deployment
Problem Mechanism: Traditional deployment of backend applications required either installing the entire project (including unintended code) or manually copying dependencies, breaking version consistency. Impact: Silent incompatibilities due to untracked transitive dependencies.
Solution: pip install --only-deps . parses pyproject.toml, activates pip’s resolver, and installs dependencies without touching application code. Observable Effect: Consistent dependency environments without redundant artifacts.
Rule: Use --only-deps for backends not distributed as packages. Failure Condition: Absence of pyproject.toml disables this mechanism.
2. REST APIs: Streamlining Dependency Resolution
Historical Risk: APIs often relied on requirements.txt, bypassing pyproject.toml metadata. Mechanism: Loss of PEP 517 builds and dynamic dependency resolution → unresolved imports at runtime.
Optimal Fix: --only-deps leverages pyproject.toml to resolve dependencies, including transitive ones. Effect: Eliminates ModuleNotFoundError risks inherent in manual methods.
Professional Judgment: For APIs, --only-deps is superior to requirements.txt due to its integration with pip’s resolver logic.
3. Python Scripts: Retiring Dummy Packages
Workaround Failure: Dummy packages introduced redundant artifacts, requiring versioning and maintenance. Causal Chain: Redundant package metadata → expanded attack surface for version conflicts.
Mechanism of --only-deps: Directly installs dependencies without creating a package. Impact: Scripts maintain clean dependency trees without unnecessary distribution overhead.
Rule: If the script is not a distributable package, use --only-deps to avoid dummy package complexity.
4. Multi-Environment Deployments: Consistent Dependency Locking
Risk Formation: Manual dependency copying across environments led to version drift. Internal Process: Untracked updates in one environment → silent failures in others.
Solution Effectiveness: --only-deps ensures all environments use the same pyproject.toml-defined dependencies. Observable Effect: Uniform dependency versions across staging, production, and local setups.
Edge Case: If pyproject.toml is modified post-deployment, re-run --only-deps to sync changes. Failure Condition: Ignoring updates leads to environment divergence.
5. Monorepos: Isolating Project Dependencies
Historical Challenge: Monorepos often mixed package and non-package projects, complicating dependency isolation. Mechanism: Shared pip install . commands → unintended package installations.
Optimal Strategy: Apply --only-deps to non-package projects within the monorepo. Effect: Prevents cross-contamination of dependencies between projects.
Rule: In monorepos, use --only-deps for non-package projects; reserve standard pip install for distributable packages.
6. CI/CD Pipelines: Reducing Deployment Artifacts
Inefficiency Mechanism: Pipelines often built dummy packages or copied dependencies, increasing build times. Impact: Longer CI/CD cycles and higher resource consumption.
Technical Insight: --only-deps eliminates the need for redundant artifacts by directly installing dependencies. Observable Effect: Faster pipeline execution and reduced storage overhead.
Professional Judgment: Integrate --only-deps into CI/CD scripts for non-package projects to optimize deployment efficiency. Failure Condition: Pipelines without pyproject.toml cannot utilize this feature.
Conclusion: A Paradigm Shift in Dependency Management
The --only-deps flag addresses a 16-year-old design oversight in pip, rendering manual workarounds obsolete. By decoupling dependency installation from package distribution, it eliminates systemic risks like version conflicts and missing transitive dependencies. Rule of Thumb: If your project is not intended for distribution (e.g., backends, scripts, APIs) and has a pyproject.toml, adopt --only-deps immediately. Limitation: This feature is incompatible with projects meant to be installed as packages—use standard pip install for those.
Conclusion and Future Implications
The introduction of the --only-deps flag in pip 26.2 marks a transformative shift in Python project deployment, addressing a 16-year-old pain point that has plagued developers working on non-package projects. By decoupling dependency installation from package installation, this feature eliminates the need for cumbersome workarounds like manual dependency copying, requirements.txt hacks, or dummy packages. The mechanical process is straightforward: --only-deps parses pyproject.toml, activates pip’s dependency resolver, and installs dependencies without touching the project code. This ensures version consistency, resolves transitive dependencies, and reduces deployment complexity—a stark contrast to the risks and inefficiencies of previous methods.
For developers working on application backends, REST APIs, scripts, and similar non-package projects, this feature is a game-changer. It directly addresses the root cause of systemic issues like version conflicts and missing dependencies, which previously led to runtime failures and increased maintenance overhead. The rule is clear: if your project is not meant for distribution, use --only-deps. However, this feature is not suitable for projects intended to be installed as packages, as it bypasses the package installation process entirely.
Looking ahead, the adoption of --only-deps is likely to become standard practice for non-package projects, rendering outdated workarounds obsolete. However, its success hinges on widespread awareness and proper usage. Developers must ensure their projects include a pyproject.toml file, as the feature relies on it for metadata and dependency resolution. Edge cases, such as monorepos or multi-environment deployments, will benefit from isolated dependency management, but re-running --only-deps after modifying pyproject.toml is critical to maintaining consistency.
Future developments in dependency management could build on this foundation, potentially introducing more granular control over dependency installation or tighter integration with CI/CD pipelines. For now, --only-deps is a monumental step forward, simplifying workflows and reducing errors. Developers should adopt it immediately for non-package projects, retiring inefficient hacks and embracing a more streamlined approach to Python project deployment.
Key Takeaways
- Optimal Solution: Use --only-deps for non-package projects to ensure consistent dependency resolution without redundant artifacts.
- Rule of Thumb: If your project lacks a distribution intent and has a pyproject.toml, --only-deps is the correct choice.
- Edge Case: Re-run --only-deps after modifying pyproject.toml to maintain dependency consistency across environments.
- Avoid: Manual workarounds like requirements.txt or dummy packages, as they introduce version conflicts and missing dependencies.
With --only-deps, Python developers finally have a native, efficient solution to a decades-old problem. The future of dependency management looks brighter, and the community’s adoption of this feature will be a testament to its impact.

Top comments (0)