|
2 | 2 |
|
3 | 3 | set -o errexit |
4 | 4 |
|
5 | | -repo_root=$(python -c 'from pathlib import Path; print(Path.cwd().resolve().as_posix())') |
6 | | -lib_dir="$repo_root/.local/lib" |
7 | | -pkgconfig_dir="$lib_dir/pkgconfig" |
8 | | -mkdir -p "$pkgconfig_dir" |
9 | | - |
10 | | -dll_name=$(python -c 'import sysconfig; print(sysconfig.get_config_var("LDLIBRARY") or "")') |
11 | | -pkg_version=$(python -c 'import sysconfig; print(sysconfig.get_config_var("LDVERSION") or sysconfig.get_python_version())') |
12 | | -include_dir=$(python -c 'import sysconfig; print(sysconfig.get_config_var("INCLUDEPY") or "")') |
13 | | -base_prefix=$(python -c 'import sys; print(getattr(sys, "base_prefix", sys.prefix))') |
14 | | -python_bin=$(python -c 'import os, sys; print(os.path.dirname(sys.executable))') |
15 | | - |
16 | | -include_dir=${include_dir//\\//} |
17 | | -base_prefix=${base_prefix//\\//} |
18 | | -python_bin=${python_bin//\\//} |
19 | | - |
20 | | -if [ -z "$dll_name" ] || [ -z "$include_dir" ]; then |
21 | | - echo "Could not determine Python DLL or include dir" >&2 |
| 5 | +env_file=.local/cibw_before_build_windows_arm64.env |
| 6 | +if [ ! -f "$env_file" ]; then |
| 7 | + echo "Could not find $env_file" >&2 |
22 | 8 | exit 1 |
23 | 9 | fi |
24 | 10 |
|
25 | | -dll_path="" |
26 | | -for candidate in \ |
27 | | - "$python_bin/$dll_name" \ |
28 | | - "$base_prefix/$dll_name" \ |
29 | | - "$base_prefix/DLLs/$dll_name" \ |
30 | | - "$base_prefix/libs/$dll_name" |
31 | | -do |
32 | | - if [ -f "$candidate" ]; then |
33 | | - dll_path="$candidate" |
34 | | - break |
35 | | - fi |
36 | | -done |
| 11 | +# shellcheck disable=SC1090 |
| 12 | +. "$env_file" |
37 | 13 |
|
38 | | -if [ -z "$dll_path" ]; then |
39 | | - echo "Could not find $dll_name" >&2 |
40 | | - exit 1 |
| 14 | +lib_dir_msys="$LIB_DIR" |
| 15 | +pkgconfig_dir_msys="$PKGCONFIG_DIR" |
| 16 | +dll_path_msys="$DLL_PATH" |
| 17 | +if command -v cygpath >/dev/null 2>&1; then |
| 18 | + lib_dir_msys=$(cygpath -u "$LIB_DIR") |
| 19 | + pkgconfig_dir_msys=$(cygpath -u "$PKGCONFIG_DIR") |
| 20 | + dll_path_msys=$(cygpath -u "$DLL_PATH") |
41 | 21 | fi |
| 22 | +mkdir -p "$pkgconfig_dir_msys" |
42 | 23 |
|
43 | 24 | if ! command -v gendef >/dev/null 2>&1; then |
44 | 25 | echo "Could not find gendef on PATH" >&2 |
45 | 26 | exit 1 |
46 | 27 | fi |
47 | 28 |
|
| 29 | +dlltool= |
48 | 30 | if command -v cc >/dev/null 2>&1; then |
49 | 31 | dlltool=$(cc -print-prog-name=dlltool) |
50 | 32 | fi |
|
61 | 43 | exit 1 |
62 | 44 | fi |
63 | 45 |
|
64 | | -dll_stem=${dll_name%.dll} |
65 | | -def_path="$lib_dir/$dll_stem.def" |
66 | | -import_lib="$lib_dir/lib$dll_stem.dll.a" |
67 | | -pc_path="$pkgconfig_dir/python-$pkg_version.pc" |
| 46 | +dll_stem=${DLL_NAME%.dll} |
| 47 | +def_path_msys="$lib_dir_msys/$dll_stem.def" |
| 48 | +import_lib_msys="$lib_dir_msys/lib$dll_stem.dll.a" |
| 49 | +pc_path_msys="$pkgconfig_dir_msys/python-$PKG_VERSION.pc" |
68 | 50 |
|
69 | | -rm -f "$def_path" "$import_lib" |
| 51 | +rm -f "$def_path_msys" "$import_lib_msys" |
70 | 52 | ( |
71 | | - cd "$lib_dir" |
72 | | - gendef "$dll_path" |
| 53 | + cd "$lib_dir_msys" |
| 54 | + gendef "$dll_path_msys" |
73 | 55 | ) |
74 | | -"$dlltool" -d "$def_path" -D "$dll_name" -l "$import_lib" |
| 56 | +"$dlltool" -d "$def_path_msys" -D "$DLL_NAME" -l "$import_lib_msys" |
| 57 | + |
| 58 | +cat > "$pc_path_msys" <<EOF |
| 59 | +prefix=$REPO_ROOT |
| 60 | +exec_prefix=\${prefix} |
| 61 | +libdir=$LIB_DIR |
| 62 | +includedir=$INCLUDE_DIR |
75 | 63 |
|
76 | | -printf 'prefix=%s\n' "$repo_root" > "$pc_path" |
77 | | -printf 'exec_prefix=${prefix}\n' >> "$pc_path" |
78 | | -printf 'libdir=%s\n' "$lib_dir" >> "$pc_path" |
79 | | -printf 'includedir=%s\n\n' "$include_dir" >> "$pc_path" |
80 | | -printf 'Name: Python\n' >> "$pc_path" |
81 | | -printf 'Description: CPython import library for MinGW wheel builds\n' >> "$pc_path" |
82 | | -printf 'Version: %s\n' "$pkg_version" >> "$pc_path" |
83 | | -printf 'Libs: -L${libdir} -l%s\n' "$dll_stem" >> "$pc_path" |
84 | | -printf 'Cflags: -I${includedir}\n' >> "$pc_path" |
| 64 | +Name: Python |
| 65 | +Description: CPython import library for MinGW wheel builds |
| 66 | +Version: $PKG_VERSION |
| 67 | +Libs: -L\${libdir} -l$dll_stem |
| 68 | +Cflags: -I\${includedir} |
| 69 | +EOF |
85 | 70 |
|
86 | 71 | if command -v pkg-config >/dev/null 2>&1; then |
87 | | - pkg-config --exists "python-$pkg_version" |
| 72 | + pkg-config --exists "python-$PKG_VERSION" |
88 | 73 | fi |
89 | 74 |
|
90 | | -echo "Generated $import_lib" |
91 | | -echo "Generated $pc_path" |
| 75 | +echo "Generated $import_lib_msys" |
| 76 | +echo "Generated $pc_path_msys" |
0 commit comments