Skip to content

Commit 57f0114

Browse files
committed
Source NDK installer and use NDK_HOME
Source the NDK install script in CI (AppVeyor and GitHub Actions) so its environment is applied. .ci/install_ndk.sh now exports NDK_HOME and ensures a trailing newline. In src/forge/build.py, add logic to detect NDK_HOME and re-point missing compiler/binutils to the NDK toolchain prebuilt bin directory so Android build archives that reference embedded NDK paths work in CI. Also uncomment build.script_env in the pydantic-core recipe to set _PYTHON_SYSCONFIGDATA_NAME.
1 parent 2a13e1a commit 57f0114

5 files changed

Lines changed: 25 additions & 7 deletions

File tree

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ for:
200200
- tar -xzf python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz -C $python_android_dir
201201

202202
# install Android NDK
203-
- .ci/install_ndk.sh
203+
- . .ci/install_ndk.sh
204204

205205
# install Rust
206206
- curl https://sh.rustup.rs -sSf | sh -s -- -y

.ci/install_ndk.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ if [[ -z "${NDK_HOME-}" ]]; then
4646
fi
4747
else
4848
echo "NDK home: $NDK_HOME"
49-
fi
49+
fi
50+
51+
export NDK_HOME

.github/workflows/build-wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
mkdir -p "$python_android_dir"
6767
tar -xzf "python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" -C "$python_android_dir"
6868
69-
.ci/install_ndk.sh
69+
. .ci/install_ndk.sh
7070
7171
curl https://sh.rustup.rs -sSf | sh -s -- -y
7272
. "$HOME/.cargo/env"
@@ -119,4 +119,4 @@ jobs:
119119
uses: actions/upload-artifact@v4
120120
with:
121121
name: ${{ matrix.platform }}-errors-${{ github.run_id }}-${{ github.run_attempt }}
122-
path: errors/*.log
122+
path: errors/*.log

recipes/pydantic-core/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package:
22
name: pydantic-core
33
version: 2.33.2
44

5-
# build:
6-
# script_env:
7-
# _PYTHON_SYSCONFIGDATA_NAME: '{sysconfigdata_name}'
5+
build:
6+
script_env:
7+
_PYTHON_SYSCONFIGDATA_NAME: '{sysconfigdata_name}'

src/forge/build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,22 @@ def compile_env(self, **kwargs) -> dict[str, str]:
299299

300300
cppflags += f" -mios-version-min={self.cross_venv.sdk_version}"
301301
else:
302+
# Some Python Android support archives reference an embedded NDK path
303+
# that isn't present in CI. If NDK_HOME is set, re-point missing
304+
# compiler/binutils paths to that installed NDK toolchain.
305+
ndk_home = os.environ.get("NDK_HOME")
306+
if ndk_home:
307+
prebuilt_dirs = list(
308+
(Path(ndk_home) / "toolchains" / "llvm" / "prebuilt").glob("*")
309+
)
310+
if prebuilt_dirs:
311+
ndk_bin = prebuilt_dirs[0] / "bin"
312+
if not Path(cc).is_file():
313+
cc = str(ndk_bin / Path(cc).name)
314+
if not Path(cxx).is_file():
315+
cxx = str(ndk_bin / Path(cxx).name)
316+
if not Path(ar).is_file():
317+
ar = str(ndk_bin / Path(ar).name)
302318
ndk_sysroot = Path(cc).parent.parent / "sysroot"
303319
if (ndk_sysroot / "usr" / "include").is_dir():
304320
cflags += f" -I{ndk_sysroot}/usr/include"

0 commit comments

Comments
 (0)