uv
uv copied to clipboard
Bug (?): `PACKAGE_ROOT` not working one level up
I have a setuptools.build_meta backend monorepo with a pyproject.toml package named packagename in a subfolder. I specify its dependency in a requirements.txt at the repo root: package-name @ file://${PROJECT_ROOT}/packagename
In /Users/user/code/repo-root, running uv pip install --no-cache . works fine.
Moving up one directory to /Users/user/code and running uv pip install --no-cache ./repo fails:
error: Distribution not found at: file:///Users/user/code/packagename
Can we somehow know PROJECT_ROOT should be ./repo, instead of ./ in this case?
I am using uv 0.1.38 (0b23caa18 2024-04-24)
Hmm, right now PROJECT_ROOT is just the current working directory.
Slightly tempted to set it to the directory of the containing file.
Lol give in to your temptations 😈 🔥 🚀 🦾 😆
Is that "breaking" ?
I'd consider it breaking.
Would we support $PWD too or whatever?
I believe we already do.
We support any env var, and then PROJECT_ROOT is special on top of those.
Using the directory that contains the file definitely seems right for pyproject.toml. I could see it being less convenient for requirements.txt in some rare cases?
Yeah the latter seems more problematic, e.g. requirements/dev.txt — but it seems quite correct for pyproject.toml.
I wonder if we should scan for git boundaries for requirements.txt...
Yeah the latter seems more problematic, e.g. requirements/dev.txt — but it seems quite correct for pyproject.toml.
Yeah. Is it even that bad though? It just means you need to make the path relative to the file rather than the root directory. But it would still work consistently regardless of where you invoked uv from, unlike the current implementation.
I'm curious if anyone else will weigh in, but yeah having it work consistently seems like an improvement.
Maybe PACKAGE_ROOT can have a fallback (or a configuration option --package-root-is-not-cwd) to maintain compatibility:
- Looks in target directory (in this case,
./repo) - Falls back on current working directory
That being said, imo the most straightforward/intuitive route is to support two environment variables:
# Uses input uv command to resolve to ./repo/foo
file://${PROJECT_ROOT}/foo
# Always resolves to ./foo
file://${CURRENT_DIRECTORY}/foo
For ${CURRENT_DIRECTORY} you can likely already do ${PWD}.
We'll ship this in v0.3.0.