Skip to content

Use uv

Use uv #1493

Workflow file for this run

name: Main
on:
push:
branches:
- master
pull_request:
jobs:
build-test:
name: Build and Test
runs-on: ${{ matrix.os.instance }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os:
- category: windows
platform: x86
instance: windows-latest
- category: windows
platform: x64
instance: windows-latest
- category: ubuntu
platform: x64
instance: ubuntu-22.04
- category: macos
platform: x64
instance: macos-13
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
# This fails in pytest with:
# CSC : error CS4023: /platform:anycpu32bitpreferred can only be used with /t:exe, /t:winexe and /t:appcontainerexe [D:\a\pythonnet\pythonnet\src\runtime\Python.Runtime.csproj]
exclude:
- os:
category: windows
platform: x86
python: "3.13"
steps:
- name: Set Environment on macOS
uses: maxim-lobanov/setup-xamarin@v1
if: ${{ matrix.os.category == 'macos' }}
with:
mono-version: latest
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
architecture: ${{ matrix.os.platform }}
python-version: ${{ matrix.python }}
enable-cache: true
- name: Set Python DLL path and PYTHONHOME (non Windows)
if: ${{ matrix.os.category != 'windows' }}
run: |
echo PYTHONNET_PYDLL=$(uv run find_libpython) >> $GITHUB_ENV
- name: Set Python DLL path and PYTHONHOME (Windows)
if: ${{ matrix.os.category == 'windows' }}
run: |
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(uv run find_libpython)"
- name: Embedding tests
run: uv run dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
env:
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
- name: Python Tests (Mono)
if: ${{ matrix.os.category != 'windows' }}
run: uv run pytest --runtime mono
# TODO: Run these tests on Windows x86
- name: Python Tests (.NET Core)
if: ${{ matrix.os.platform == 'x64' }}
run: uv run pytest --runtime coreclr
- name: Python Tests (.NET Framework)
if: ${{ matrix.os.category == 'windows' }}
run: uv run pytest --runtime netfx
- name: Python tests run from .NET
run: uv run dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
- name: Perf tests
if: ${{ (matrix.python == '3.8') && (matrix.os.platform == 'x64') }}
run: |
uv pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
# TODO: Run mono tests on Windows?