mirror of https://github.com/astral-sh/uv
Make self-update an opt-in Cargo feature (#2606)
## Summary Ensures that (e.g.) installs from conda-forge, Homebrew, and other distributions don't expose `uv self update` at all. We'll still show `uv self update` for `pip install uv`, but it will fail with a good error. Removing the `uv self update` from `pip`-installed `uv` is more complicated, since we'd need to build separately for the installer vs. for PyPI. Closes #2588.
This commit is contained in:
parent
0ea51d43f5
commit
9986710a53
|
|
@ -74,7 +74,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: x86_64
|
target: x86_64
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
- name: "Upload wheels"
|
- name: "Upload wheels"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -112,7 +112,7 @@ jobs:
|
||||||
- name: "Build wheels - universal2"
|
- name: "Build wheels - universal2"
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
args: --release --locked --target universal2-apple-darwin --out dist
|
args: --release --locked --target universal2-apple-darwin --out dist --features self-update
|
||||||
- name: "Test wheel - universal2"
|
- name: "Test wheel - universal2"
|
||||||
run: |
|
run: |
|
||||||
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
|
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
|
||||||
|
|
@ -163,7 +163,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
- name: "Test wheel"
|
- name: "Test wheel"
|
||||||
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
|
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -211,7 +211,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
manylinux: auto
|
manylinux: auto
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
# See: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145
|
# See: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145
|
||||||
before-script-linux: |
|
before-script-linux: |
|
||||||
# If we're running on rhel centos, install needed packages.
|
# If we're running on rhel centos, install needed packages.
|
||||||
|
|
@ -289,7 +289,7 @@ jobs:
|
||||||
# On `aarch64`, use `manylinux: 2_28`; otherwise, use `manylinux: auto`.
|
# On `aarch64`, use `manylinux: 2_28`; otherwise, use `manylinux: auto`.
|
||||||
manylinux: ${{ matrix.platform.arch == 'aarch64' && '2_28' || 'auto' }}
|
manylinux: ${{ matrix.platform.arch == 'aarch64' && '2_28' || 'auto' }}
|
||||||
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
name: Test wheel
|
name: Test wheel
|
||||||
with:
|
with:
|
||||||
|
|
@ -353,7 +353,7 @@ jobs:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
manylinux: auto
|
manylinux: auto
|
||||||
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
||||||
args: --release --locked --out dist --no-default-features --features flate2/rust_backend
|
args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
if: matrix.platform.arch != 'ppc64'
|
if: matrix.platform.arch != 'ppc64'
|
||||||
name: Test wheel
|
name: Test wheel
|
||||||
|
|
@ -420,7 +420,7 @@ jobs:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
manylinux: auto
|
manylinux: auto
|
||||||
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
||||||
args: --release --locked --out dist --no-default-features --features flate2/rust_backend
|
args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update
|
||||||
before-script-linux: |
|
before-script-linux: |
|
||||||
if command -v yum &> /dev/null; then
|
if command -v yum &> /dev/null; then
|
||||||
yum update -y
|
yum update -y
|
||||||
|
|
@ -489,7 +489,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
manylinux: musllinux_1_2
|
manylinux: musllinux_1_2
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
- name: "Test wheel"
|
- name: "Test wheel"
|
||||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||||
uses: addnab/docker-run-action@v3
|
uses: addnab/docker-run-action@v3
|
||||||
|
|
@ -551,7 +551,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
manylinux: musllinux_1_2
|
manylinux: musllinux_1_2
|
||||||
args: --release --locked --out dist
|
args: --release --locked --out dist --features self-update
|
||||||
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
docker-options: ${{ matrix.platform.maturin_docker_options }}
|
||||||
- uses: uraimo/run-on-arch-action@v2
|
- uses: uraimo/run-on-arch-action@v2
|
||||||
name: Test wheel
|
name: Test wheel
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ uv-warnings = { workspace = true }
|
||||||
|
|
||||||
anstream = { workspace = true }
|
anstream = { workspace = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
axoupdater = { workspace = true, features = ["github_releases", "tokio"] }
|
axoupdater = { workspace = true, features = ["github_releases", "tokio"], optional = true }
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
clap = { workspace = true, features = ["derive", "string"] }
|
clap = { workspace = true, features = ["derive", "string"] }
|
||||||
clap_complete_command = { workspace = true }
|
clap_complete_command = { workspace = true }
|
||||||
|
|
@ -94,6 +94,8 @@ pypi = []
|
||||||
git = []
|
git = []
|
||||||
# Introduces a dependency on Maturin.
|
# Introduces a dependency on Maturin.
|
||||||
maturin = []
|
maturin = []
|
||||||
|
# Adds self-update functionality.
|
||||||
|
self-update = ["axoupdater"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
fs-err = { workspace = true }
|
fs-err = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ pub(crate) use pip_list::pip_list;
|
||||||
pub(crate) use pip_show::pip_show;
|
pub(crate) use pip_show::pip_show;
|
||||||
pub(crate) use pip_sync::pip_sync;
|
pub(crate) use pip_sync::pip_sync;
|
||||||
pub(crate) use pip_uninstall::pip_uninstall;
|
pub(crate) use pip_uninstall::pip_uninstall;
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
pub(crate) use self_update::self_update;
|
pub(crate) use self_update::self_update;
|
||||||
use uv_cache::Cache;
|
use uv_cache::Cache;
|
||||||
use uv_fs::Simplified;
|
use uv_fs::Simplified;
|
||||||
|
|
@ -39,6 +40,7 @@ mod pip_show;
|
||||||
mod pip_sync;
|
mod pip_sync;
|
||||||
mod pip_uninstall;
|
mod pip_uninstall;
|
||||||
mod reporters;
|
mod reporters;
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
mod self_update;
|
mod self_update;
|
||||||
mod venv;
|
mod venv;
|
||||||
mod version;
|
mod version;
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ enum Commands {
|
||||||
Cache(CacheNamespace),
|
Cache(CacheNamespace),
|
||||||
/// Manage the `uv` executable.
|
/// Manage the `uv` executable.
|
||||||
#[clap(name = "self")]
|
#[clap(name = "self")]
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
Self_(SelfNamespace),
|
Self_(SelfNamespace),
|
||||||
/// Clear the cache, removing all entries or those linked to specific packages.
|
/// Clear the cache, removing all entries or those linked to specific packages.
|
||||||
#[clap(hide = true)]
|
#[clap(hide = true)]
|
||||||
|
|
@ -151,12 +152,14 @@ enum Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
struct SelfNamespace {
|
struct SelfNamespace {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: SelfCommand,
|
command: SelfCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
enum SelfCommand {
|
enum SelfCommand {
|
||||||
/// Update `uv` to the latest version.
|
/// Update `uv` to the latest version.
|
||||||
Update,
|
Update,
|
||||||
|
|
@ -1822,6 +1825,7 @@ async fn run() -> Result<ExitStatus> {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "self-update")]
|
||||||
Commands::Self_(SelfNamespace {
|
Commands::Self_(SelfNamespace {
|
||||||
command: SelfCommand::Update,
|
command: SelfCommand::Update,
|
||||||
}) => commands::self_update(printer).await,
|
}) => commands::self_update(printer).await,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue