Use a ninja variable for Python binary
If we're going to allow for swapping out other dependencies with local versions, we don't want to have to be passing them around everywhere they are used.
This commit is contained in:
parent
dc0185720a
commit
ff59b33c54
@ -43,9 +43,9 @@ impl DistKind {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_bundle(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
pub fn build_bundle(build: &mut Build) -> Result<()> {
|
||||
// install into venv
|
||||
setup_primary_venv(build, python_binary)?;
|
||||
setup_primary_venv(build)?;
|
||||
install_anki_wheels(build)?;
|
||||
|
||||
// bundle venv into output binary + extra_files
|
||||
@ -60,7 +60,7 @@ pub fn build_bundle(build: &mut Build, python_binary: &BuildInput) -> Result<()>
|
||||
// repeat for Qt5
|
||||
if !targetting_macos_arm() {
|
||||
if !cfg!(target_os = "macos") {
|
||||
setup_qt5_venv(build, python_binary)?;
|
||||
setup_qt5_venv(build)?;
|
||||
}
|
||||
build_dist_folder(build, DistKind::Alternate)?;
|
||||
}
|
||||
@ -171,7 +171,7 @@ const QT5_VENV: Venv = Venv {
|
||||
path_without_builddir: "bundle/pyenv-qt5",
|
||||
};
|
||||
|
||||
fn setup_primary_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
fn setup_primary_venv(build: &mut Build) -> Result<()> {
|
||||
let mut qt6_reqs = inputs![
|
||||
"python/requirements.bundle.txt",
|
||||
if cfg!(target_os = "macos") {
|
||||
@ -189,14 +189,13 @@ fn setup_primary_venv(build: &mut Build, python_binary: &BuildInput) -> Result<(
|
||||
folder: PRIMARY_VENV.path_without_builddir,
|
||||
base_requirements_txt: "python/requirements.base.txt".into(),
|
||||
requirements_txt: qt6_reqs,
|
||||
python_binary,
|
||||
extra_binary_exports: &[],
|
||||
},
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn setup_qt5_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
fn setup_qt5_venv(build: &mut Build) -> Result<()> {
|
||||
let qt5_reqs = inputs![
|
||||
"python/requirements.base.txt",
|
||||
if cfg!(target_os = "macos") {
|
||||
@ -211,7 +210,6 @@ fn setup_qt5_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
folder: QT5_VENV.path_without_builddir,
|
||||
base_requirements_txt: "python/requirements.base.txt".into(),
|
||||
requirements_txt: qt5_reqs,
|
||||
python_binary,
|
||||
extra_binary_exports: &[],
|
||||
},
|
||||
)
|
||||
|
@ -35,14 +35,14 @@ fn main() -> Result<()> {
|
||||
let mut build = Build::new()?;
|
||||
let build = &mut build;
|
||||
|
||||
let python_binary = setup_python(build)?;
|
||||
setup_venv(build, &python_binary)?;
|
||||
setup_python(build)?;
|
||||
setup_venv(build)?;
|
||||
|
||||
build_rust(build)?;
|
||||
build_pylib(build)?;
|
||||
build_and_check_web(build)?;
|
||||
build_and_check_aqt(build)?;
|
||||
build_bundle(build, &python_binary)?;
|
||||
build_bundle(build)?;
|
||||
|
||||
check_rust(build)?;
|
||||
check_pylib(build)?;
|
||||
|
@ -59,7 +59,7 @@ fn python_archive(platform: Platform) -> OnlineArchive {
|
||||
|
||||
/// Returns the Python binary, which can be used to create venvs.
|
||||
/// Downloads if missing.
|
||||
pub fn setup_python(build: &mut Build) -> Result<BuildInput> {
|
||||
pub fn setup_python(build: &mut Build) -> Result<()> {
|
||||
// if changing this, make sure you remove out/pyenv
|
||||
let python_binary = match env::var("PYTHON_BINARY") {
|
||||
Ok(path) => {
|
||||
@ -81,10 +81,12 @@ pub fn setup_python(build: &mut Build) -> Result<BuildInput> {
|
||||
inputs![":extract:python:bin"]
|
||||
}
|
||||
};
|
||||
Ok(python_binary)
|
||||
let python_binary = build.expand_inputs(python_binary);
|
||||
build.variable("python_binary", &python_binary[0]);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn setup_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
pub fn setup_venv(build: &mut Build) -> Result<()> {
|
||||
let requirements_txt = if cfg!(windows) {
|
||||
inputs![
|
||||
"python/requirements.dev.txt",
|
||||
@ -109,7 +111,6 @@ pub fn setup_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
folder: "pyenv",
|
||||
base_requirements_txt: inputs!["python/requirements.base.txt"],
|
||||
requirements_txt,
|
||||
python_binary,
|
||||
extra_binary_exports: &[
|
||||
"pip-compile",
|
||||
"pip-sync",
|
||||
@ -135,7 +136,6 @@ pub fn setup_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
folder: "pyenv-qt5.15",
|
||||
base_requirements_txt: inputs!["python/requirements.base.txt"],
|
||||
requirements_txt: inputs![&reqs_qt5, "python/requirements.qt5_15.txt"],
|
||||
python_binary,
|
||||
extra_binary_exports: &[],
|
||||
},
|
||||
)?;
|
||||
@ -145,7 +145,6 @@ pub fn setup_venv(build: &mut Build, python_binary: &BuildInput) -> Result<()> {
|
||||
folder: "pyenv-qt5.14",
|
||||
base_requirements_txt: inputs!["python/requirements.base.txt"],
|
||||
requirements_txt: inputs![reqs_qt5, "python/requirements.qt5_14.txt"],
|
||||
python_binary,
|
||||
extra_binary_exports: &[],
|
||||
},
|
||||
)?;
|
||||
|
@ -8,15 +8,14 @@ use crate::inputs;
|
||||
use crate::Build;
|
||||
use crate::Result;
|
||||
|
||||
pub struct PythonEnvironment<'a> {
|
||||
pub struct PythonEnvironment {
|
||||
pub folder: &'static str,
|
||||
pub base_requirements_txt: BuildInput,
|
||||
pub requirements_txt: BuildInput,
|
||||
pub python_binary: &'a BuildInput,
|
||||
pub extra_binary_exports: &'static [&'static str],
|
||||
}
|
||||
|
||||
impl BuildAction for PythonEnvironment<'_> {
|
||||
impl BuildAction for PythonEnvironment {
|
||||
fn command(&self) -> &str {
|
||||
"$runner pyenv $python_binary $builddir/$pyenv_folder $system_pkgs $base_requirements $requirements"
|
||||
}
|
||||
@ -32,7 +31,7 @@ impl BuildAction for PythonEnvironment<'_> {
|
||||
vec![path]
|
||||
};
|
||||
|
||||
build.add_inputs("python_binary", self.python_binary);
|
||||
build.add_inputs("python_binary", inputs!["$python_binary"]);
|
||||
build.add_inputs("base_requirements", &self.base_requirements_txt);
|
||||
build.add_inputs("requirements", &self.requirements_txt);
|
||||
build.add_variable("pyenv_folder", self.folder);
|
||||
|
Loading…
Reference in New Issue
Block a user