Skip to content

Build and Package Python Project with Python 3.11 #46

Build and Package Python Project with Python 3.11

Build and Package Python Project with Python 3.11 #46

Workflow file for this run

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:
# - uses: actions/checkout@v2
# - name: Install build tools and dependencies (ARM64)
# run: |
# sudo apt-get update
# sudo apt-get install -y cmake make gcc-aarch64-linux-gnu g++-aarch64-linux-gnu python3.11 python3.11-dev
# - name: Build the project (ARM64)
# run: |
# mkdir build-arm64
# cd build-arm64
# cmake -DCMAKE_TOOLCHAIN_FILE=../arm-toolchain.cmake -DPython3_EXECUTABLE=/usr/bin/python3.11 -DPython3_INCLUDE_DIR=/usr/include/python3.11 -DPython3_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.11.so ..
# make
# - name: Make artifact executable (ARM64)
# run: chmod +x build-arm64/*
# - name: Create artifact package
# run: |
# cp pokereval.py build-arm64/
# cp test.py build-arm64/
# cp build-arm64/libpypokereval.so build-arm64/_pokereval_3_11.so
# - name: Upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: poker-eval-linux-arm64
# path: build-arm64/*
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
- name: Create artifact package
run: |
cp pokereval.py build/
cp test.py build/
cp _pokereval_3_11.so build/pypokereval.so
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: poker-eval-linux
path: build/*
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
- name: Create artifact package
run: |
Copy-Item pokereval.py build/
Copy-Item test.py build/
Copy-Item _pokereval_3_11.pyd build/_pokereval_3_11.pyd
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: poker-eval-windows
path: build/*
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: Create artifact package
run: |
cp pokereval.py build/
cp test.py build/
cp _pokereval_3_11.so build/_pokereval_3_11.so
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: poker-eval-macos
path: build/*
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: Create artifact package
run: |
cp pokereval.py build/
cp test.py build/
cp _pokereval_3_11.so build/_pokereval_3_11.so
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: poker-eval-macos-arm
path: build/*