@@ -93,11 +93,11 @@ jobs:
9393 build-python-wheels :
9494 name : Build Python wheels on ${{ matrix.os }}
9595 runs-on : ${{ matrix.os }}
96- # needs: [test-go, test-python]
96+ # needs: [ test-go, test-python ]
9797 strategy :
9898 matrix :
9999 # Must use different OS runners for binary compatibility
100- os : [ubuntu-latest, macos-latest, windows-latest]
100+ os : [ ubuntu-latest, macos-latest, windows-latest ]
101101 fail-fast : false # Don't cancel other jobs if one fails
102102
103103 steps :
@@ -125,77 +125,82 @@ jobs:
125125 go mod verify
126126
127127 # Linux-specific build
128+ - name : Pre-build Go library (Linux)
129+ if : runner.os == 'Linux'
130+ run : |
131+ # Build the Go library on the host before running cibuildwheel
132+ CGO_ENABLED=1 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.so ./pkg/bindings
133+ ls -la python/spl_toolkit/
134+ file python/spl_toolkit/*.so
135+
128136 - name : Build wheels (Linux)
129137 if : runner.os == 'Linux'
130138 env :
131139 CIBW_BUILD : " cp3{8,9,10,11,12}-*" # All Python versions at once
132140 CIBW_SKIP : " *-musllinux* *-manylinux_i686"
133141 CIBW_ARCHS_LINUX : " x86_64" # Add "aarch64" if you need ARM support
134142 CIBW_MANYLINUX_X86_64_IMAGE : " manylinux_2_28"
135- CIBW_BEFORE_ALL_LINUX : |
136- # Install Go in the container
137- curl -L https://go.dev/dl/go${{ env.GO_VERSION }}.linux-amd64.tar.gz -o /tmp/go.tar.gz
138- tar -C /opt -xzf /tmp/go.tar.gz
139- export PATH=/opt/go/bin:$PATH
140- go version
141143 CIBW_BEFORE_BUILD_LINUX : |
142- export PATH=/opt/go/bin:$PATH
143- export CGO_ENABLED=1
144- cd {project}
145- go mod download
146- go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.so ./pkg/bindings
147- ls -la python/spl_toolkit/*.so
144+ # Library is already built, just verify it exists
145+ ls -la {project}/spl_toolkit/*.so
146+ file {project}/spl_toolkit/*.so
148147 CIBW_REPAIR_WHEEL_COMMAND_LINUX : " auditwheel repair -w {dest_dir} {wheel}"
149148 CIBW_TEST_COMMAND : " python -c 'import spl_toolkit'"
149+ CIBW_ENVIRONMENT_LINUX : " CIBUILDWHEEL=1"
150150 run : |
151151 cd python
152152 python -m cibuildwheel --output-dir ../dist
153153
154154 # macOS-specific build (Universal2 for both Intel and Apple Silicon)
155+ - name : Pre-build Go library (macOS)
156+ if : runner.os == 'macOS'
157+ run : |
158+ # Build universal binary for macOS
159+ CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit_amd64.dylib ./pkg/bindings
160+ CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit_arm64.dylib ./pkg/bindings
161+ lipo -create python/spl_toolkit/libspl_toolkit_amd64.dylib python/spl_toolkit/libspl_toolkit_arm64.dylib -output python/spl_toolkit/libspl_toolkit.dylib
162+ rm python/spl_toolkit/libspl_toolkit_amd64.dylib python/spl_toolkit/libspl_toolkit_arm64.dylib
163+ ls -la python/spl_toolkit/
164+ file python/spl_toolkit/*.dylib
165+
155166 - name : Build wheels (macOS)
156167 if : runner.os == 'macOS'
157168 env :
158169 CIBW_BUILD : " cp3{8,9,10,11,12}-*"
159170 CIBW_SKIP : " *-musllinux*"
160171 CIBW_ARCHS_MACOS : " x86_64 arm64 universal2" # Build for all architectures
161172 CIBW_BEFORE_BUILD_MACOS : |
162- export CGO_ENABLED=1
163- cd {project}
164- go mod download
165- # Build architecture-specific library
166- if [[ "$ARCHFLAGS" == *"arm64"* ]]; then
167- GOARCH=arm64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.dylib ./pkg/bindings
168- elif [[ "$ARCHFLAGS" == *"x86_64"* ]]; then
169- GOARCH=amd64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.dylib ./pkg/bindings
170- else
171- # Universal build - create both and combine
172- GOARCH=amd64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit_x86_64.dylib ./pkg/bindings
173- GOARCH=arm64 go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit_arm64.dylib ./pkg/bindings
174- lipo -create python/spl_toolkit/libspl_toolkit_x86_64.dylib python/spl_toolkit/libspl_toolkit_arm64.dylib -output python/spl_toolkit/libspl_toolkit.dylib
175- rm python/spl_toolkit/libspl_toolkit_x86_64.dylib python/spl_toolkit/libspl_toolkit_arm64.dylib
176- fi
177- ls -la python/spl_toolkit/*.dylib
173+ # Library is already built, just verify it exists
174+ ls -la {project}/spl_toolkit/*.dylib
175+ file {project}/spl_toolkit/*.dylib
178176 CIBW_REPAIR_WHEEL_COMMAND_MACOS : " delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
179177 CIBW_TEST_COMMAND : " python -c 'import spl_toolkit'"
180178 CIBW_TEST_SKIP : " *-macosx_arm64 *-macosx_universal2:arm64" # Skip ARM tests on x86 runners
179+ CIBW_ENVIRONMENT_MACOS : " CIBUILDWHEEL=1"
181180 run : |
182181 cd python
183182 python -m cibuildwheel --output-dir ../dist
184183
185184 # Windows-specific build
185+ - name : Pre-build Go library (Windows)
186+ if : runner.os == 'Windows'
187+ run : |
188+ # Build the Go library on the host before running cibuildwheel
189+ $env:CGO_ENABLED = "1"
190+ go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.dll ./pkg/bindings
191+ dir python\spl_toolkit\
192+
186193 - name : Build wheels (Windows)
187194 if : runner.os == 'Windows'
188195 env :
189196 CIBW_BUILD : " cp3{8,9,10,11,12}-*"
190197 CIBW_SKIP : " *-musllinux* *-win32"
191198 CIBW_ARCHS_WINDOWS : " AMD64"
192199 CIBW_BEFORE_BUILD_WINDOWS : |
193- cd {project}
194- go mod download
195- set CGO_ENABLED=1
196- go build -buildmode=c-shared -o python\spl_toolkit\libspl_toolkit.dll .\pkg\bindings
197- dir python\spl_toolkit\*.dll
200+ # Library is already built, just verify it exists
201+ dir {project}\spl_toolkit\*.dll
198202 CIBW_TEST_COMMAND : " python -c \" import spl_toolkit\" "
203+ CIBW_ENVIRONMENT_WINDOWS : " CIBUILDWHEEL=1"
199204 run : |
200205 cd python
201206 python -m cibuildwheel --output-dir ../dist
0 commit comments