mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Add option pass environment variables for SDist building (#2039)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary With this PR I've added the option environment variables to the wheel building process, through the `BuildDispatch`. When integrating uv with our project pixi (https://github.com/prefix-dev/pixi/pull/863). We ran into this missing requirement, I've made a rough version here, could maybe use some refinement. ### Why do we need this? Because pixi allow the user to use a conda activated prefix for wheel building, this comes with a number of environment variables, like `PATH` but also `CONDA_PREFIX` amongst others. This allows the user to use system dependencies from conda-forge to use during an sdist build. Because we use `uv` as a library we need to pass in the options programatically. Additionally, in general there is nothing holding a python sdist back from actually depending on an environment variable, see e.g the test package: https://pypi.org/project/env-test-package/ ### What about `ConfigSettings` I think `ConfigSettings` does not suffice because e.g. CMake could function differently when the `CONDA_PREFIX` is set. Also, we do not know if the user supplied backend actually support these settings. ### Path handling Because the user can now also supply a PATH in the environment map, the logic I had was the following, I format the path so that it has the following precedence 1. venv scripts dir. 2. user supplied path. 3. system path. ### Improvements There is some path modification and copying happening everytime we use the `run_python_script` function, I think we could improve this but would like some pointers where to best put the maybe split and cached version, we might also want to use some types to split these things up. ### Finally I did not add any of these options to the uv executables, I first would like to know if this is a direction we would want to go in. I'm happy to do this or make any changes that you feel would benefit this project. Also tagging @wolfv to keep track of this as well. ## Test Plan <!-- How was it tested? --> --------- Co-authored-by: konsti <konstin@mailbox.org>
This commit is contained in:
parent
2838542ade
commit
0fbfa11013
6 changed files with 103 additions and 18 deletions
|
@ -7,6 +7,7 @@ use fs_err as fs;
|
|||
|
||||
use distribution_types::IndexLocations;
|
||||
use platform_host::Platform;
|
||||
use rustc_hash::FxHashMap;
|
||||
use uv_build::{SourceBuild, SourceBuildContext};
|
||||
use uv_cache::{Cache, CacheArgs};
|
||||
use uv_client::{FlatIndex, RegistryClientBuilder};
|
||||
|
@ -87,6 +88,7 @@ pub(crate) async fn build(args: BuildArgs) -> Result<PathBuf> {
|
|||
setup_py,
|
||||
config_settings.clone(),
|
||||
build_kind,
|
||||
FxHashMap::default(),
|
||||
)
|
||||
.await?;
|
||||
Ok(wheel_dir.join(builder.build(&wheel_dir).await?))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue