From 3d3282dba7e1aa7a2bd371cb97e4c8e69c9be69b Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 20 Jun 2026 16:21:41 -0500 Subject: [PATCH] chore(cryptography): update maturin version to 1.13.2 and apply libpython3 symlink fix in build process --- .../cryptography-49/meta.yaml | 1 + .../patches/maturin_min_version.patch | 11 +++++++ .../patches/openssl_no_legacy.patch | 13 ++++----- scripts/build-android-wheels-local.sh | 29 +++++++++++++++++++ 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 android/chaquopy-recipes/cryptography-49/patches/maturin_min_version.patch diff --git a/android/chaquopy-recipes/cryptography-49/meta.yaml b/android/chaquopy-recipes/cryptography-49/meta.yaml index 1d661422..dea67b47 100644 --- a/android/chaquopy-recipes/cryptography-49/meta.yaml +++ b/android/chaquopy-recipes/cryptography-49/meta.yaml @@ -5,5 +5,6 @@ package: requirements: build: - rust + - maturin>=1.13.2 host: - openssl diff --git a/android/chaquopy-recipes/cryptography-49/patches/maturin_min_version.patch b/android/chaquopy-recipes/cryptography-49/patches/maturin_min_version.patch new file mode 100644 index 00000000..728f9683 --- /dev/null +++ b/android/chaquopy-recipes/cryptography-49/patches/maturin_min_version.patch @@ -0,0 +1,11 @@ +--- src-original/pyproject.toml ++++ src/pyproject.toml +@@ -4,7 +4,7 @@ + # These requirements must be kept sync with the requirements in + # ./.github/requirements/build-requirements.{in,txt} + requires = [ +- "maturin>=1.9.4,<2,!=1.12.0", ++ "maturin>=1.13.2,<2,!=1.12.0", + + # Must be kept in sync with `project.dependencies` + "cffi>=2.0.0; platform_python_implementation != 'PyPy'", diff --git a/android/chaquopy-recipes/cryptography-49/patches/openssl_no_legacy.patch b/android/chaquopy-recipes/cryptography-49/patches/openssl_no_legacy.patch index a5a049ad..bafccc3c 100644 --- a/android/chaquopy-recipes/cryptography-49/patches/openssl_no_legacy.patch +++ b/android/chaquopy-recipes/cryptography-49/patches/openssl_no_legacy.patch @@ -1,13 +1,10 @@ --- src-original/src/rust/src/lib.rs +++ src/src/rust/src/lib.rs -@@ -89,6 +89,9 @@ - let load_legacy = !cfg!(CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY) - && !env::var("CRYPTOGRAPHY_OPENSSL_NO_LEGACY").is_ok_and(|v| !v.is_empty() && v != "0"); - -+ // Chaquopy: the legacy provider is not available. +@@ -89,6 +89,6 @@ +- let load_legacy = !cfg!(CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY) +- && !env::var("CRYPTOGRAPHY_OPENSSL_NO_LEGACY").is_ok_and(|v| !v.is_empty() && v != "0"); ++ // Chaquopy: the legacy provider is not available on Android. + let load_legacy = false; -+ + let legacy = if load_legacy { let legacy_result = provider::Provider::load(None, "legacy"); - if legacy_result.is_err() { - let message = c"OpenSSL 3's legacy provider failed to load. Legacy algorithms will not be available. If you need those algorithms, check your OpenSSL configuration."; diff --git a/scripts/build-android-wheels-local.sh b/scripts/build-android-wheels-local.sh index bf47393c..161d4734 100755 --- a/scripts/build-android-wheels-local.sh +++ b/scripts/build-android-wheels-local.sh @@ -204,6 +204,33 @@ fi echo "Using Chaquopy git ref: ${CHAQUOPY_REF}" echo "Using Chaquopy target version: ${TARGET_VERSION}" +apply_chaquopy_libpython3_link_fix() { + local build_wheel="${PYPIDIR}/build-wheel.py" + "${PYTHON_BIN}" - <<'PY' +from pathlib import Path +import os +import sys + +path = Path(os.environ["BUILD_WHEEL_PY"]) +text = path.read_text() +if "python_abi3_link" in text: + print("libpython3.so symlink fix already present in build-wheel.py") + sys.exit(0) +needle = ' run(f"ln -s {filename} {reqs_lib_dir}/{link_filename}")' +if needle not in text: + print("Could not find SONAME symlink loop in build-wheel.py", file=sys.stderr) + sys.exit(1) +insert = needle + """ + + python_soname = f"libpython{self.python}.so" + python_abi3_link = "libpython3.so" + if exists(f"{reqs_lib_dir}/{python_soname}") and not exists(f"{reqs_lib_dir}/{python_abi3_link}"): + run(f"ln -s {python_soname} {reqs_lib_dir}/{python_abi3_link}")""" +path.write_text(text.replace(needle, insert, 1)) +print("Applied libpython3.so symlink fix to build-wheel.py") +PY +} + pushd "${CHAQUOPY_DIR}" >/dev/null TARGET_PATH="maven/com/chaquo/python/target/${TARGET_VERSION}" if [[ ! -d "${TARGET_PATH}" ]]; then @@ -214,6 +241,8 @@ fi popd >/dev/null PYPIDIR="${CHAQUOPY_DIR}/server/pypi" +export BUILD_WHEEL_PY="${PYPIDIR}/build-wheel.py" +apply_chaquopy_libpython3_link_fix VENV_DIR="${PYPIDIR}/.venv-local" rm -rf "${VENV_DIR}" "${PYTHON_BIN}" -m venv "${VENV_DIR}"