Skip to content

Commit d1bd9b3

Browse files
Mizuxcopybara-github
authored andcommitted
deep rework (mostly ci and build system)
# Fix * Fix `absl::monostate` support against C++14 * Fix `MSVC C2466` compilation error ref: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2466 * Fix `bazel test -c opt` run # CMake * Bump CMake minimal version to 3.18 to align with pybind11_protobuf and needed to work with pypa/manylinux image (ed need `Development.Module` option in `FindPython3`) * rename `status` as `status_py_extension_stub` target to avoid conflict with abseil-cpp when fetched (ed cmake target are NOT scoped)<br> note: still provide the `pybind11_abseil::status` target alias. * Disable C++ gnu extension. * Rework third party management * disable test for dependencies BUT still allow to enable them for pybind11_abseil * Bump abseil-cpp from `20230802.0` to `20240722.0` * Bump pybind11 from master(floating) to `v2.13.6` * Fix XCode build using `MODULE` in `pybind_extension` * Fix Python support by not linking against the python library as manylinux images and PEP-513 require<br> ref: https://peps.python.org/pep-0513/#libpythonx-y-so-1 # Bazel * Update dependencies in `MODULE.bazel` and `WORKSPACE` * Bump Protobuf to `v29.2` * Add a `.bazelignore` to avoid to parse cmake's usual `build` directory * Add a `.bazelrc` with default options (similar to the one in `pybind11_protobuf`) # Update CI workflows * Split CMake and Bazel workflows to get independent badges * Split MacOS (amd64 and M1) and Windows (amd64) and Linux (amd64) jobs * import ubuntu-build.yml from pybind11_protobuf ## Bazel * Add C++14, c++17 and c++20 flavours * Add `-c opt` and `-c dbg` variants * only test against the default python3.11 ## CMake * Test Python 3.9, 3.10. 3.11, 3.12 * cmake(linux): Test Unix Makefile and Ninja Build generators * cmake(macOS): Test XCode and Makefile generators * cmake(windows): Test MSVC (VC 2022) generator PiperOrigin-RevId: 721778070
1 parent 2420efd commit d1bd9b3

29 files changed

+1054
-208
lines changed

.bazelignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.bazelrc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Enable logging rc options.
2+
common --announce_rc
3+
4+
# Enable verbose failures for testing only.
5+
build --verbose_failures
6+
7+
# Set the default Apple platform to macOS.
8+
build --apple_platform_type=macos
9+
10+
# Abseil requires C++14 at minimum.
11+
build --enable_platform_specific_config
12+
build:linux --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
13+
build:macos --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
14+
build:macos --cxxopt=-mmacos-version-min=10.15 --host_cxxopt=-mmacos-version-min=10.15
15+
build:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17
16+
17+
# Enable the runfiles symlink tree on Windows. This makes it possible to build
18+
# the pip package on Windows without an intermediate data-file archive, as the
19+
# build_pip_package script in its current form (as of Aug 2023) uses the
20+
# runfiles symlink tree to decide what to put into the Python wheel.
21+
startup --windows_enable_symlinks
22+
build:windows --enable_runfiles
23+
24+
# Enable logging error output.
25+
test --test_output=errors
26+
test --test_summary=detailed
27+
28+
# https://bazel.build/configure/best-practices#bazelrc-file
29+
try-import %workspace%/user.bazelrc

.github/workflows/actions.yml

+10-24
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,43 @@
1+
# ref: https://github.com/actions/runner-images
12
name: build_and_test
23

34
# Controls when the action will run.
4-
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
6-
push:
7-
branches: [ master ]
8-
pull_request:
9-
branches: [ master ]
10-
# Allows you to run this workflow manually from the Actions tab
11-
workflow_dispatch:
5+
on: [push, pull_request, workflow_dispatch]
126

137
env:
148
PIP_BREAK_SYSTEM_PACKAGES: 1
159

1610
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1711
jobs:
18-
1912
unix:
2013
strategy:
2114
fail-fast: false
2215
matrix:
2316
runs-on: [ubuntu-latest]
2417
build_tool: [bazel, cmake]
2518

26-
name: "${{matrix.runs-on}} ${{matrix.build_tool}}"
19+
name: "script ${{matrix.build_tool}}"
2720
runs-on: ${{matrix.runs-on}}
2821

2922
# Steps represent a sequence of tasks that will be executed as part of the job
3023
steps:
3124
- name: Show env
3225
run: env
33-
3426
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
3628

37-
- name: Install bazel
29+
- name: Setup bazel
3830
if: matrix.build_tool == 'bazel'
39-
# Install Bazel, see https://docs.bazel.build/versions/master/install-ubuntu.html#step-1-install-required-packages
40-
run: |
41-
sudo apt install curl gnupg
42-
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
43-
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
44-
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
45-
sudo apt update && sudo apt install bazel -y
31+
uses: bazel-contrib/setup-bazel@0.8.4
32+
with:
33+
bazelisk-cache: true
34+
disk-cache: ${{ github.workflow }}
35+
repository-cache: true
4636

4737
- name: Show bazel version
4838
if: matrix.build_tool == 'bazel'
4939
run: bazel --version
5040

51-
- name: Update cmake
52-
if: matrix.build_tool == 'cmake'
53-
uses: jwlawson/actions-setup-cmake@v1.14
54-
5541
- name: Show cmake version
5642
if: matrix.build_tool == 'cmake'
5743
run: cmake --version
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 Linux Bazel
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
bazel: [
12+
{compilation_mode: opt},
13+
{compilation_mode: dbg},
14+
]
15+
cpp: [
16+
{version: 14, flags: "-std=c++14"},
17+
{version: 17, flags: "-std=c++17"},
18+
{version: 20, flags: "-std=c++20"},
19+
]
20+
python: [
21+
{version: '3.11'},
22+
]
23+
exclude:
24+
# only test `-c dbg` build with C++17
25+
- cpp: {version: 14}
26+
bazel: {compilation_mode: dbg}
27+
- cpp: {version: 20}
28+
bazel: {compilation_mode: dbg}
29+
fail-fast: false
30+
name: Linux•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Check Java
35+
run: java -version
36+
- name: Setup Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ matrix.python.version }}
40+
- name: Check Python
41+
run: |
42+
python --version
43+
python -m platform
44+
- uses: bazel-contrib/setup-bazel@0.8.4
45+
with:
46+
bazelisk-cache: true
47+
disk-cache: ${{ github.workflow }}
48+
repository-cache: true
49+
- name: Check Bazel
50+
run: bazel version
51+
- name: Build
52+
run: >
53+
bazel build
54+
-c ${{ matrix.bazel.compilation_mode }}
55+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
56+
--subcommands=pretty_print
57+
--enable_bzlmod
58+
//...
59+
- name: Test
60+
run: >
61+
bazel test
62+
-c ${{ matrix.bazel.compilation_mode }}
63+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
64+
--subcommands=pretty_print
65+
--enable_bzlmod
66+
//...
67+
68+
amd64_linux_bazel:
69+
runs-on: ubuntu-latest
70+
needs: native
71+
steps:
72+
- uses: actions/checkout@v4
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 Linux CMake
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
python: [
12+
{version: '3.9'},
13+
{version: '3.10'},
14+
{version: '3.11'},
15+
{version: '3.12'},
16+
#{version: '3.13'},
17+
]
18+
cmake: [
19+
{generator: "Unix Makefiles", config: "Release"},
20+
{generator: "Ninja", config: "Release"},
21+
#{generator: "Ninja Multi-Config", config: "Release"},
22+
]
23+
fail-fast: false
24+
name: Linux•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python.version }}
32+
- name: Check Python
33+
run: |
34+
python --version
35+
python -m platform
36+
- name: Install Python requirements
37+
run: python -m pip install --upgrade -r $(python -c 'import sys; print("./pybind11_abseil/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
38+
- name: Install Ninja
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install ninja-build
42+
- name: Check CMake
43+
run: cmake --version
44+
- name: Configure
45+
run: >
46+
cmake -S. -Bbuild
47+
-G "${{ matrix.cmake.generator }}"
48+
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }}
49+
-DCMAKE_INSTALL_PREFIX=install
50+
- name: Build
51+
run: >
52+
cmake --build build
53+
--config ${{ matrix.cmake.config }}
54+
--target all
55+
-v -j2
56+
- name: Test
57+
run: >
58+
CTEST_OUTPUT_ON_FAILURE=1
59+
cmake --build build
60+
--config ${{ matrix.cmake.config }}
61+
--target test
62+
-v
63+
- name: Install
64+
run: >
65+
cmake --build build
66+
--config ${{ matrix.cmake.config }}
67+
--target install
68+
-v
69+
70+
amd64_linux_cmake:
71+
runs-on: ubuntu-latest
72+
needs: native
73+
steps:
74+
- uses: actions/checkout@v4
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 MacOS Bazel
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
bazel: [
12+
{compilation_mode: opt},
13+
{compilation_mode: dbg},
14+
]
15+
cpp: [
16+
#{version: 14, flags: "-std=c++14"},
17+
{version: 17, flags: "-std=c++17"},
18+
#{version: 20, flags: "-std=c++20"},
19+
]
20+
python: [
21+
{version: '3.11'},
22+
]
23+
exclude:
24+
# only test `-c dbg` build with C++17
25+
- cpp: {version: 14}
26+
bazel: {compilation_mode: dbg}
27+
- cpp: {version: 20}
28+
bazel: {compilation_mode: dbg}
29+
fail-fast: false
30+
name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
31+
runs-on: macos-13 # last macos intel based runner
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Set Java to OpenJDK 17 (Temurin)
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: 'temurin'
38+
java-version: '17'
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python.version }}
43+
- name: Check Python
44+
run: |
45+
python --version
46+
python -m platform
47+
- name: Check Bazel
48+
run: bazel version
49+
- name: Change Python in MODULE.bazel
50+
run: |
51+
sed -i '' -e 's/\(DEFAULT_PYTHON =\) "3.[0-9]*"/\1 "${{ matrix.python.version }}"/g' MODULE.bazel
52+
cat MODULE.bazel
53+
- name: Build
54+
run: >
55+
bazel build
56+
-c ${{ matrix.bazel.compilation_mode }}
57+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
58+
--subcommands=pretty_print
59+
--enable_bzlmod
60+
//...
61+
- name: Test
62+
run: >
63+
bazel test
64+
-c ${{ matrix.bazel.compilation_mode }}
65+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
66+
--subcommands=pretty_print
67+
--enable_bzlmod
68+
//...
69+
70+
amd64_macos_bazel:
71+
runs-on: ubuntu-latest
72+
needs: native
73+
steps:
74+
- uses: actions/checkout@v4
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 MacOS CMake
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
python: [
12+
{version: '3.9'},
13+
{version: '3.10'},
14+
{version: '3.11'},
15+
{version: '3.12'},
16+
#{version: '3.13'},
17+
]
18+
cmake: [
19+
#{generator: "Xcode", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: install},
20+
{generator: "Unix Makefiles", config: Release, build_target: all, test_target: test, install_target: install},
21+
]
22+
fail-fast: false
23+
name: MacOS•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
24+
runs-on: macos-13 # last macos intel based runner
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python.version }}
31+
- name: Update Path
32+
run: |
33+
echo "$HOME/Library/Python/${{ matrix.python.version }}/bin" >> $GITHUB_PATH
34+
echo "$HOME/.local/bin" >> $GITHUB_PATH
35+
- name: Check Python
36+
run: python --version
37+
- name: Install Python requirements
38+
run: python -m pip install --upgrade -r $(python -c 'import sys; print("./pybind11_abseil/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
39+
- name: Check CMake
40+
run: cmake --version
41+
- name: Configure
42+
run: >
43+
cmake -S. -Bbuild
44+
-G "${{ matrix.cmake.generator }}"
45+
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }}
46+
-DCMAKE_INSTALL_PREFIX=install
47+
- name: Build
48+
run: >
49+
cmake --build build
50+
--config ${{ matrix.cmake.config }}
51+
--target ${{ matrix.cmake.build_target }}
52+
-v -j2
53+
- name: Test
54+
run: >
55+
CTEST_OUTPUT_ON_FAILURE=1
56+
cmake --build build
57+
--config ${{ matrix.cmake.config }}
58+
--target ${{ matrix.cmake.test_target }}
59+
-v
60+
- name: Install
61+
run: >
62+
cmake --build build
63+
--config ${{ matrix.cmake.config }}
64+
--target ${{ matrix.cmake.install_target }}
65+
-v
66+
67+
amd64_macos_cmake:
68+
runs-on: ubuntu-latest
69+
needs: native
70+
steps:
71+
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)