-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Python bindings to Btwxt via SWIG #44
base: main
Are you sure you want to change the base?
Changes from all commits
0dcde7f
c6f0832
fbab36b
e7876bc
6541ef6
d75b293
70ece55
1afbe1e
c9c8742
9c71d19
d3b7ca6
9cbee2b
5ca75cf
04f18bc
1c6eb0c
09134a9
56c694a
73e984d
ff9ccac
497b50d
240d733
4aee6c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,41 +9,53 @@ jobs: | |
matrix: | ||
include: | ||
- os: ubuntu | ||
os_ver: "22.04" | ||
os_ver: "24.04" | ||
config: Release | ||
coverage: false | ||
cc: gcc-11 | ||
cxx: g++-11 | ||
cc: gcc-14 | ||
cxx: g++-14 | ||
python_bindings: false | ||
arch: x86_64 | ||
- os: ubuntu | ||
os_ver: "20.04" | ||
os_ver: "22.04" | ||
config: Release | ||
coverage: false | ||
cc: gcc-10 | ||
cxx: g++-10 | ||
python_bindings: true | ||
arch: x86_64 | ||
- os: windows | ||
os_ver: "2022" | ||
config: Release | ||
coverage: false | ||
cc: cl | ||
cxx: cl | ||
python_bindings: true | ||
arch: x86_64 | ||
- os: macos | ||
os_ver: "12" | ||
os_ver: "14" | ||
config: Release | ||
coverage: false | ||
cc: clang | ||
cxx: clang++ | ||
python_bindings: true | ||
arch: arm64 | ||
- os: macos | ||
os_ver: "11" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. macos-11 was removed from GHA a long time ago. |
||
os_ver: "13" | ||
config: Release | ||
coverage: false | ||
cc: clang | ||
cxx: clang++ | ||
python_bindings: true | ||
arch: x86_64 | ||
- os: ubuntu | ||
os_ver: "20.04" | ||
os_ver: "22.04" | ||
config: Debug | ||
coverage: true | ||
cc: gcc-10 | ||
cxx: g++-10 | ||
python_bindings: false | ||
arch: x86_64 | ||
defaults: | ||
run: | ||
shell: bash | ||
|
@@ -57,10 +69,13 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set Project Name | ||
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | ||
|
||
- name: Create Build Directory | ||
run: cmake -E make_directory ${{github.workspace}}/build | ||
|
||
- name: Set coverage variables | ||
id: cov | ||
run: | | ||
|
@@ -71,21 +86,73 @@ jobs: | |
echo "COVERAGE=OFF" >> $GITHUB_OUTPUT | ||
echo "STATIC_LIB=ON" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
- name: Configure CMake | ||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="${{ matrix.config }}" -D${{ env.REPOSITORY_NAME }}_BUILD_TESTING="ON" -D${{ env.REPOSITORY_NAME }}_STATIC_LIB="${{ steps.cov.outputs.STATIC_LIB }}" -D${{ env.REPOSITORY_NAME }}_COVERAGE="${{ steps.cov.outputs.COVERAGE }}" | ||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -D${{ env.REPOSITORY_NAME }}_BUILD_TESTING=ON -D${{ env.REPOSITORY_NAME }}_STATIC_LIB=${{ steps.cov.outputs.STATIC_LIB }} -D${{ env.REPOSITORY_NAME }}_COVERAGE=${{ steps.cov.outputs.COVERAGE }} | ||
|
||
- name: Build | ||
run: cmake --build build --config ${{ matrix.config }} | ||
run: | | ||
cmake --build build --config ${{ matrix.config }} | ||
|
||
- name: Test | ||
run: ctest -C ${{ matrix.config }} --output-on-failure | ||
working-directory: build | ||
|
||
- name: Code Coverage Analysis | ||
if: "matrix.coverage" | ||
run: make gcov | ||
working-directory: build | ||
|
||
- name: Upload Code Coverage Report | ||
if: "matrix.coverage" | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
flags: integration | ||
functionalities: "gcov" | ||
move_coverage_to_trash: true | ||
|
||
- name: Set up Python 3.12 | ||
if: ${{ matrix.python_bindings }} | ||
id: setup-python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Build Python Wheel | ||
if: ${{ matrix.python_bindings }} | ||
working-directory: ./build/ | ||
run: | | ||
begin_group() { echo -e "::group::\033[93m$1\033[0m"; } | ||
|
||
begin_group "Install other python dependencies" | ||
python -m pip install --upgrade pip | ||
# Ubuntu 22.04 from apt will get swig that's too old to support attributes like [[ nodiscard ]], so get from PyPi | ||
pip install setuptools wheel twine requests packaging pytest swig | ||
echo -e "::endgroup::" | ||
|
||
begin_group "Build target" | ||
cmake -DBUILD_PYTHON_BINDINGS:BOOL=ON -DPython_REQUIRED_VERSION:STRING=${{ steps.setup-python.outputs.python-version }} -DPython_ROOT_DIR:PATH=$RUNNER_TOOL_CACHE/Python/${{ steps.setup-python.outputs.python-version }}/${{ matrix.arch }}/ . | ||
cmake --build . --config ${{ matrix.config }} --target python_package | ||
echo -e "::endgroup::" | ||
|
||
- name: Python CTest | ||
if: ${{ matrix.python_bindings }} | ||
working-directory: ./build/ | ||
run: | | ||
ctest -C ${{ matrix.config }} -R python -VV | ||
|
||
- name: Zip the wheel to maintain case sensitivy and file permissions | ||
if: ${{ matrix.python_bindings }} | ||
working-directory: ./build/python | ||
shell: bash | ||
run: | | ||
TGZ_STEM="btwxt-python-${{ matrix.os }}-${{ matrix.os_ver }}-${{ matrix.arch }}" | ||
echo "TGZ_STEM=$TGZ_STEM" >> $GITHUB_ENV | ||
tar -cvzf "$TGZ_STEM.tar.gz" dist/ | ||
|
||
- name: Upload .whl to artifact | ||
if: ${{ matrix.python_bindings }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.TGZ_STEM }} | ||
path: "./build/python/${{ env.TGZ_STEM }}.tar.gz" | ||
Comment on lines
+114
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New workflow bits to build the python bindings after the regular build is done. Runs the python ctest, and uploads the wheel as artifacts |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ builds/ | |
build/ | ||
.idea/ | ||
.vs/ | ||
.vscode/ | ||
.vscode/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
cmake_policy(SET CMP0078 NEW) | ||
cmake_policy(SET CMP0086 NEW) | ||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couple of SWIG-related policies |
||
|
||
project(btwxt) | ||
|
||
# Set a default build type if none was specified | ||
|
@@ -32,6 +35,7 @@ endif () | |
add_subdirectory("include/${PROJECT_NAME}") | ||
add_subdirectory(src) | ||
add_subdirectory(vendor) | ||
add_subdirectory(python) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add subdir. Did not change the other directories. |
||
|
||
if (${PROJECT_NAME}_BUILD_TESTING) | ||
add_subdirectory(test) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macos-12 is removed.
actions/runner-images#10721
I uses 13 (x86_64) and 14 (arm64, M1)