mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Add UV_NO_BUILD_ISOLATION
as environment variable (#3318)
## Summary Hi! Added `UV_NO_BUILD_ISOLATION` as a boolean environment variable for the `--no-build-isolation` command-line option. Closes https://github.com/astral-sh/uv/issues/3309 ## Test Plan Added new test `respect_no_build_isolation_env_var` to check that the behaviour is the same as if the ``--no-build-isolation`` command-line-option is set.
This commit is contained in:
parent
cf55c715f8
commit
f77583e036
3 changed files with 92 additions and 3 deletions
|
@ -508,6 +508,8 @@ uv accepts the following command-line arguments as environment variables:
|
||||||
file as the constraints file. Uses space-separated list of files.
|
file as the constraints file. Uses space-separated list of files.
|
||||||
- `UV_LINK_MODE`: Equivalent to the `--link-mode` command-line argument. If set, uv will use this
|
- `UV_LINK_MODE`: Equivalent to the `--link-mode` command-line argument. If set, uv will use this
|
||||||
as a link mode.
|
as a link mode.
|
||||||
|
- `UV_NO_BUILD_ISOLATION`: Equivalent to the `--no-build-isolation` command-line argument. If set,
|
||||||
|
uv will skip isolation when building source distributions.
|
||||||
|
|
||||||
In each case, the corresponding command-line argument takes precedence over an environment variable.
|
In each case, the corresponding command-line argument takes precedence over an environment variable.
|
||||||
|
|
||||||
|
|
|
@ -500,7 +500,12 @@ pub(crate) struct PipCompileArgs {
|
||||||
/// Disable isolation when building source distributions.
|
/// Disable isolation when building source distributions.
|
||||||
///
|
///
|
||||||
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
||||||
#[arg(long, overrides_with("build_isolation"))]
|
#[arg(
|
||||||
|
long,
|
||||||
|
env = "UV_NO_BUILD_ISOLATION",
|
||||||
|
value_parser = clap::builder::BoolishValueParser::new(),
|
||||||
|
overrides_with("build_isolation")
|
||||||
|
)]
|
||||||
pub(crate) no_build_isolation: bool,
|
pub(crate) no_build_isolation: bool,
|
||||||
|
|
||||||
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
||||||
|
@ -801,7 +806,13 @@ pub(crate) struct PipSyncArgs {
|
||||||
/// Disable isolation when building source distributions.
|
/// Disable isolation when building source distributions.
|
||||||
///
|
///
|
||||||
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
||||||
#[arg(long, overrides_with("build_isolation"))]
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
env = "UV_NO_BUILD_ISOLATION",
|
||||||
|
value_parser = clap::builder::BoolishValueParser::new(),
|
||||||
|
overrides_with("build_isolation")
|
||||||
|
)]
|
||||||
pub(crate) no_build_isolation: bool,
|
pub(crate) no_build_isolation: bool,
|
||||||
|
|
||||||
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
||||||
|
@ -1176,7 +1187,12 @@ pub(crate) struct PipInstallArgs {
|
||||||
/// Disable isolation when building source distributions.
|
/// Disable isolation when building source distributions.
|
||||||
///
|
///
|
||||||
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
/// Assumes that build dependencies specified by PEP 518 are already installed.
|
||||||
#[arg(long, overrides_with("build_isolation"))]
|
#[arg(
|
||||||
|
long,
|
||||||
|
env = "UV_NO_BUILD_ISOLATION",
|
||||||
|
value_parser = clap::builder::BoolishValueParser::new(),
|
||||||
|
overrides_with("build_isolation")
|
||||||
|
)]
|
||||||
pub(crate) no_build_isolation: bool,
|
pub(crate) no_build_isolation: bool,
|
||||||
|
|
||||||
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
#[arg(long, overrides_with("no_build_isolation"), hide = true)]
|
||||||
|
|
|
@ -2676,6 +2676,77 @@ fn no_build_isolation() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ensure that `UV_NO_BUILD_ISOLATION` env var does the same as the `--no-build-isolation` flag
|
||||||
|
#[test]
|
||||||
|
fn respect_no_build_isolation_env_var() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
let requirements_in = context.temp_dir.child("requirements.in");
|
||||||
|
requirements_in.write_str("anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz")?;
|
||||||
|
|
||||||
|
// We expect the build to fail, because `setuptools` is not installed.
|
||||||
|
let filters = std::iter::once((r"exit code: 1", "exit status: 1"))
|
||||||
|
.chain(context.filters())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
uv_snapshot!(filters, context.install()
|
||||||
|
.arg("-r")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.env("UV_NO_BUILD_ISOLATION", "yes"), @r###"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Failed to download and build: `anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz`
|
||||||
|
Caused by: Failed to build: `anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz`
|
||||||
|
Caused by: Build backend failed to determine metadata through `prepare_metadata_for_build_wheel` with exit status: 1
|
||||||
|
--- stdout:
|
||||||
|
|
||||||
|
--- stderr:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "<string>", line 8, in <module>
|
||||||
|
ModuleNotFoundError: No module named 'setuptools'
|
||||||
|
---
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
// Install `setuptools` and `wheel`.
|
||||||
|
uv_snapshot!(context.install()
|
||||||
|
.arg("setuptools")
|
||||||
|
.arg("wheel"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 2 packages in [TIME]
|
||||||
|
Downloaded 2 packages in [TIME]
|
||||||
|
Installed 2 packages in [TIME]
|
||||||
|
+ setuptools==69.2.0
|
||||||
|
+ wheel==0.43.0
|
||||||
|
"###);
|
||||||
|
|
||||||
|
// We expect the build to succeed, since `setuptools` is now installed.
|
||||||
|
uv_snapshot!(context.install()
|
||||||
|
.arg("-r")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.env("UV_NO_BUILD_ISOLATION", "yes"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 3 packages in [TIME]
|
||||||
|
Downloaded 3 packages in [TIME]
|
||||||
|
Installed 3 packages in [TIME]
|
||||||
|
+ anyio==0.0.0 (from https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz)
|
||||||
|
+ idna==3.6
|
||||||
|
+ sniffio==1.3.1
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// This tests that `uv` can read UTF-16LE encoded requirements.txt files.
|
/// This tests that `uv` can read UTF-16LE encoded requirements.txt files.
|
||||||
///
|
///
|
||||||
/// Ref: <https://github.com/astral-sh/uv/issues/2276>
|
/// Ref: <https://github.com/astral-sh/uv/issues/2276>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue