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

FR: Dynamic dependencies and optional dependencies #6422

Open
chrisrodrigue opened this issue Aug 22, 2024 · 1 comment
Open

FR: Dynamic dependencies and optional dependencies #6422

chrisrodrigue opened this issue Aug 22, 2024 · 1 comment

Comments

@chrisrodrigue
Copy link

chrisrodrigue commented Aug 22, 2024

Greetings uv team and congratulations on the release of 0.3!

I would like to present a rather vexing issue when it comes to project management.

As you may know, Anaconda has a significant presence in the realm of data science and scientific python usage. Currently, conda lags behind current PEP standards and does not support reading dependencies from pyproject.toml. It is typically used by orgs that deploy to airgapped environments since it comes bundled with Anaconda alongside a number of other popular packages such as pytorch.

These orgs vastly prefer to use modern packaging tools like uv in non-airgapped development environments, but this requires carefully maintaining project dependencies for compatibility with Anaconda/conda and avoidance of adding new runtime dependencies to the airgapped deployment environments.

One such solution to avoid duplication of dependencies between conda environment.yml files and those defined pyproject.toml is by utilizing requirements.txt in conjunction with dynamic project.dependencies (as seen in Drphoton’s answer here).

This allows users to have a project layout like so:

Project/
|-- src/
|   |-- __init__.py
|   |-- main.py
|
|-- pyproject.toml
|-- requirements.txt
|-- requirements-dev.txt

and a pyproject.toml with dynamic dependency fields:

[project]
name = "myproject"
# ...
dynamic = ["dependencies", "optional-dependencies"]

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

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

This setup allows users to run conda in airgapped environments like so:

conda create -n ENVNAME "python>=3.12" --file requirements.txt

while also letting them use uv pip in non-airgapped environments:

uv pip install -e .

This approach places a dependency on setuptools to read the dynamic dependencies, and is admittedly just a stop-gap solution to make up for conda’s lack of pyproject.toml support.

It would be nice if uv supported reading dynamic dependencies such that commands like uv sync would work if dependencies were defined in other files (such as split being across numerous requirements.txt).

(Eagerly waiting to see if Astral ever offers a product similar to Anaconda that provides a number of high quality MIT-licensed python packages/python interpreter/uv/ruff/etc).

@chrisrodrigue chrisrodrigue changed the title Feat: Dynamic dependencies and optional dependencies FR: Dynamic dependencies and optional dependencies Aug 22, 2024
@adamtheturtle
Copy link
Contributor

At least better for me than the current situation is having a warning / error when trying to use dynamic dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants