3232 name : dist-sdist
3333 path : dist/*
3434
35- wheels-linux :
36- name : Build Linux wheels (x86_64, aarch64)
35+ # ----- Linux x86_64 (native) -----
36+ wheels-linux-x86_64 :
37+ name : Build Linux wheels (x86_64)
3738 runs-on : ubuntu-latest
3839 permissions :
3940 contents : read
@@ -42,44 +43,157 @@ jobs:
4243 with :
4344 fetch-depth : 0
4445
45- # Enable QEMU so aarch64 manylinux containers can run on x86_64 runners
46- - name : Enable QEMU for cross-arch builds
47- uses : docker/setup-qemu-action@v3
46+ # Cache compiled objects across ABIs & runs
47+ - name : Restore ccache
48+ uses : actions/cache@v4
4849 with :
49- platforms : arm64
50+ path : .ccache
51+ key : ccache-linux-x86_64-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', '**/*.cpp', '**/*.h', 'pyproject.toml') }}
5052
51- - name : Build wheels with cibuildwheel
53+ # Cache third-party source tarballs so BEFORE_ALL can just extract
54+ - name : Restore 3rdparty source cache
55+ uses : actions/cache@v4
56+ with :
57+ path : build-cache
58+ key : thirdparty-src-x86_64-fftw-3.3.10-boost-1_84_0
59+
60+ - name : Pre-fetch Boost/FFTW (host)
61+ run : |
62+ set -eux
63+ mkdir -p build-cache
64+ # FFTW
65+ test -f build-cache/fftw-3.3.10.tar.gz || \
66+ curl -fsSL -o build-cache/fftw-3.3.10.tar.gz http://www.fftw.org/fftw-3.3.10.tar.gz
67+ # Boost headers
68+ test -f build-cache/boost_1_84_0.tar.gz || \
69+ curl -fsSL -o build-cache/boost_1_84_0.tar.gz https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz
70+
71+ - name : Build wheels with cibuildwheel (x86_64)
5272 uses : pypa/cibuildwheel@v2.21.3
5373 env :
5474 CIBW_BUILD : cp310-* cp311-* cp312-*
5575 CIBW_SKIP : pp* *-musllinux_*
56- CIBW_ARCHS_LINUX : x86_64 aarch64
76+ CIBW_ARCHS_LINUX : x86_64
5777 CIBW_MANYLINUX_X86_64_IMAGE : manylinux_2_28
78+ CIBW_BEFORE_ALL_LINUX : |
79+ set -eux
80+ # Install ccache and minimal build deps in the manylinux container
81+ if command -v dnf >/dev/null 2>&1; then
82+ dnf -y install ccache pkgconfig ninja-build || true
83+ elif command -v yum >/dev/null 2>&1; then
84+ yum -y install ccache pkgconfig ninja-build || true
85+ fi
86+
87+ # Extract cached sources from /project (mounted by cibuildwheel)
88+ mkdir -p /opt/fftw /opt/boost/include
89+ tar -xzf /project/build-cache/fftw-3.3.10.tar.gz -C /tmp
90+ tar -xzf /project/build-cache/boost_1_84_0.tar.gz -C /tmp
91+
92+ # Build FFTW (shared, threads; no fortran/mpi)
93+ pushd /tmp/fftw-3.3.10
94+ ./configure --prefix=/opt/fftw --enable-shared --enable-threads --disable-fortran --disable-mpi
95+ make -j"$(nproc)"
96+ make install
97+ popd
98+
99+ # Header-only Boost "install"
100+ cp -r /tmp/boost_1_84_0/boost /opt/boost/include/
101+ CIBW_ENVIRONMENT_LINUX : >
102+ PKG_CONFIG_PATH=/opt/fftw/lib/pkgconfig
103+ CMAKE_PREFIX_PATH=/opt/fftw
104+ CCACHE_DIR=/project/.ccache
105+ CMAKE_ARGS="-G Ninja -DHF_USE_OPENMP=ON -DHF_USE_FFTW_THREADS=ON -DBOOST_INCLUDE_DIR=/opt/boost/include -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
106+ CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
107+ CIBW_REPAIR_WHEEL_COMMAND_LINUX : >
108+ bash -lc 'LD_LIBRARY_PATH=/opt/fftw/lib auditwheel repair -w {dest_dir} {wheel}'
109+ CIBW_TEST_REQUIRES : numpy
110+ CIBW_TEST_COMMAND : |
111+ python - <<'PY'
112+ import numpy as np, cpp_hf
113+ nk,d=4,2
114+ w=np.ones((nk,nk))*((2/nk)*(2/nk)/(2*np.pi)**2)
115+ H=np.zeros((nk,nk,d,d),np.complex128)
116+ K=np.linspace(-1,1,nk)
117+ V=(1.0/np.sqrt((K[:,None]**2+K[None,:]**2)+0.2)).astype(np.complex128)[...,None,None]
118+ P0=np.zeros_like(H)
119+ ne=0.5*d*w.sum()
120+ P,F,E,mu,n=cpp_hf.hartreefock_iteration_cpp(w,H,V,P0,ne,0.2,1,1e-2,2,1.0)
121+ print("wheel ok", int(n), float(mu))
122+ PY
123+
124+ - name : Upload Linux x86_64 wheels
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : dist-wheels-linux-x86_64
128+ path : wheelhouse/*
129+ if-no-files-found : error
130+
131+ # ----- Linux aarch64 (native ARM runner) -----
132+ wheels-linux-aarch64 :
133+ name : Build Linux wheels (aarch64 — native)
134+ # For public repos you can use ubuntu-24.04-arm / ubuntu-22.04-arm.
135+ # For private repos, switch to your self-hosted arm64 runner label.
136+ runs-on : ubuntu-24.04-arm
137+ permissions :
138+ contents : read
139+ steps :
140+ - uses : actions/checkout@v4
141+ with :
142+ fetch-depth : 0
143+
144+ - name : Restore ccache
145+ uses : actions/cache@v4
146+ with :
147+ path : .ccache
148+ key : ccache-linux-arm64-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', '**/*.cpp', '**/*.h', 'pyproject.toml') }}
149+
150+ - name : Restore 3rdparty source cache
151+ uses : actions/cache@v4
152+ with :
153+ path : build-cache
154+ key : thirdparty-src-arm64-fftw-3.3.10-boost-1_84_0
155+
156+ - name : Pre-fetch Boost/FFTW (host)
157+ run : |
158+ set -eux
159+ mkdir -p build-cache
160+ test -f build-cache/fftw-3.3.10.tar.gz || \
161+ curl -fsSL -o build-cache/fftw-3.3.10.tar.gz http://www.fftw.org/fftw-3.3.10.tar.gz
162+ test -f build-cache/boost_1_84_0.tar.gz || \
163+ curl -fsSL -o build-cache/boost_1_84_0.tar.gz https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz
164+
165+ - name : Build wheels with cibuildwheel (aarch64)
166+ uses : pypa/cibuildwheel@v2.21.3
167+ env :
168+ CIBW_BUILD : cp310-* cp311-* cp312-*
169+ CIBW_SKIP : pp* *-musllinux_*
170+ CIBW_ARCHS_LINUX : aarch64
58171 CIBW_MANYLINUX_AARCH64_IMAGE : manylinux_2_28
59172 CIBW_BEFORE_ALL_LINUX : |
60173 set -eux
61- if command -v yum >/dev/null 2>&1; then
62- yum -y install pkgconfig || true
174+ if command -v dnf >/dev/null 2>&1; then
175+ dnf -y install ccache pkgconfig ninja-build || true
176+ elif command -v yum >/dev/null 2>&1; then
177+ yum -y install ccache pkgconfig ninja-build || true
63178 fi
64- FFTW_V=3.3.10
65- curl -fsSL -o fftw.tar.gz http://www.fftw.org/fftw-${FFTW_V}.tar.gz
66- tar -xzf fftw.tar.gz
67- pushd fftw-${FFTW_V}
68- ./configure --prefix=/opt/fftw --enable-shared --enable-threads
179+
180+ mkdir -p /opt/fftw /opt/boost/include
181+ tar -xzf /project/build-cache/fftw-3.3.10.tar.gz -C /tmp
182+ tar -xzf /project/build-cache/boost_1_84_0.tar.gz -C /tmp
183+
184+ pushd /tmp/fftw-3.3.10
185+ ./configure --prefix=/opt/fftw --enable-shared --enable-threads --disable-fortran --disable-mpi
69186 make -j"$(nproc)"
70187 make install
71188 popd
72189
73- BOOST_U=1_84_0
74- BOOST_D=1.84.0
75- curl -fsSL -o boost.tar.gz https://archives.boost.io/release/${BOOST_D}/source/boost_${BOOST_U}.tar.gz
76- tar -xzf boost.tar.gz
77- mkdir -p /opt/boost/include
78- cp -r boost_${BOOST_U}/boost /opt/boost/include/
190+ cp -r /tmp/boost_1_84_0/boost /opt/boost/include/
79191 CIBW_ENVIRONMENT_LINUX : >
80192 PKG_CONFIG_PATH=/opt/fftw/lib/pkgconfig
81193 CMAKE_PREFIX_PATH=/opt/fftw
82- CMAKE_ARGS="-DHF_USE_OPENMP=ON -DHF_USE_FFTW_THREADS=ON -DBOOST_INCLUDE_DIR=/opt/boost/include"
194+ CCACHE_DIR=/project/.ccache
195+ CMAKE_ARGS="-G Ninja -DHF_USE_OPENMP=ON -DHF_USE_FFTW_THREADS=ON -DBOOST_INCLUDE_DIR=/opt/boost/include -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
196+ CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
83197 CIBW_REPAIR_WHEEL_COMMAND_LINUX : >
84198 bash -lc 'LD_LIBRARY_PATH=/opt/fftw/lib auditwheel repair -w {dest_dir} {wheel}'
85199 CIBW_TEST_REQUIRES : numpy
@@ -97,13 +211,14 @@ jobs:
97211 print("wheel ok", int(n), float(mu))
98212 PY
99213
100- - name : Upload Linux wheels
214+ - name : Upload Linux aarch64 wheels
101215 uses : actions/upload-artifact@v4
102216 with :
103- name : dist-wheels-linux
217+ name : dist-wheels-linux-aarch64
104218 path : wheelhouse/*
105219 if-no-files-found : error
106220
221+ # ----- macOS (Intel/Apple Silicon) -----
107222 wheels-macos :
108223 name : Build macOS wheels (Intel/Apple Silicon)
109224 strategy :
@@ -160,9 +275,10 @@ jobs:
160275 path : wheelhouse/*
161276 if-no-files-found : error
162277
278+ # ----- Publish to PyPI -----
163279 publish :
164280 name : Publish to PyPI
165- needs : [sdist, wheels-linux, wheels-macos]
281+ needs : [sdist, wheels-linux-x86_64, wheels-linux-aarch64 , wheels-macos]
166282 runs-on : ubuntu-latest
167283 # 🔐 Ensure the OIDC token includes the environment claim
168284 environment : cpp_hf_env
0 commit comments