Closed ketozhang closed 2 weeks ago
If you use the pip
API, there's no impact. But you can't use uv sync
or uv lock
without uv.lock
. (Note that uv.lock
is not the same as PEP 751, which is not yet finished or accepted.)
Yeah, I'd recommend just using uv pip sync
instead of the top-level interface.
@charliermarsh Your response speed amazing ❤️! @zanieb (and you! I didn't get a chance to type this)
Doesn't the lock file affect uv run
(docs)?
I think uv run python
is something I started to use in place of .venv/bin/python
(or activate -> python).
Gotcha, will try to move remember to always use uv pip
.
uv run
will always create and use a lockfile in a project, yeah. I presume you have a pyproject.toml
?
Actually you can use uv run --no-project
and we will ignore any pyproject.toml
files
I presume you have a pyproject.toml?
Yes.
For now, I'm thinking about the project workflow:
$ cd /path/to/project
$ uv venv # Optional and redundant to next command (old habit)
$ uv pip sync dev-requirements.txt # OR uv pip install -r ...
# Run project environment's python == .venv/bin/python
$ uv run python
Yep! Makes sense. If you do uv run --no-project python
we will read the .venv
we just will ignore the pyproject.toml
(and uv.lock
)
❯ uv init
Initialized project `example`
❯ uv venv
Using Python 3.11.7
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
❯ uv pip install httpx
Resolved 7 packages in 201ms
Installed 7 packages in 19ms
+ anyio==4.4.0
+ certifi==2024.7.4
+ h11==0.14.0
+ httpcore==1.0.5
+ httpx==0.27.0
+ idna==3.7
+ sniffio==1.3.1
❯ uv run --no-project python -c "import httpx"
❯ tree .
.
├── README.md
├── pyproject.toml
└── src
└── example
└── __init__.py
(Note we don't create a uv.lock
)
You can also just do
[tool.uv]
managed = false
if you never want to use uv sync
and uv lock
managed = false
Oh, same as rye. That solves it as a quasi-feature flag. Thank you!
Adding documentation for this in https://github.com/astral-sh/uv/pull/6465
I'm not ready to use the new lock files in my dev environment. I need to heavily rely on pip-compile style lock files (
uv sync requirements.in
).Is there any way to not be affected by the
uv.lock
(not sure what the existence of that file implies for other uv commands).