respect env var UV_BINARY with OFFLINE_BUILD being set (#4170)

* respect env var UV_BINARY with OFFLINE_BUILD being set

* cleanup formatting, fix import

* Fix build error (dae)
This commit is contained in:
Alexander Bocken 2025-07-07 10:16:00 +02:00 committed by GitHub
parent b16439fc9c
commit b205008a5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,6 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use anyhow::Result;
use ninja_gen::action::BuildAction;
use ninja_gen::archives::Platform;
@ -125,7 +123,14 @@ impl BuildAction for BuildWheel {
}
fn files(&mut self, build: &mut impl FilesHandle) {
build.add_inputs("uv", inputs![":uv_binary"]);
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
let uv_path =
std::env::var("UV_BINARY").expect("UV_BINARY must be set in OFFLINE_BUILD mode");
build.add_inputs("uv", inputs![uv_path]);
} else {
build.add_inputs("uv", inputs![":uv_binary"]);
}
build.add_inputs("", &self.deps);
// Set the project directory based on which package we're building
@ -222,15 +227,19 @@ struct Sphinx {
impl BuildAction for Sphinx {
fn command(&self) -> &str {
if env::var("OFFLINE_BUILD").is_err() {
"$uv sync --extra sphinx && $python python/sphinx/build.py"
} else {
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
"$python python/sphinx/build.py"
} else {
"$uv sync --extra sphinx && $python python/sphinx/build.py"
}
}
fn files(&mut self, build: &mut impl FilesHandle) {
if env::var("OFFLINE_BUILD").is_err() {
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
let uv_path =
std::env::var("UV_BINARY").expect("UV_BINARY must be set in OFFLINE_BUILD mode");
build.add_inputs("uv", inputs![uv_path]);
} else {
build.add_inputs("uv", inputs![":uv_binary"]);
// Set environment variable to use the existing pyenv
build.add_variable("pyenv_path", "$builddir/pyenv");