Commit graph

16 commits

Author SHA1 Message Date
Zanie Blue
6cc2202799 Ignore arbitrary Python requests in version files (#12909)
Closes https://github.com/astral-sh/uv/issues/12605
2025-04-29 16:37:00 -05:00
Zanie Blue
41ac6649d7
Add debug logs for version file search (#12951)
Co-authored-by: John Mumm <jtfmumm@gmail.com>
2025-04-18 16:31:52 +00:00
John Mumm
797f1fbac0
Add support for global uv python pin (#12115)
These changes add support for

```
uv python pin 3.12 --global 
```

This adds the specified version to a `.python-version` file in the
user-level config directory. uv will now use the user-level version as a
fallback if no version is found in the project directory or its
ancestors.

Closes #4972
2025-03-13 13:48:37 +01:00
Zanie Blue
8ef5949294 Discover and respect .python-version files in parent directories (#6370)
Uses #6369 for test coverage.

Updates version file discovery to search up into parent directories.
Also refactors Python request determination to avoid duplicating the
user request / version file / workspace lookup logic in every command
(this supersedes the work started in
https://github.com/astral-sh/uv/pull/6372).

There is a bit of remaining work here, mostly around documentation.
There are some edge-cases where we don't use the refactored request
utility, like `uv build` — I'm not sure how I'm going to handle that yet
as it needs a separate root directory.
2024-11-07 14:29:54 -06:00
Charlie Marsh
fe8880bf3c
Surface dedicated errors for .python-version conflict with requires-python (#7218)
## Summary

I got confused because I had a `.python-version` file that conflicted
with my `requires-python`.
2024-09-09 17:12:53 -04:00
Charlie Marsh
8a0e1fde33
Write trailing newline to .python-version files (#7140)
## Summary

Closes https://github.com/astral-sh/uv/issues/7135.
2024-09-06 18:03:52 -04:00
Charlie Marsh
50d7b9c38a
Pin .python-version in uv init (#6869)
## Summary

I'm not convinced that the behavior is correct as-implemented. When the
user passes a `--python >=3.8` or we discover a `requires-python` from
the workspace, we're currently writing that request out to
`.python-version`. I would probably rather that we write the resolved
patch version?

Closes https://github.com/astral-sh/uv/issues/6821.
2024-09-03 19:43:50 -04:00
Zanie Blue
7d90c29552
Fix priority for .python-versions files in uv python install (#6382)
In https://github.com/astral-sh/uv/pull/6359, I accidentally made `uv
python install` prefer `.python-version` files over `.python-versions`
files -.-, kind of niche but it's a regression.
2024-08-21 22:17:14 +00:00
Zanie Blue
2fbe12ee1b
Refactor .python-version discovery (#6359)
In preparation for more comprehensive discovery
2024-08-21 16:41:20 -05:00
Charlie Marsh
37388f0987
Make directory a required argument (#5573) 2024-07-29 20:47:34 +00:00
bluss
e46c24d3cf
Implement uv run --directory (#5566)
## Summary

uv run --directory <path> means that one doesn't have to change to a
project's directory to run programs from it. It makes it possible to use
projects as if they are tool installations.

To support this, first the code reading .python-version was updated so
that
it can read such markers outside the current directory. Note the minor
change this causes (if I'm right), described in the commit.

## Test Plan

One test has been added.

## --directory

Not sure what the name of the argument should be, but it's following uv
sync's directory for now.

Other alternatives could be "--project". Uv run and uv tool run should
probably find common agreement on this (relevant for project-locked
tools).

I've implemented this same change in Rye, some time ago, and then we
went
with --pyproject `<`path to pyproject.toml file`>`. I think using
pyproject.toml file path and not directory was probably a mistake, an
overgeneralization one doesn't need.
2024-07-29 15:53:10 -04:00
Jo
96b24345eb
Allow comments in .python-version[s] (#5350)
## Summary

Do the same thing as https://github.com/astral-sh/rye/pull/1038.
2024-07-23 14:56:50 -05:00
Charlie Marsh
7762d78281
Add color to python pin CLI (#5215)
## Summary

![Screenshot 2024-07-19 at 9 03
10 AM](https://github.com/user-attachments/assets/5668bd23-3f09-4964-bc09-9f3788f5a841)
2024-07-19 13:19:28 -04:00
Charlie Marsh
2169902bd9
Avoid TOCTOU errors in .python-version reads (#5223)
## Summary

Not a big deal, but better to try the operation and handle the failure
case than to check if the file exists and _then_ read it.
2024-07-19 15:08:20 +00:00
Zanie Blue
a4044be95b
Respect --isolated in uv python install (#4938)
We ignore Python version files when `--isolated` is used, logging that
we skipped them if they exist.
2024-07-10 15:36:25 +00:00
Zanie Blue
dd7da6af5f
Change "toolchain" to "python" (#4735)
Whew this is a lot.

The user-facing changes are:

- `uv toolchain` to `uv python` e.g. `uv python find`, `uv python
install`, ...
- `UV_TOOLCHAIN_DIR` to` UV_PYTHON_INSTALL_DIR`
- `<UV_STATE_DIR>/toolchains` to `<UV_STATE_DIR>/python` (with
[automatic
migration](https://github.com/astral-sh/uv/pull/4735/files#r1663029330))
- User-facing messages no longer refer to toolchains, instead using
"Python", "Python versions" or "Python installations"

The internal changes are:

- `uv-toolchain` crate to `uv-python`
- `Toolchain` no longer referenced in type names
- Dropped unused `SystemPython` type (previously replaced)
- Clarified the type names for "managed Python installations"
- (more little things)
2024-07-03 07:44:29 -05:00
Renamed from crates/uv-toolchain/src/version_files.rs (Browse further)