Skip to content

Commit 50f8176

Browse files
committed
fix: build linux CLI in manylinux container to avoid GLIBC mismatch; auto-recreate spec
1 parent 948f46b commit 50f8176

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ poetry.lock
6363
**/.DS_Store
6464
.DS_Store
6565

66-
artifacts/
66+
artifacts/
67+
cli/nixopus.spec

cli/build.sh

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
set -e
44

5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
cd "$SCRIPT_DIR"
7+
58
RED='\033[0;31m'
69
GREEN='\033[0;32m'
710
YELLOW='\033[1;33m'
@@ -136,6 +139,52 @@ EOF
136139
log_success "Spec file created: $SPEC_FILE"
137140
}
138141

142+
run_pyinstaller_build() {
143+
# Ensure spec file exists even if manually deleted
144+
if [[ ! -f "$SPEC_FILE" ]]; then
145+
log_warning "Spec file missing; regenerating..."
146+
create_spec_file
147+
fi
148+
149+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
150+
ARCH=$(uname -m)
151+
152+
if [[ "$OS" == "linux" ]] && command -v docker &> /dev/null && [[ -z "$NIXOPUS_DISABLE_DOCKER" ]]; then
153+
case $ARCH in
154+
x86_64)
155+
MANYLINUX_IMAGE="quay.io/pypa/manylinux2014_x86_64"
156+
PYTAG="cp311-cp311"
157+
;;
158+
aarch64|arm64)
159+
MANYLINUX_IMAGE="quay.io/pypa/manylinux2014_aarch64"
160+
PYTAG="cp311-cp311"
161+
;;
162+
*)
163+
MANYLINUX_IMAGE=""
164+
;;
165+
esac
166+
167+
if [[ -n "$MANYLINUX_IMAGE" ]]; then
168+
log_info "Building with PyInstaller inside $MANYLINUX_IMAGE for wide glibc compatibility..."
169+
docker run --rm -v "$PWD":/work -w /work "$MANYLINUX_IMAGE" bash -lc \
170+
"export PATH=/opt/python/$PYTAG/bin:\$PATH && \
171+
python3 -m pip install -U pip && \
172+
python3 -m pip install 'poetry==1.8.3' && \
173+
poetry install --with dev && \
174+
poetry run pyinstaller --clean --noconfirm $SPEC_FILE" || {
175+
log_error "Dockerized build failed"
176+
exit 1
177+
}
178+
return
179+
fi
180+
181+
log_warning "Unsupported arch $ARCH for manylinux; building on host (may require newer glibc)"
182+
fi
183+
184+
log_info "Building with PyInstaller on host..."
185+
poetry run pyinstaller --clean --noconfirm $SPEC_FILE
186+
}
187+
139188
build_wheel() {
140189
log_info "Building wheel package..."
141190

@@ -147,7 +196,7 @@ build_wheel() {
147196
build_binary() {
148197
log_info "Building binary"
149198

150-
poetry run pyinstaller --clean --noconfirm $SPEC_FILE
199+
run_pyinstaller_build
151200

152201
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
153202
ARCH=$(uname -m)

0 commit comments

Comments
 (0)