Skip to content

Commit 3362d9f

Browse files
committed
Use exact core count in parallel builds
1 parent af74046 commit 3362d9f

File tree

8 files changed

+22
-3
lines changed

8 files changed

+22
-3
lines changed

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ jobs:
4545
working_directory: buildconfig/manylinux-build/docker_base
4646
command: docker build -t manylinux2014_base_aarch64 -f Dockerfile-aarch64 .
4747

48+
- run:
49+
name: Substitute core count in pip config file for speed
50+
command: sed -i "s/{nproc}/$(nproc)/g" buildconfig/pip_config.ini
51+
4852
- run:
4953
name: Build the Linux wheels.
5054
command: |

.github/workflows/build-debian-multiarch.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
# Build a wheel, install it for running unit tests
8484
run: |
8585
export PIP_CONFIG_FILE=buildconfig/pip_config.ini
86+
echo "\nSubstituting core count in pip config file for speed\n"
87+
sed -i "s/{nproc}/$(nproc)/g" $PIP_CONFIG_FILE
8688
echo "\nBuilding pygame wheel\n"
8789
python3 setup.py docs
8890
pip3 wheel . --wheel-dir /artifacts -vvv

.github/workflows/build-macos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ jobs:
181181
key: macdep-${{ hashFiles('buildconfig/manylinux-build/**') }}-${{ hashFiles('buildconfig/macdependencies/*.sh') }}-${{ matrix.macarch }}
182182
fail-on-cache-miss: true
183183

184+
- name: Substitute core count in pip config file for speed
185+
run: sed -i '' "s/{nproc}/$(sysctl -n hw.logicalcpu)/g" buildconfig/pip_config.ini
186+
184187
- name: Build and test wheels
185188
uses: pypa/cibuildwheel@v2.16.4
186189

.github/workflows/build-manylinux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ jobs:
110110
tags: ${{ steps.meta.outputs.tags }}
111111
labels: ${{ steps.meta.outputs.labels }}
112112

113+
- name: Substitute core count in pip config file for speed
114+
run: sed -i "s/{nproc}/$(nproc)/g" buildconfig/pip_config.ini
115+
113116
- name: Build and test wheels
114117
env:
115118
# set custom pygame images

.github/workflows/build-ubuntu-sdist.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
env:
7070
PIP_CONFIG_FILE: "buildconfig/pip_config.ini"
7171
run: |
72+
# Substitute core count in pip config file for speed
73+
sed -i "s/{nproc}/$(nproc)/g" $PIP_CONFIG_FILE
7274
python3 setup.py docs
7375
python3 setup.py sdist
7476
pip3 install dist/pygame-*.tar.gz -vv

.github/workflows/build-windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ jobs:
151151
- uses: TheMrMilchmann/setup-msvc-dev@v3 # this lets us use the developer command prompt on windows
152152
with:
153153
arch: ${{ matrix.msvc-dev-arch }}
154+
155+
- name: Substitute core count in pip config file for speed
156+
shell: bash
157+
run: sed -i "s/{nproc}/$(nproc)/g" buildconfig/pip_config.ini
158+
154159
- name: Build and test wheels
155160
shell: cmd
156161
run: |

buildconfig/macdependencies/build_mac_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export PKG_CONFIG_PATH="$PG_DEP_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
1616
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
1717

1818
# for great speed.
19-
export MAKEFLAGS="-j 4"
19+
export MAKEFLAGS="-j $(sysctl -n hw.logicalcpu)"
2020

2121
# With this we
2222
# 1) Force install prefix to $PG_DEP_PREFIX

buildconfig/pip_config.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[wheel]
55

66
# preserve this multiline assignment to register these args as distinct
7-
# use -j3 to use 3 cores, most CI machines have either 2 or 3 cores
7+
# {nproc} gets substituted to the number of cores when this file is used.
88
global-option =
99
build_ext
10-
-j3
10+
-j{nproc}

0 commit comments

Comments
 (0)