Fix python-setuptools by adding legacy build option

This commit is contained in:
Wildan M 2026-07-14 16:35:43 +07:00
parent a309abb16b
commit a551de6eb8
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
5 changed files with 25 additions and 5 deletions

View File

@ -7,8 +7,8 @@ shallow_clone = true
template = "python"
dev-dependencies = [
"host:python312",
"host:python3-setuptools",
"python312",
"python3-setuptools",
]
[package]

View File

@ -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",

View File

@ -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(),

View File

@ -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"
}

View File

@ -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 },