Skip to content

Use uv #2520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Use uv #2520

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use uv
  • Loading branch information
filmor committed Apr 14, 2025
commit d2414cab8bcf9a4fa88d21a8e7fddcbeeb163cbf
40 changes: 16 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# 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:
- os:
category: windows
platform: x86
python: "3.13"
Expand All @@ -57,60 +57,52 @@ jobs:
with:
dotnet-version: '6.0.x'

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.os.platform }}
python-version: ${{ matrix.python }}
enable-cache: true

- name: Install dependencies
run: |
pip install --upgrade -r requirements.txt
pip install numpy # for tests

- name: Build and Install
run: |
pip install -v .
uv venv --python ${{ matrix.python }}
uv sync

- name: Set Python DLL path and PYTHONHOME (non Windows)
if: ${{ matrix.os.category != 'windows' }}
run: |
echo PYTHONNET_PYDLL=$(python -m find_libpython) >> $GITHUB_ENV
echo PYTHONHOME=$(python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
echo PYTHONNET_PYDLL=$(uv run python -m 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=$(python -m find_libpython)"
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(python -c 'import sys; print(sys.prefix)')"
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(uv run python -m find_libpython)"

- name: Embedding tests
if: ${{ matrix.python != '3.13' }}
run: dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_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: pytest --runtime mono
run: uv run python -m pytest --runtime mono

# TODO: Run these tests on Windows x86
- name: Python Tests (.NET Core)
if: ${{ matrix.os.platform == 'x64' }}
run: pytest --runtime coreclr
run: uv run python -m pytest --runtime coreclr

- name: Python Tests (.NET Framework)
if: ${{ matrix.os.category == 'windows' }}
run: pytest --runtime netfx
run: uv run python -m pytest --runtime netfx

- name: Python tests run from .NET
if: ${{ matrix.python != '3.13' }}
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
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: |
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/

uv pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
uv run dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
# TODO: Run mono tests on Windows?
7 changes: 4 additions & 3 deletions tools/geninterop/geninterop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#!/usr/bin/env uv run
# /// script
# dependencies = ["pycparser"]
# ///
"""
TypeOffset is a C# class that mirrors the in-memory layout of heap
allocated Python objects.
Expand Down
Loading
Loading