Skip to content

Python: use uv rather than pip #2919

Python: use uv rather than pip

Python: use uv rather than pip #2919

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
workflow_dispatch:
jobs:
ci:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - name: 'Windows static library (Intel)'
# os: windows-2022
# arch: amd64
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'Windows shared library (Intel)'
# os: windows-2022
# arch: amd64
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# copy_dll: ON
# - name: 'Windows static library (ARM)'
# os: windows-11-arm
# arch: amd64_arm64
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# - name: 'Windows shared library (ARM)'
# os: windows-11-arm
# arch: amd64_arm64
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# copy_dll: ON
# - name: 'Linux static library (Intel)'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'Linux shared library (Intel)'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'Linux static library (ARM)'
# os: ubuntu-22.04-arm
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'Linux shared library (ARM)'
# os: ubuntu-22.04-arm
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'macOS static library (Intel)'
# os: macos-15-intel
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'macOS shared library (Intel)'
# os: macos-15-intel
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'macOS static library (ARM)'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'macOS shared library (ARM)'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: unit_testing
# install_uninstall_and_package: ON
# use_install_prefix: ON
# - name: 'JavaScript bindings'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: ON
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: javascript_unit_testing
# - name: 'Windows Python bindings'
# os: windows-2022
# arch: amd64
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: ON
# shared_libs: OFF
# unit_testing: OFF
# target: python_unit_testing
# pip_install_test_and_uninstall: ON
- name: 'Linux Python bindings'
os: ubuntu-22.04
build_type: Release
code_analysis: OFF
code_coverage: OFF
documentation: OFF
javascript_support: OFF
memory_checks: OFF
python_support: ON
shared_libs: OFF
unit_testing: OFF
target: python_unit_testing
pip_install_test_and_uninstall: ON
# - name: 'macOS Python bindings'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: ON
# shared_libs: OFF
# unit_testing: OFF
# context: PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
# target: python_unit_testing
# pip_install_prerequisites: sudo uv pip install --system cmake scikit-build
# pip_install_test_and_uninstall: ON
# - name: 'Code formatting'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: OFF
# context: PATH=$GITHUB_WORKSPACE:$PATH
# target: check_code_formatting
# - name: 'JavaScript code formatting'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: javascript_check_code_formatting
# - name: 'Python code formatting'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: python_check_code_formatting
# - name: 'Code analysis'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: ON
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: ON
# context: PATH=$GITHUB_WORKSPACE:$PATH CC=/usr/local/bin/clang CXX=/usr/local/bin/clang++
# - name: 'Code coverage'
# os: macos-15
# build_type: Release
# code_analysis: OFF
# code_coverage: ON
# documentation: OFF
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# context: PATH=/opt/homebrew/opt/llvm@20/bin:$PATH CC=/opt/homebrew/opt/llvm@20/bin/clang CXX=/opt/homebrew/opt/llvm@20/bin/clang++
# target: code_coverage
# - name: 'Memory checks'
# os: ubuntu-22.04
# build_type: Debug
# code_analysis: OFF
# code_coverage: OFF
# documentation: OFF
# javascript_support: OFF
# memory_checks: ON
# python_support: OFF
# shared_libs: ON
# unit_testing: ON
# target: memory_checks
# - name: 'Documentation'
# os: ubuntu-22.04
# build_type: Release
# code_analysis: OFF
# code_coverage: OFF
# documentation: ON
# javascript_support: OFF
# memory_checks: OFF
# python_support: OFF
# shared_libs: OFF
# unit_testing: OFF
# target: documentation
env:
BUILDCACHE_ACCURACY: STRICT
BUILDCACHE_COMPRESS_FORMAT: ZSTD
BUILDCACHE_DEBUG: -1
BUILDCACHE_LOG_FILE: ""
steps:
- name: Set the timezone to New Zealand
uses: szenius/[email protected]
with:
timezoneWindows: 'New Zealand Standard Time'
timezoneLinux: 'Pacific/Auckland'
timezoneMacos: 'Pacific/Auckland'
- name: Check out libOpenCOR
uses: actions/checkout@v4
- name: Install Python
if: ${{ matrix.python_support == 'ON' }}
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install CMake and Ninja
uses: lukka/get-cmake@latest
- name: Install buildcache
uses: opencor/buildcache-action@v1
with:
cache_key: ci-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.code_analysis }}-${{ matrix.code_coverage }}-${{ matrix.documentation }}-${{ matrix.javascript_support }}-${{ matrix.memory_checks }}-${{ matrix.python_support }}-${{ matrix.shared_libs }}-${{ matrix.unit_testing }}-${{ matrix.target }}
- name: Configure MSVC
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Install LLVM
if: ${{ matrix.code_coverage == 'ON' }}
run: brew install --overwrite llvm@20
- name: Install Clang
if: ${{ matrix.code_analysis == 'ON' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang.tar.gz -O - | tar -xz
sudo mv clang /usr/local/bin
sudo cp /usr/local/bin/clang /usr/local/bin/clang++
wget https://github.com/opencor/gha/releases/download/gha/clang-include.tar.gz -O - | tar -xz
sudo mv include/* /usr/local/include
- name: Install ClangFormat
if: ${{ matrix.target == 'check_code_formatting' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang-format.tar.gz -O - | tar -xz
sudo mv clang-format /usr/local/bin
- name: Install Clang-Tidy
if: ${{ matrix.name == 'Code analysis' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/clang-tidy.tar.gz -O - | tar -xz
sudo mv clang-tidy /usr/local/bin
- name: Install Emscripten
if: ${{ matrix.javascript_support == 'ON' }}
run: brew install --overwrite emscripten
- name: Install Prettier
if: ${{ matrix.target == 'javascript_check_code_formatting' }}
run: brew install --overwrite prettier
- name: Install uv
if: ${{ matrix.documentation == 'ON' || matrix.python_support == 'ON' || matrix.target == 'python_check_code_formatting' }}
uses: astral-sh/setup-uv@v6
- name: Install Black
if: ${{ matrix.target == 'python_check_code_formatting' }}
run: uv pip install --system black
- name: Install Valgrind
if: ${{ matrix.memory_checks == 'ON' }}
run: |
sudo apt update
sudo apt install valgrind
- name: Install pytest and pytest-html
if: ${{ matrix.python_support == 'ON' }}
run: uv pip install --system pytest pytest-html
- name: Check pip list
if: ${{ matrix.python_support == 'ON' }}
run: |
uv pip list
python cmake/check_python_package.py pytest_html
/opt/hostedtoolcache/Python/3.11.13/x64/bin/python cmake/check_python_package.py pytest_html
# uv python cmake/check_python_package.py pytest_html
- name: Install Sphinx and some Sphinx packages
if: ${{ matrix.documentation == 'ON' }}
run: uv pip install --system sphinx sphinx-copybutton sphinx-inline-tabs
- name: Install Doxygen
if: ${{ matrix.documentation == 'ON' }}
run: |
wget https://github.com/opencor/gha/releases/download/gha/doxygen.tar.gz -O - | tar -xz
sudo mv doxygen /usr/local/bin
- name: Configure libOpenCOR
shell: bash
run: |
uv pip list
if [ '${{ matrix.use_install_prefix }}' == 'ON' ]; then export D_INSTALL_PREFIX='-DINSTALL_PREFIX=${{ github.workspace }}/install'; fi
${{ matrix.context }} cmake -G Ninja -S . -B build -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=${{ matrix.code_analysis }} -DCODE_COVERAGE=${{ matrix.code_coverage }} -DDOCUMENTATION=${{ matrix.documentation }} $D_INSTALL_PREFIX -DJAVASCRIPT_BINDINGS=${{ matrix.javascript_support }} -DJAVASCRIPT_UNIT_TESTING=${{ matrix.javascript_support }} -DMEMORY_CHECKS=${{ matrix.memory_checks }} -DPYTHON_BINDINGS=${{ matrix.python_support }} -DPYTHON_UNIT_TESTING=${{ matrix.python_support }} -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=${{ matrix.unit_testing }}
- name: Build libOpenCOR
if: ${{ (matrix.install_uninstall_and_package == 'ON') || (matrix.javascript_support == 'ON') || (matrix.python_support == 'ON') }}
run: cmake --build build
- name: Unit testing
if: ${{ (matrix.unit_testing == 'ON') && (matrix.code_analysis == 'OFF') && (matrix.code_coverage == 'OFF') && (matrix.memory_checks == 'OFF') }}
run: cmake --build build --target ${{ matrix.target }}
- name: JavaScript unit testing
if: ${{ matrix.javascript_support == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Python unit testing
if: ${{ matrix.python_support == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Python unit testing report
if: ${{ matrix.python_support == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}_report
- name: Code formatting
if: ${{ matrix.target == 'check_code_formatting' }}
run: cmake --build build --target ${{ matrix.target }}
- name: JavaScript code formatting
if: ${{ matrix.target == 'javascript_check_code_formatting' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Python code formatting
if: ${{ matrix.target == 'python_check_code_formatting' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Code analysis
if: ${{ matrix.name == 'Code analysis' }}
run: cmake --build build
- name: Code coverage
if: ${{ matrix.code_coverage == 'ON' }}
run: |
cmake --build build --target ${{ matrix.target }}
if [ `cmake --build build --target ${{ matrix.target }} | grep TOTAL | sed 's/ /\n/g' | grep "100.00%" | wc -l | sed 's/ //g'` -eq 4 ]; then exit 0; else exit 1; fi
- name: Code coverage report
if: ${{ matrix.code_coverage == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}_report
- name: Memory checks
if: ${{ matrix.memory_checks == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Documentation
if: ${{ matrix.documentation == 'ON' }}
run: cmake --build build --target ${{ matrix.target }}
- name: Install libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: cmake --build build --target install
- name: Test libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
shell: bash
run: |
cd tests/install
if [ '${{ matrix.use_install_prefix }}' == 'ON' ]; then export D_CMAKE_PREFIX_PATH='-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install'; fi
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $D_CMAKE_PREFIX_PATH
cmake --build build
if [ '${{ matrix.copy_dll }}' == 'ON' ]; then cp "C:/Program Files (x86)/libOpenCOR/bin/libOpenCOR.dll" build; fi
build/testInstall
- name: Uninstall libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: cmake --build build --target uninstall
- name: Package libOpenCOR
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
run: |
cd build
cpack
- name: pip install libOpenCOR
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: |
${{ matrix.pip_install_prerequisites }}
uv pip install --system .
- name: Test libOpenCOR Python
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: |
cd tests/install/bindings/python
python3 test_install.py
- name: pip uninstall libOpenCOR
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
run: uv pip uninstall -y libopencor
# spell_check:
# name: Spell check
# runs-on: ubuntu-22.04
# steps:
# - name: Set the timezone to New Zealand
# uses: szenius/[email protected]
# with:
# timezoneLinux: 'Pacific/Auckland'
# - name: Check out libOpenCOR
# uses: actions/checkout@v4
# - name: Spell check
# uses: codespell-project/actions-codespell@v2
# with:
# check_filenames: true
# skip: ./extern
# exclude_file: .codespellexclude