Skip to content

Commit df000c9

Browse files
committed
a fix to build script
1 parent 3e62404 commit df000c9

1 file changed

Lines changed: 67 additions & 6 deletions

File tree

scripts/build-wheels.sh

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,48 @@ resolve_path() {
4343
fi
4444
}
4545

46+
target_python_request() {
47+
local version="$1"
48+
local target="$2"
49+
local arch=""
50+
local os=""
51+
local libc=""
52+
53+
case "$target" in
54+
x86_64-unknown-linux-gnu)
55+
arch="x86_64"
56+
os="linux"
57+
libc="gnu"
58+
;;
59+
aarch64-apple-darwin)
60+
arch="aarch64"
61+
os="macos"
62+
libc="none"
63+
;;
64+
x86_64-apple-darwin)
65+
arch="x86_64"
66+
os="macos"
67+
libc="none"
68+
;;
69+
x86_64-pc-windows-msvc)
70+
arch="x86_64"
71+
os="windows"
72+
libc="none"
73+
;;
74+
aarch64-pc-windows-msvc)
75+
arch="aarch64"
76+
os="windows"
77+
libc="none"
78+
;;
79+
*)
80+
printf '%s\n' "$version"
81+
return 0
82+
;;
83+
esac
84+
85+
printf 'cpython-%s-%s-%s-%s\n' "$version" "$os" "$arch" "$libc"
86+
}
87+
4688
OUTPUT_DIR="$DEFAULT_OUTPUT_DIR"
4789
INSTALL_PYTHONS=1
4890
RUST_TARGET="${RSLOOP_RUST_TARGET:-}"
@@ -99,21 +141,40 @@ cd "$ROOT_DIR"
99141
mkdir -p "$OUTPUT_DIR"
100142

101143
if (( INSTALL_PYTHONS )); then
102-
echo "Installing Python interpreters with uv: ${PYTHON_VERSIONS[*]}"
103-
uv python install "${PYTHON_VERSIONS[@]}"
144+
if [[ -n "$RUST_TARGET" ]]; then
145+
python_requests=()
146+
for version in "${PYTHON_VERSIONS[@]}"; do
147+
python_requests+=("$(target_python_request "$version" "$RUST_TARGET")")
148+
done
149+
echo "Installing Python interpreters with uv for ${RUST_TARGET}: ${python_requests[*]}"
150+
uv python install "${python_requests[@]}"
151+
else
152+
echo "Installing Python interpreters with uv: ${PYTHON_VERSIONS[*]}"
153+
uv python install "${PYTHON_VERSIONS[@]}"
154+
fi
104155
fi
105156

106157
for version in "${PYTHON_VERSIONS[@]}"; do
107-
interpreter="$(uv python find "$version")"
108-
echo "Building release wheel for Python ${version} (${interpreter})"
158+
python_request="$version"
159+
interpreter_selector=""
160+
161+
if [[ -n "$RUST_TARGET" ]]; then
162+
python_request="$(target_python_request "$version" "$RUST_TARGET")"
163+
interpreter_selector="python${version}"
164+
echo "Building release wheel for Python ${version} targeting ${RUST_TARGET} (${python_request})"
165+
else
166+
interpreter_selector="$(uv python find "$version")"
167+
echo "Building release wheel for Python ${version} (${interpreter_selector})"
168+
fi
169+
109170
maturin_cmd=(
110171
uv run
111172
--no-project
112-
--python "$interpreter"
173+
--python "$python_request"
113174
--with maturin
114175
maturin build
115176
--release
116-
--interpreter "$interpreter"
177+
--interpreter "$interpreter_selector"
117178
--out "$OUTPUT_DIR"
118179
)
119180
if [[ -n "$RUST_TARGET" ]]; then

0 commit comments

Comments
 (0)