From e2a0fe8d9c68da5c5c4b79c03090dab19fd26716 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 7 Jul 2026 01:18:37 +0700 Subject: [PATCH] Add python cross env and fix gio scanner --- recipes/dev/python312/recipe.toml | 6 ++++++ recipes/wip/dev/python/python3-cython/recipe.toml | 1 + recipes/wip/dev/python/python3-setuptools/recipe.toml | 1 + recipes/wip/dev/python/python3-yaml/recipe.toml | 1 + recipes/wip/libs/gnome/gobject-introspection/recipe.toml | 9 ++++++--- src/cook/script.rs | 9 ++++++++- 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/recipes/dev/python312/recipe.toml b/recipes/dev/python312/recipe.toml index c2e0e0936..bf54aa66c 100644 --- a/recipes/dev/python312/recipe.toml +++ b/recipes/dev/python312/recipe.toml @@ -55,6 +55,12 @@ cookbook_configure # A same file to save 60MB (cd "${COOKBOOK_STAGE}/usr/lib/python3.12/config-3.12-$ARCH-$OS" && \ rm -f libpython3.12.a && ln -s ../../libpython3.12.a) +# monkey patching to make paths working in target system +if [ "$TARGET" != "$COOKBOOK_HOST_TARGET" ]; then + PYTHON_INIT + sed -i "s/sccache //g" "$COOKBOOK_STAGE/usr/lib/$COOKBOOK_PYTHON_V/$_PYTHON_SYSCONFIGDATA_NAME.py" + sed -i "s|${COOKBOOK_SYSROOT}|/usr|g" "$COOKBOOK_STAGE/usr/lib/$COOKBOOK_PYTHON_V/$_PYTHON_SYSCONFIGDATA_NAME.py" +fi """ [[optional-packages]] diff --git a/recipes/wip/dev/python/python3-cython/recipe.toml b/recipes/wip/dev/python/python3-cython/recipe.toml index d4ddeb0e2..a5d2a08be 100644 --- a/recipes/wip/dev/python/python3-cython/recipe.toml +++ b/recipes/wip/dev/python/python3-cython/recipe.toml @@ -8,6 +8,7 @@ template = "python" dev-dependencies = [ "host:python312", "host:python3-setuptools", + "python312", ] [package] diff --git a/recipes/wip/dev/python/python3-setuptools/recipe.toml b/recipes/wip/dev/python/python3-setuptools/recipe.toml index 42503df2a..7c356df17 100644 --- a/recipes/wip/dev/python/python3-setuptools/recipe.toml +++ b/recipes/wip/dev/python/python3-setuptools/recipe.toml @@ -7,6 +7,7 @@ shallow_clone = true template = "python" dev-dependencies = [ "host:python312", + "python312", ] [package] diff --git a/recipes/wip/dev/python/python3-yaml/recipe.toml b/recipes/wip/dev/python/python3-yaml/recipe.toml index 9f2ccdfec..2b75312fc 100644 --- a/recipes/wip/dev/python/python3-yaml/recipe.toml +++ b/recipes/wip/dev/python/python3-yaml/recipe.toml @@ -9,6 +9,7 @@ dev-dependencies = [ "host:python312", "host:python3-setuptools", "host:python3-cython", + "python312", ] [package] diff --git a/recipes/wip/libs/gnome/gobject-introspection/recipe.toml b/recipes/wip/libs/gnome/gobject-introspection/recipe.toml index 43e940465..3b1a74738 100644 --- a/recipes/wip/libs/gnome/gobject-introspection/recipe.toml +++ b/recipes/wip/libs/gnome/gobject-introspection/recipe.toml @@ -16,13 +16,16 @@ dev-dependencies = [ ] script = """ DYNAMIC_INIT -cookbook_meson -Dpython="python3.12" \ +PYTHON_INIT +cookbook_meson -Dpython="${COOKBOOK_PYTHON_V}" \ -Dbuild_introspection_data=false -sed -i "s|${COOKBOOK_TOOLCHAIN}||g" ${COOKBOOK_STAGE}/usr/bin/g-ir-annotation-tool -sed -i "s|${COOKBOOK_TOOLCHAIN}||g" ${COOKBOOK_STAGE}/usr/bin/g-ir-scanner +sed -i "s|${COOKBOOK_TOOLCHAIN}||g" "${COOKBOOK_STAGE}"/usr/bin/g-ir-annotation-tool +sed -i "s|${COOKBOOK_TOOLCHAIN}||g" "${COOKBOOK_STAGE}"/usr/bin/g-ir-scanner +mv "${COOKBOOK_STAGE}"/usr/lib/gobject-introspection "${COOKBOOK_STAGE}"/usr/lib/${COOKBOOK_PYTHON_V} """ [package] dependencies = [ "python312", + "python3-setuptools", ] diff --git a/src/cook/script.rs b/src/cook/script.rs index 8b0791f23..2c1e5f2d0 100644 --- a/src/cook/script.rs +++ b/src/cook/script.rs @@ -349,10 +349,17 @@ function cookbook_meson { DESTDIR="${COOKBOOK_STAGE}" "${COOKBOOK_NINJA}" install -j"${COOKBOOK_MAKE_JOBS}" } COOKBOOK_PYTHON="${COOKBOOK_TOOLCHAIN}/bin/python3" -function cookbook_python { +COOKBOOK_PYTHON_V="python3.12" +function PYTHON_INIT { ARCH="${TARGET%%-*}" OS=$(echo "${TARGET}" | cut -d - -f3-4) + SYSTEM=$(echo "${TARGET}" | cut -d - -f3) export PYTHONPYCACHEPREFIX="${COOKBOOK_BUILD}" _PYTHON_HOST_PLATFORM="$OS-$ARCH" + export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}${COOKBOOK_SYSROOT}/usr/lib/${COOKBOOK_PYTHON_V}" + export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__${SYSTEM}_${ARCH}-${OS}" +} +function cookbook_python { + PYTHON_INIT "${COOKBOOK_PYTHON}" -m pip install --prefix="${COOKBOOK_STAGE}/usr" "${COOKBOOK_SOURCE}" \ --ignore-installed --no-index "$@" rsync -av "${COOKBOOK_BUILD}/${COOKBOOK_STAGE}/usr/" "${COOKBOOK_STAGE}/usr"