Build and Package Python Project with Python 3.11 #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package Python Project with Python 3.11 | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-linux-arm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: arm | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build Docker image | |
run: | | |
docker buildx create --use | |
docker buildx build --platform linux/arm64 -t my-arm-build . | |
- name: Run Docker container | |
run: | | |
docker run --rm my-arm-build /bin/sh -c " | |
mkdir build && | |
cd build && | |
cmake .. && | |
cmake --build . && | |
ctest --output-on-failure" | |
build-linux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y python3.11 python3.11-dev cmake make | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Build project | |
run: | | |
set -e | |
# Initialize submodules | |
git submodule update --init --recursive | |
# Build poker-eval | |
cd poker-eval | |
mkdir -p build | |
cd build | |
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON | |
make | |
cd ../.. | |
# Build pypoker-eval | |
mkdir -p build | |
cd build | |
cmake -DPython3_EXECUTABLE=$(which python3.11) \ | |
-DPython3_INCLUDE_DIR=$(python3.11 -c "from sysconfig import get_paths as gp; print(gp()['include'])") \ | |
-DPython3_LIBRARY=$(python3.11 -c "from sysconfig import get_config_var as gcv; print(gcv('LIBDIR') + '/libpython3.11.so')") \ | |
.. | |
make | |
cd .. | |
# Copy and rename the output | |
cp ./build/pypokereval.so ./_pokereval_3_11.so | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y | |
git submodule update --init --recursive | |
- name: Build project | |
shell: pwsh | |
run: | | |
Set-StrictMode -Version Latest | |
$ErrorActionPreference = "Stop" | |
# Initialize submodules | |
git submodule update --init --recursive | |
# Build poker-eval in Debug mode | |
cd ./poker-eval | |
if (!(Test-Path -Path "build")) { | |
New-Item -ItemType Directory -Force -Path "build" | |
} | |
cd build | |
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Debug | |
cmake --build . --config Debug | |
cd ../.. | |
# Build pypoker-eval in Debug mode | |
if (!(Test-Path -Path "build")) { | |
New-Item -ItemType Directory -Force -Path "build" | |
} | |
cd build | |
$pythonExe = "${{ env.pythonLocation }}\python.exe" | |
$pythonInclude = "${{ env.pythonLocation }}\include" | |
$pythonLib = "${{ env.pythonLocation }}\libs\python311.lib" | |
cmake .. -G "Visual Studio 17 2022" -A x64 -DPython3_EXECUTABLE=$pythonExe -DPython3_INCLUDE_DIR=$pythonInclude -DPython3_LIBRARY=$pythonLib -DCMAKE_BUILD_TYPE=Debug | |
cmake --build . --config Debug | |
cd .. | |
# Copy and rename the output | |
Copy-Item "./build/Debug/pypokereval.pyd" "./_pokereval_3_11.pyd" -Force | |
build-on-macos: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cmake | |
- name: Build poker-eval (macOS) | |
run: | | |
cd poker-eval | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON | |
make | |
cd ../.. | |
- name: Build pypoker-eval (macOS) | |
run: | | |
mkdir build | |
cd build | |
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON .. | |
cmake --build . --verbose | |
cd .. | |
find . -name "*pokereval*.so" -exec cp {} _pokereval_3_11.so \; || true | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pokereval-macos | |
path: _pokereval_3_11.so | |
build-on-macos-arm: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cmake | |
- name: Build poker-eval (macOS ARM) | |
run: | | |
cd poker-eval | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_OSX_ARCHITECTURES=arm64 | |
make | |
cd ../.. | |
- name: Build pypoker-eval (macOS ARM) | |
run: | | |
mkdir build | |
cd build | |
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_OSX_ARCHITECTURES=arm64 .. | |
cmake --build . --verbose | |
cd .. | |
find . -name "*pokereval*.so" -exec cp {} _pokereval_3_11.so \; || true | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: pokereval-macos-arm | |
path: _pokereval_3_11.so |