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

Provide option to install only dev dependencies #7255

Closed
paveldedik opened this issue Sep 10, 2024 · 1 comment · Fixed by #7367
Closed

Provide option to install only dev dependencies #7255

paveldedik opened this issue Sep 10, 2024 · 1 comment · Fixed by #7367
Assignees
Labels
enhancement New feature or improvement to existing functionality

Comments

@paveldedik
Copy link

Hi,

Thank you for creating this amazing tool! We are in the process of switching from pip-tools to uv and have encountered a situation we’re unsure how to resolve.

Use Case

We have a Python project with the following setup:

  1. We install dependencies (excluding dev dependencies) in Docker.

  2. We use Docker Compose to mount the site-packages directory to the host machine.

  3. On the host machine, we create a virtual environment (venv).

  4. Dev dependencies are installed only in this virtual environment.

  5. We link the production dependencies (mounted via Docker) to the venv using the following script:

    source .venv/bin/activate
    VENV_SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
    echo "$(realpath var/site-packages/)" > "$VENV_SITE_PACKAGES/core.pth"
    echo "$(realpath app/libs/)" > "$VENV_SITE_PACKAGES/libs.pth"

This setup works well with pip and pip-compile, allowing us to maintain a development environment close to production, with full IDE compatibility.

Challenge with uv

We’d like to transition to pyproject.toml + uv.lock for dependency management.

Steps 1-3 remain the same when using uv. However, we encounter difficulties with step 4, where we need to install only dev dependencies into the virtual environment.

The issue is that:

  • uv sync installs both production and dev dependencies.
  • uv pip install doesn't respect the pinned dependencies from the lock file.

We’ve considered using the following workaround:

  • uv export --format requirements-txt followed by uv pip install <exported-requirements>, but there doesn’t seem to be an option to export only dev dependencies as well (this could be resolved somehow by combination of uv export ... - uv export --no-dev ... outputs, but that is very far from a neat solution.

Conclusion

There may be a better way to handle this setup with uv where project dependencies are mounted over Docker (feel free to suggest them), but at the moment we are missing a way to install only dev dependencies without affecting the linked site-packages.

The obvious solution is to add an option something like uv sync --only-dev + also uv export --only-dev ....

Any guidance or suggestions would be greatly appreciated!

@charliermarsh
Copy link
Member

Agree, I do want to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants