Implement build python template and port python3-yaml

This commit is contained in:
Wildan M 2026-05-17 17:42:39 +07:00
parent 0886d88cd6
commit 2dd0f0f1f2
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
7 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,16 @@
[source]
git = "https://github.com/cython/cython"
rev = "3.2.4"
shallow_clone = true
[build]
template = "python"
dev-dependencies = [
"host:python312",
"host:python3-setuptools",
]
[package]
dependencies = [
"python312"
]

View File

@ -0,0 +1,16 @@
[source]
git = "https://github.com/pypa/setuptools"
rev = "v82.0.1"
shallow_clone = true
[build]
template = "python"
dev-dependencies = [
"host:python312",
]
[package]
dependencies = [
"python312"
]

View File

@ -0,0 +1,17 @@
[source]
git = "https://github.com/yaml/pyyaml.git"
rev = "6.0.3"
shallow_clone = true
[build]
template = "python"
dev-dependencies = [
"host:python312",
"host:python3-setuptools",
"host:python3-cython",
]
[package]
dependencies = [
"python312"
]

View File

@ -0,0 +1,11 @@
# TODO: workout pyproject.toml deps
[source]
git = "https://github.com/aws/aws-cli.git"
rev = "2.15.31"
shallow_clone = true
[build]
template = "python"
dev-dependencies = [
"host:python312"
]

View File

@ -388,6 +388,7 @@ pub fn build(
"DYNAMIC_INIT\n{}cookbook_meson",
flags_fn("COOKBOOK_MESON_FLAGS", mesonflags),
),
BuildKind::Python {} => format!("DYNAMIC_INIT\ncookbook_python"),
BuildKind::Custom { script } => script.clone(),
BuildKind::Remote => unreachable!(),
BuildKind::None => "".to_owned(),

View File

@ -348,6 +348,15 @@ function cookbook_meson {
"${COOKBOOK_NINJA}" -j"${COOKBOOK_MAKE_JOBS}"
DESTDIR="${COOKBOOK_STAGE}" "${COOKBOOK_NINJA}" install -j"${COOKBOOK_MAKE_JOBS}"
}
COOKBOOK_PYTHON="${COOKBOOK_TOOLCHAIN}/bin/python3"
function cookbook_python {
ARCH="${TARGET%%-*}"
OS=$(echo "${TARGET}" | cut -d - -f3-4)
export PYTHONPYCACHEPREFIX="${COOKBOOK_BUILD}" _PYTHON_HOST_PLATFORM="$OS-$ARCH"
"${COOKBOOK_PYTHON}" -m pip install --prefix="${COOKBOOK_STAGE}/usr" "${COOKBOOK_SOURCE}" \
--ignore-installed --no-index --no-build-isolation "$@"
rsync -av "${COOKBOOK_BUILD}/${COOKBOOK_STAGE}/usr/" "${COOKBOOK_STAGE}/usr"
}
"#;
pub(crate) static BUILD_POSTSCRIPT: &str = r#"

View File

@ -103,6 +103,9 @@ pub enum BuildKind {
#[serde(default)]
mesonflags: Vec<String>,
},
/// Will build and install using python pip
#[serde(rename = "python")]
Python,
/// Will build and install using custom commands
#[serde(rename = "custom")]
Custom { script: String },