From a551de6eb862cb96db9f38210377e4566cdaab8d Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 14 Jul 2026 16:35:43 +0700 Subject: [PATCH] Fix python-setuptools by adding legacy build option --- recipes/wip/dev/python/python3-cython/recipe.toml | 2 +- recipes/wip/dev/python/python3-setuptools/recipe.toml | 3 ++- src/cook/cook_build.rs | 9 ++++++++- src/cook/script.rs | 7 ++++++- src/recipe.rs | 9 ++++++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/recipes/wip/dev/python/python3-cython/recipe.toml b/recipes/wip/dev/python/python3-cython/recipe.toml index a5d2a08be..c5eff5eec 100644 --- a/recipes/wip/dev/python/python3-cython/recipe.toml +++ b/recipes/wip/dev/python/python3-cython/recipe.toml @@ -7,8 +7,8 @@ shallow_clone = true template = "python" dev-dependencies = [ "host:python312", - "host:python3-setuptools", "python312", + "python3-setuptools", ] [package] diff --git a/recipes/wip/dev/python/python3-setuptools/recipe.toml b/recipes/wip/dev/python/python3-setuptools/recipe.toml index 7c356df17..135b25ab4 100644 --- a/recipes/wip/dev/python/python3-setuptools/recipe.toml +++ b/recipes/wip/dev/python/python3-setuptools/recipe.toml @@ -1,10 +1,11 @@ [source] git = "https://github.com/pypa/setuptools" -rev = "v82.0.1" +rev = "v83.0.0" shallow_clone = true [build] template = "python" +legacysetup = true dev-dependencies = [ "host:python312", "python312", diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index 39cdb7809..a5bc44907 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -390,7 +390,14 @@ pub fn build( "DYNAMIC_INIT\n{}cookbook_meson", flags_fn("COOKBOOK_MESON_FLAGS", mesonflags), ), - BuildKind::Python {} => format!("DYNAMIC_INIT\ncookbook_python"), + BuildKind::Python { legacysetup } => format!( + "DYNAMIC_INIT\n{}cookbook_python", + if *legacysetup { + "COOKBOOK_PYTHON_LEGACY_SETUP=1\n" + } else { + "" + } + ), BuildKind::Custom { script } => script.clone(), BuildKind::Remote => unreachable!(), BuildKind::None => "".to_owned(), diff --git a/src/cook/script.rs b/src/cook/script.rs index 4db4a0c04..009d449e6 100644 --- a/src/cook/script.rs +++ b/src/cook/script.rs @@ -361,7 +361,12 @@ function PYTHON_INIT { } function cookbook_python { PYTHON_INIT - "${COOKBOOK_PYTHON}" -m pip install --prefix="${COOKBOOK_STAGE}/usr" "${COOKBOOK_SOURCE}" \ + # no way to do out-of-tree build: https://github.com/pypa/setuptools/issues/3237 + rsync -a "${COOKBOOK_SOURCE}/" ./source + if [ -n "${COOKBOOK_PYTHON_LEGACY_SETUP}" ]; then + python3 ./source/setup.py install + fi + "${COOKBOOK_PYTHON}" -m pip install --prefix="${COOKBOOK_STAGE}/usr" "./source" \ --ignore-installed --no-index --no-build-isolation "$@" rsync -av "${COOKBOOK_BUILD}/${COOKBOOK_STAGE}/usr/" "${COOKBOOK_STAGE}/usr" } diff --git a/src/recipe.rs b/src/recipe.rs index ea379a18d..5c9c0323f 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -105,7 +105,14 @@ pub enum BuildKind { }, /// Will build and install using python pip #[serde(rename = "python")] - Python, + Python { + /// Some recipes need to run setup.py, + /// other does not allow running setup.py. + /// This defaults to not run setup.py, but if build result in error, + /// like "invalid command 'dist_info'", set this on. + #[serde(default)] + legacysetup: bool, + }, /// Will build and install using custom commands #[serde(rename = "custom")] Custom { script: String },