Skip to content

Build

Build #17

Workflow file for this run

name: Build
on: workflow_dispatch
env:
# Codec2 is required for the build process, so instruct cibuildwheel to
# install the currently supported version.
CIBW_BEFORE_ALL_LINUX: >
git clone https://github.com/drowe67/codec2 &&
cd codec2 &&
git checkout 1.2.0 &&
mkdir build_linux &&
cd build_linux &&
cmake .. &&
make &&
make install
# Don't support x86, because I had problems getting a successful build.
CIBW_ARCHS_LINUX: x86_64
# A smoke test for each wheel.
CIBW_TEST_COMMAND: >
python -c "import pycodec2"
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install build
run: python -m pip install build==1.2.2
- name: Build sdist
run: python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: pycodec2-sdist
path: ./dist/*.tar.gz
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Supported runners: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# Not supporting Windows, because there's no codec2 package for Windows' package manager.Use cross compilation to support windows
os: [ubuntu-24.04, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
# Used to host cibuildwheel
# https://github.com/actions/setup-python
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
- name: Install codec2 on macOS
if: contains(matrix.os, 'macos')
run: |
git clone https://github.com/drowe67/codec2 &&
cd codec2 &&
git checkout 1.2.0 &&
mkdir build_linux &&
cd build_linux &&
cmake .. &&
make &&
sudo make install
# brew update
# brew install codec2
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: pycodec2-${{ matrix.os }}
path: ./wheelhouse/*.whl
cross_compile_windows:
name: cross compile windows on ubuntu
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: build_linux
run: |
git clone https://github.com/drowe67/codec2 &&
cd codec2 &&
git checkout 1.2.0 &&
mkdir build_linux &&
cd build_linux &&
cmake .. &&
make &&
sudo make install
- name: build_windows
run: |
sudo apt-get update &&
sudo apt-get install -y mingw-w64 &&
cd codec2 &&
mkdir build_windows &&
echo "set(CMAKE_SYSTEM_NAME Windows)" > Toolchain-Ubuntu-mingw32.cmake &&
echo "set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-g++)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_RC_COMPILER \${TOOLCHAIN_PREFIX}-windres)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX})" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -m64\")" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} -m64\")" >> Toolchain-Ubuntu-mingw32.cmake &&
echo "set(CMAKE_SIZEOF_VOID_P 8)" >> Toolchain-Ubuntu-mingw32.cmake &&
cd build_windows &&
cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-Ubuntu-mingw32.cmake -DUNITTEST=FALSE -DGENERATE_CODEBOOK=../build_linux/src/generate_codebook -DCMAKE_BUILD_TYPE=Release .. &&
make
- name: Upload libs for windows
uses: actions/upload-artifact@v4
with:
name: windows-libs
path: |
codec2/build_windows/src/libcodec2.dll
codec2/build_windows/src/libcodec2.dll.a
codec2/build_windows/codec2/version.h
codec2/src/codec2.h
/usr/lib/gcc/x86_64-w64-mingw32/13-win32/libgcc_s_seh-1.dll
build_wheels_windows:
needs:
- cross_compile_windows
name: Build wheels on windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# Used to host cibuildwheel
# https://github.com/actions/setup-python
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
- name: Download libs for windows
uses: actions/download-artifact@v4
with:
name: windows-libs
path: temp/
pattern: true
- name: Copy libs for windows
run: |
mkdir lib_win &&
mkdir pycodec2/codec2 &&
cp .\temp\home\runner\work\pycodec2\pycodec2\codec2\build_windows\src\libcodec2.dll lib_win\libcodec2.dll &&
cp .\temp\home\runner\work\pycodec2\pycodec2\codec2\build_windows\src\libcodec2.dll.a lib_win\libcodec2.lib &&
cp .\temp\home\runner\work\pycodec2\pycodec2\codec2\build_windows\codec2\version.h pycodec2\codec2\version.h &&
cp .\temp\home\runner\work\pycodec2\pycodec2\codec2\src\codec2.h pycodec2\codec2\codec2.h &&
cp .\temp\usr\lib\gcc\x86_64-w64-mingw32\13-win32\libgcc_s_seh-1.dll lib_win\libgcc_s_seh-1.dll &&
ls lib_win
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse --archs AMD64
- uses: actions/upload-artifact@v4
with:
name: pycodec2-windows
path: ./wheelhouse/*.whl
merge:
runs-on: ubuntu-latest
needs:
- build_sdist
- build_wheels
- build_wheels_windows
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: pycodec2
pattern: pycodec2-*