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

Use the lockfile as constraints when doing uv run --with #7416

Closed
delfick opened this issue Sep 16, 2024 · 5 comments · Fixed by #7627
Closed

Use the lockfile as constraints when doing uv run --with #7416

delfick opened this issue Sep 16, 2024 · 5 comments · Fixed by #7627
Assignees
Labels
wish Not on the immediate roadmap

Comments

@delfick
Copy link

delfick commented Sep 16, 2024

Hello,

I'm using uv 0.4.10

I'm trying to make my project use uv project semantics and to get around uv not having support for conflicting requirements I have scripts to run my tests with either uv run --with mypy==1.4.0 django-stubs==4.2.3 or uv run --with mypy==1.11.2 --with django-stubs==5.0.2 and that works.

However, it seems that it's not using the lock file as a constraints and so it's not respecting that I have a specific version of django in my project.

Is it possible to make it so that doing a uv run using --with uses the lock file as a constraints?

@juftin
Copy link

juftin commented Sep 21, 2024

Agreed - I came looking for a very similar issue to this. In my case I'd like to run Python CLIs in my environment without installing other tools.

For example, in a linting CI/CD job I'd like to just run ruff which is one of my dev dependencies, without installing everything else:

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
dependencies = [
  "requests"
]
name = "example"
readme = "README.md"
requires-python = ">=3.11,<4"
version = "0.1.0"

[tool.uv]
dev-dependencies = [
  "ruff>=0.6.5",
  "pytest>=8.3.3"
]

In this case I would want to run something like this and have it respect my lockfile:

uv run --with ruff ruff format .

Even better (for my use case), it would be nice to install ruff into my virtual environment without having to install any of my other dev dependencies:

uv run --only-sync ruff ruff format .

@charliermarsh
Copy link
Member

@juftin -- Are you looking for uv run --only-dev ruff format .?

@charliermarsh charliermarsh added the wish Not on the immediate roadmap label Sep 21, 2024
@juftin
Copy link

juftin commented Sep 21, 2024

Kind of, I'm using uv run --only-dev ruff format . today but it syncs all of my dev dependencies when I really only need ruff for the CI job.

Maybe this is a niche need, but I'd like to be able to install/run just ruff without trying to sync the other dev dependencies (that was my idea with the --only-sync flag in the above example)

If uv run --with ruff --no-sync ruff format . respected my lock file that would also work.

@charliermarsh
Copy link
Member

Yeah I think we should respect the lockfile for the —with dependencies. At the very least we should prefer versions that are in the lockfile.

@delfick
Copy link
Author

delfick commented Sep 23, 2024

awesome, thanks for the fix!

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

Successfully merging a pull request may close this issue.

3 participants