This commit is contained in:
konsti 2025-07-05 01:13:11 +03:30 committed by GitHub
commit 0faaf17819
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 81 additions and 26 deletions

View file

@ -225,6 +225,7 @@ jobs:
cat <<EOF > Dockerfile
FROM ${BASE_IMAGE}
COPY --from=${{ env.UV_GHCR_IMAGE }}:latest /uv /uvx /usr/local/bin/
ENV UV_TOOL_BIN_DIR="/usr/local/bin"
ENTRYPOINT []
CMD ["/usr/local/bin/uv"]
EOF

1
Cargo.lock generated
View file

@ -4665,7 +4665,6 @@ dependencies = [
"uv-client",
"uv-configuration",
"uv-console",
"uv-dirs",
"uv-dispatch",
"uv-distribution",
"uv-distribution-filename",

View file

@ -33,7 +33,7 @@ pub enum TargetTriple {
#[serde(rename = "i686-pc-windows-msvc")]
I686PcWindowsMsvc,
/// An x86 Linux target. Equivalent to `x86_64-manylinux_2_17`.
/// An x86 Linux target. Equivalent to `x86_64-manylinux_2_28`.
#[cfg_attr(feature = "clap", value(name = "x86_64-unknown-linux-gnu"))]
#[serde(rename = "x86_64-unknown-linux-gnu")]
#[serde(alias = "x8664-unknown-linux-gnu")]
@ -56,7 +56,7 @@ pub enum TargetTriple {
#[serde(alias = "x8664-apple-darwin")]
X8664AppleDarwin,
/// An ARM64 Linux target. Equivalent to `aarch64-manylinux_2_17`.
/// An ARM64 Linux target. Equivalent to `aarch64-manylinux_2_28`.
#[cfg_attr(feature = "clap", value(name = "aarch64-unknown-linux-gnu"))]
#[serde(rename = "aarch64-unknown-linux-gnu")]
Aarch64UnknownLinuxGnu,
@ -240,7 +240,7 @@ impl TargetTriple {
Self::Linux | Self::X8664UnknownLinuxGnu => Platform::new(
Os::Manylinux {
major: 2,
minor: 17,
minor: 28,
},
Arch::X86_64,
),
@ -262,7 +262,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => Platform::new(
Os::Manylinux {
major: 2,
minor: 17,
minor: 28,
},
Arch::Aarch64,
),

View file

@ -217,6 +217,19 @@ impl PythonVersionFile {
}
}
/// Create a new representation of a global Python version file.
///
/// Returns [`None`] if the user configuration directory cannot be determined.
pub fn global() -> Option<Self> {
let path = user_uv_config_dir()?.join(PYTHON_VERSION_FILENAME);
Some(Self::new(path))
}
/// Returns `true` if the version file is a global version file.
pub fn is_global(&self) -> bool {
PythonVersionFile::global().is_some_and(|global| self.path() == global.path())
}
/// Return the first request declared in the file, if any.
pub fn version(&self) -> Option<&PythonRequest> {
self.versions.first()
@ -260,6 +273,9 @@ impl PythonVersionFile {
/// Update the version file on the file system.
pub async fn write(&self) -> Result<(), std::io::Error> {
debug!("Writing Python versions to `{}`", self.path.display());
if let Some(parent) = self.path.parent() {
fs_err::tokio::create_dir_all(parent).await?;
}
fs::tokio::write(
&self.path,
self.versions

View file

@ -24,7 +24,6 @@ uv-cli = { workspace = true }
uv-client = { workspace = true }
uv-configuration = { workspace = true }
uv-console = { workspace = true }
uv-dirs = { workspace = true }
uv-dispatch = { workspace = true }
uv-distribution = { workspace = true }
uv-distribution-filename = { workspace = true }

View file

@ -9,7 +9,6 @@ use tracing::debug;
use uv_cache::Cache;
use uv_client::BaseClientBuilder;
use uv_configuration::{DependencyGroupsWithDefaults, PreviewMode};
use uv_dirs::user_uv_config_dir;
use uv_fs::Simplified;
use uv_python::{
EnvironmentPreference, PYTHON_VERSION_FILENAME, PythonDownloads, PythonInstallation,
@ -72,10 +71,20 @@ pub(crate) async fn pin(
}
bail!("No Python version file found");
};
if !global && file.is_global() {
bail!("No Python version file found; use `--rm --global` to remove the global pin");
}
fs_err::tokio::remove_file(file.path()).await?;
writeln!(
printer.stdout(),
"Removed Python version file at `{}`",
"Removed {} at `{}`",
if global {
"global Python pin"
} else {
"Python version file"
},
file.path().user_display()
)?;
return Ok(ExitStatus::Success);
@ -192,12 +201,11 @@ pub(crate) async fn pin(
let existing = version_file.ok().flatten();
// TODO(zanieb): Allow updating the discovered version file with an `--update` flag.
let new = if global {
let Some(config_dir) = user_uv_config_dir() else {
return Err(anyhow::anyhow!("No user-level config directory found."));
let Some(new) = PythonVersionFile::global() else {
// TODO(zanieb): We should find a nice way to surface that as an error
bail!("Failed to determine directory for global Python pin");
};
fs_err::tokio::create_dir_all(&config_dir).await?;
PythonVersionFile::new(config_dir.join(PYTHON_VERSION_FILENAME))
.with_versions(vec![request])
new.with_versions(vec![request])
} else {
PythonVersionFile::new(project_dir.join(PYTHON_VERSION_FILENAME))
.with_versions(vec![request])

View file

@ -14728,7 +14728,7 @@ fn invalid_platform() -> Result<()> {
uv_snapshot!(context
.pip_compile()
.arg("--python-platform")
.arg("linux")
.arg("x86_64-manylinux_2_17")
.arg("requirements.in"), @r"
success: false
exit_code: 1

View file

@ -855,7 +855,7 @@ fn python_pin_rm() {
error: No Python version file found
");
// Remove the local pin
// Create and remove a local pin
context.python_pin().arg("3.12").assert().success();
uv_snapshot!(context.filters(), context.python_pin().arg("--rm"), @r"
success: true
@ -892,12 +892,41 @@ fn python_pin_rm() {
.arg("--global")
.assert()
.success();
uv_snapshot!(context.filters(), context.python_pin().arg("--rm").arg("--global"), @r"
success: true
exit_code: 0
----- stdout -----
Removed Python version file at `[UV_USER_CONFIG_DIR]/.python-version`
Removed global Python pin at `[UV_USER_CONFIG_DIR]/.python-version`
----- stderr -----
");
// Add the global pin again
context
.python_pin()
.arg("3.12")
.arg("--global")
.assert()
.success();
// Remove the local pin
uv_snapshot!(context.filters(), context.python_pin().arg("--rm"), @r"
success: true
exit_code: 0
----- stdout -----
Removed Python version file at `.python-version`
----- stderr -----
");
// The global pin should not be removed without `--global`
uv_snapshot!(context.filters(), context.python_pin().arg("--rm"), @r"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: No Python version file found; use `--rm --global` to remove the global pin
");
}

View file

@ -77,6 +77,9 @@ As with the distroless image, each derived image is published with uv version ta
`ghcr.io/astral-sh/uv:{major}.{minor}.{patch}-{base}` and
`ghcr.io/astral-sh/uv:{major}.{minor}-{base}`, e.g., `ghcr.io/astral-sh/uv:0.7.19-alpine`.
In addition, starting with `0.8` each derived image also sets `UV_TOOL_BIN_DIR` to `/usr/local/bin`
to allow `uv tool install` to work as expected with the default user.
For more details, see the [GitHub Container](https://github.com/astral-sh/uv/pkgs/container/uv)
page.

View file

@ -1678,10 +1678,10 @@ interpreter. Use <code>--universal</code> to display the tree for all platforms,
<li><code>macos</code>: An alias for <code>aarch64-apple-darwin</code>, the default target for macOS</li>
<li><code>x86_64-pc-windows-msvc</code>: A 64-bit x86 Windows target</li>
<li><code>i686-pc-windows-msvc</code>: A 32-bit x86 Windows target</li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_17</code></li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_28</code></li>
<li><code>aarch64-apple-darwin</code>: An ARM-based macOS target, as seen on Apple Silicon devices</li>
<li><code>x86_64-apple-darwin</code>: An x86 macOS target</li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_17</code></li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_28</code></li>
<li><code>aarch64-unknown-linux-musl</code>: An ARM64 Linux target</li>
<li><code>x86_64-unknown-linux-musl</code>: An <code>x86_64</code> Linux target</li>
<li><code>x86_64-manylinux2014</code>: An <code>x86_64</code> target for the <code>manylinux2014</code> platform. Equivalent to <code>x86_64-manylinux_2_17</code></li>
@ -3363,10 +3363,10 @@ by <code>--python-version</code>.</p>
<li><code>macos</code>: An alias for <code>aarch64-apple-darwin</code>, the default target for macOS</li>
<li><code>x86_64-pc-windows-msvc</code>: A 64-bit x86 Windows target</li>
<li><code>i686-pc-windows-msvc</code>: A 32-bit x86 Windows target</li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_17</code></li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_28</code></li>
<li><code>aarch64-apple-darwin</code>: An ARM-based macOS target, as seen on Apple Silicon devices</li>
<li><code>x86_64-apple-darwin</code>: An x86 macOS target</li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_17</code></li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_28</code></li>
<li><code>aarch64-unknown-linux-musl</code>: An ARM64 Linux target</li>
<li><code>x86_64-unknown-linux-musl</code>: An <code>x86_64</code> Linux target</li>
<li><code>x86_64-manylinux2014</code>: An <code>x86_64</code> target for the <code>manylinux2014</code> platform. Equivalent to <code>x86_64-manylinux_2_17</code></li>
@ -3620,10 +3620,10 @@ be used with caution, as it can modify the system Python installation.</p>
<li><code>macos</code>: An alias for <code>aarch64-apple-darwin</code>, the default target for macOS</li>
<li><code>x86_64-pc-windows-msvc</code>: A 64-bit x86 Windows target</li>
<li><code>i686-pc-windows-msvc</code>: A 32-bit x86 Windows target</li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_17</code></li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_28</code></li>
<li><code>aarch64-apple-darwin</code>: An ARM-based macOS target, as seen on Apple Silicon devices</li>
<li><code>x86_64-apple-darwin</code>: An x86 macOS target</li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_17</code></li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_28</code></li>
<li><code>aarch64-unknown-linux-musl</code>: An ARM64 Linux target</li>
<li><code>x86_64-unknown-linux-musl</code>: An <code>x86_64</code> Linux target</li>
<li><code>x86_64-manylinux2014</code>: An <code>x86_64</code> target for the <code>manylinux2014</code> platform. Equivalent to <code>x86_64-manylinux_2_17</code></li>
@ -3902,10 +3902,10 @@ should be used with caution, as it can modify the system Python installation.</p
<li><code>macos</code>: An alias for <code>aarch64-apple-darwin</code>, the default target for macOS</li>
<li><code>x86_64-pc-windows-msvc</code>: A 64-bit x86 Windows target</li>
<li><code>i686-pc-windows-msvc</code>: A 32-bit x86 Windows target</li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_17</code></li>
<li><code>x86_64-unknown-linux-gnu</code>: An x86 Linux target. Equivalent to <code>x86_64-manylinux_2_28</code></li>
<li><code>aarch64-apple-darwin</code>: An ARM-based macOS target, as seen on Apple Silicon devices</li>
<li><code>x86_64-apple-darwin</code>: An x86 macOS target</li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_17</code></li>
<li><code>aarch64-unknown-linux-gnu</code>: An ARM64 Linux target. Equivalent to <code>aarch64-manylinux_2_28</code></li>
<li><code>aarch64-unknown-linux-musl</code>: An ARM64 Linux target</li>
<li><code>x86_64-unknown-linux-musl</code>: An <code>x86_64</code> Linux target</li>
<li><code>x86_64-manylinux2014</code>: An <code>x86_64</code> target for the <code>manylinux2014</code> platform. Equivalent to <code>x86_64-manylinux_2_17</code></li>

4
uv.schema.json generated
View file

@ -2062,7 +2062,7 @@
"const": "i686-pc-windows-msvc"
},
{
"description": "An x86 Linux target. Equivalent to `x86_64-manylinux_2_17`.",
"description": "An x86 Linux target. Equivalent to `x86_64-manylinux_2_28`.",
"type": "string",
"const": "x86_64-unknown-linux-gnu"
},
@ -2077,7 +2077,7 @@
"const": "x86_64-apple-darwin"
},
{
"description": "An ARM64 Linux target. Equivalent to `aarch64-manylinux_2_17`.",
"description": "An ARM64 Linux target. Equivalent to `aarch64-manylinux_2_28`.",
"type": "string",
"const": "aarch64-unknown-linux-gnu"
},