Skip to content

Commit 7d17c87

Browse files
authored
caching pip dependencies (#617)
caching pip dependencies and uusing ninja on windows.
1 parent 946149d commit 7d17c87

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

.github/workflows/cmake_ci.yml

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ jobs:
1515
run: |
1616
MATRIX=$(python3 ${{ github.workspace }}/.github/workflows/generate_cmake_matrix.py)
1717
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
18+
pip-requirements:
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
cache : 'pip'
27+
python-version: '3.10'
28+
- name: Generate requirements.txt
29+
run: |
30+
pip install --upgrade pip
31+
pip install pip-tools
32+
pip-compile --all-build-deps python/finufft/pyproject.toml -o requirements.txt
33+
echo pytest >> requirements.txt
34+
sed -i -E 's/(==|>=|<=|>|<|~=|!=).*//' requirements.txt
35+
cat requirements.txt
36+
- name: Upload requirements.txt
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: requirements
40+
path: requirements.txt
1841
cache:
1942
strategy:
2043
matrix:
@@ -28,6 +51,13 @@ jobs:
2851
- name: create cache directory
2952
run: |
3053
mkdir -p cpm
54+
- name: Check if cache exists
55+
id: cache
56+
uses: actions/cache@v4
57+
with:
58+
key: cpm-cache-00-${{ hashFiles('CMakeLists.txt', 'cmake/*') }}
59+
enableCrossOsArchive: true
60+
path: cpm
3161
- name: Setup Cpp
3262
if: steps.cache.outputs.cache-hit != 'true'
3363
uses: aminya/setup-cpp@v1
@@ -57,7 +87,7 @@ jobs:
5787
path: cpm
5888
cmake-ci:
5989
runs-on: ${{ matrix.os }}
60-
needs: [prepare, cache]
90+
needs: [prepare, cache, pip-requirements]
6191
strategy:
6292
fail-fast: false
6393
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
@@ -70,6 +100,10 @@ jobs:
70100
key: cpm-cache-00-${{ hashFiles('CMakeLists.txt', 'cmake/*') }}
71101
enableCrossOsArchive: true
72102
path: cpm
103+
- name: Download requirements.txt
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: requirements
73107
- name: Run sccache-cache only on non-release runs
74108
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
75109
uses: mozilla-actions/[email protected]
@@ -105,41 +139,45 @@ jobs:
105139
- name: Build
106140
run: |
107141
cmake --build ./build --config ${{matrix.build_type}}
108-
109142
- name: Test
110143
working-directory: ./build
111144
run: |
112145
ctest -C ${{matrix.build_type}} --output-on-failure
113-
114146
- name: Set up Python
115147
if: matrix.finufft_static_linking == 'off'
116148
uses: actions/setup-python@v5
117149
with:
118150
python-version: '3.10'
119-
151+
cache: 'pip'
152+
cache-dependency-path: requirements.txt
120153
- name: Build Python wheels
121154
if: matrix.finufft_static_linking == 'off'
122155
env:
123156
MACOSX_DEPLOYMENT_TARGET: 13
124157
CPM_SOURCE_CACHE: cpm
125158
shell: bash
126159
run: |
160+
python3 -m pip install --upgrade pip
161+
python3 -m pip install -r requirements.txt
127162
python3 -m pip install \
128163
--verbose \
129164
-C cmake.define.CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
130165
-C cmake.define.FINUFFT_ARCH_FLAGS=${{ matrix.arch_flags }} \
131166
-C cmake.define.FINUFFT_USE_DUCC0=${{ matrix.ducc_fft }} \
132167
-C cmake.define.CMAKE_CXX_COMPILER_LAUNCHER=sccache \
133168
-C cmake.define.CMAKE_C_COMPILER_LAUNCHER=sccache \
169+
-C cmake.define.CMAKE_GENERATOR=Ninja \
170+
-C cmake.define.CMAKE_GENERATOR_PLATFORM= \
134171
python/finufft
135-
136-
- name: Install pytest
137-
if: matrix.finufft_static_linking == 'off'
138-
run: |
139-
python3 -m pip install --upgrade pip
140-
python3 -m pip install pytest
141-
142172
- name: Test Python package
143173
if: matrix.finufft_static_linking == 'off'
144174
run: |
145175
python3 -m pytest python/finufft/test
176+
cleanup:
177+
runs-on: ubuntu-22.04
178+
needs: cmake-ci
179+
steps:
180+
- name: Artifact cleanup
181+
uses: geekyeggo/delete-artifact@v5
182+
with:
183+
name: requirements

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ List of features / changes made / release notes, in reverse chronological order.
22
If not stated, FINUFFT is assumed (cuFINUFFT <=1.3 is listed separately).
33

44
Master, using release name V 2.4.0 (1/7/25)
5+
* PR617: Caching pip dependencies in github actions.
6+
Forcing Ninja when building python on Windows.
57
* PR614: Added support for sccache in github actions.
68
Caching cmake dependencies so to avoid downloading fftw, xsimd, etc. every time.
79
* fully removed chkbnds option (opts and spreadopts) (Barnett)

0 commit comments

Comments
 (0)