Skip to content

Commit e62ba96

Browse files
authored
ci: build in Release mode and improve compilation with multi-threading (#13)
Signed-off-by: Michele Dolfi <[email protected]>
1 parent 40a3a0c commit e62ba96

File tree

6 files changed

+17
-23
lines changed

6 files changed

+17
-23
lines changed

.github/actions/setup-deps/action.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/actions/setup-poetry/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ runs:
1414
with:
1515
python-version: ${{ inputs.python-version }}
1616
cache: 'poetry'
17-
- name: Install dependencies
18-
run: poetry install --all-extras
17+
- name: Install only dependencies and not the package itself
18+
run: poetry install --all-extras --no-root
1919
shell: bash

.github/workflows/checks.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
on:
22
workflow_call:
33

4+
env:
5+
CMAKE_BUILD_TYPE: Debug
6+
47
jobs:
58
run-checks:
69
runs-on: ubuntu-latest
@@ -18,10 +21,9 @@ jobs:
1821
- name: Run styling check
1922
run: poetry run pre-commit run --all-files
2023
- name: Install with poetry
21-
run: poetry install
24+
run: poetry install --all-extras
2225
- name: Testing
2326
run: |
2427
poetry run pytest -v tests
2528
- name: Build with poetry
2629
run: poetry build
27-

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ on:
1515
env:
1616
# disable keyring (https://github.com/actions/runner-images/issues/6185):
1717
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
18-
BUILD_TYPE: Release
1918

2019
jobs:
2120
code-checks:

.github/workflows/wheels.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
on:
22
workflow_call:
33

4+
env:
5+
CMAKE_BUILD_TYPE: Release
6+
47
jobs:
58
build_wheels:
69
name: Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }} ${{ matrix.os.macos_version }}
@@ -47,11 +50,6 @@ jobs:
4750
with:
4851
python-version: ${{ matrix.python-version }}
4952

50-
# - name: Install dependencies [linux]
51-
# if: matrix.os.platform == 'linux'
52-
# run: sudo apt-get install -y libldap-common
53-
# shell: bash
54-
5553
- name: Install poetry
5654
run: pipx install poetry==1.8.3 --python $(which python3)
5755
shell: bash
@@ -86,6 +84,7 @@ jobs:
8684
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
8785
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
8886
ARCHFLAGS: -arch x86_64
87+
BUILD_THREADS: "4"
8988
run: |
9089
echo "Building wheel ${CIBW_BUILD}"
9190
poetry run python --version
@@ -122,6 +121,7 @@ jobs:
122121
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
123122
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
124123
ARCHFLAGS: -arch arm64
124+
BUILD_THREADS: "4"
125125
run: |
126126
echo "Building wheel ${CIBW_BUILD}"
127127
poetry run python --version
@@ -164,6 +164,7 @@ jobs:
164164
CIBW_SKIP: "pp* *musllinux_* *_i686* *_s390*"
165165
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
166166
CIBW_BUILD_VERBOSITY: 3
167+
BUILD_THREADS: "8"
167168
run: |
168169
echo "Building wheel ${CIBW_BUILD}"
169170
poetry run python --version

build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run(cmd, cwd="./"):
2525
return False
2626

2727

28-
def build_local(multi_threaded=True):
28+
def build_local(num_threads: int):
2929

3030
if not os.path.exists(BUILD_DIR):
3131
print("python executable: ", sys.executable)
@@ -38,13 +38,13 @@ def build_local(multi_threaded=True):
3838
print(f"build directory detected: {BUILD_DIR}")
3939

4040
cmd = f"cmake --build {BUILD_DIR} --target install"
41-
if multi_threaded:
42-
cmd += " -j 4"
41+
if num_threads > 1:
42+
cmd += f" -j {num_threads}"
4343
success = run(cmd, cwd=ROOT_DIR)
4444
if not success:
4545
raise RuntimeError("Error building.")
4646

4747

4848
if "__main__" == __name__:
49-
50-
build_local(multi_threaded=False)
49+
num_threads = int(os.getenv("BUILD_THREADS", "4"))
50+
build_local(num_threads=num_threads)

0 commit comments

Comments
 (0)