Skip to content

Commit d2414ca

Browse files
committed
Use uv
1 parent a21c797 commit d2414ca

File tree

3 files changed

+686
-27
lines changed

3 files changed

+686
-27
lines changed

.github/workflows/main.yml

+16-24
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# This fails in pytest with:
3838
# 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]
3939
exclude:
40-
- os:
40+
- os:
4141
category: windows
4242
platform: x86
4343
python: "3.13"
@@ -57,60 +57,52 @@ jobs:
5757
with:
5858
dotnet-version: '6.0.x'
5959

60-
- name: Set up Python ${{ matrix.python }}
61-
uses: actions/setup-python@v2
60+
- name: Install the latest version of uv
61+
uses: astral-sh/setup-uv@v4
6262
with:
63-
python-version: ${{ matrix.python }}
6463
architecture: ${{ matrix.os.platform }}
64+
python-version: ${{ matrix.python }}
65+
enable-cache: true
6566

6667
- name: Install dependencies
6768
run: |
68-
pip install --upgrade -r requirements.txt
69-
pip install numpy # for tests
70-
71-
- name: Build and Install
72-
run: |
73-
pip install -v .
69+
uv venv --python ${{ matrix.python }}
70+
uv sync
7471
7572
- name: Set Python DLL path and PYTHONHOME (non Windows)
7673
if: ${{ matrix.os.category != 'windows' }}
7774
run: |
78-
echo PYTHONNET_PYDLL=$(python -m find_libpython) >> $GITHUB_ENV
79-
echo PYTHONHOME=$(python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
75+
echo PYTHONNET_PYDLL=$(uv run python -m find_libpython) >> $GITHUB_ENV
8076
8177
- name: Set Python DLL path and PYTHONHOME (Windows)
8278
if: ${{ matrix.os.category == 'windows' }}
8379
run: |
84-
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(python -m find_libpython)"
85-
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(python -c 'import sys; print(sys.prefix)')"
80+
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(uv run python -m find_libpython)"
8681
8782
- name: Embedding tests
88-
if: ${{ matrix.python != '3.13' }}
89-
run: dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
83+
run: uv run dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
9084
env:
9185
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
9286

9387
- name: Python Tests (Mono)
9488
if: ${{ matrix.os.category != 'windows' }}
95-
run: pytest --runtime mono
89+
run: uv run python -m pytest --runtime mono
9690

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

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

106100
- name: Python tests run from .NET
107-
if: ${{ matrix.python != '3.13' }}
108-
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
101+
run: uv run dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
109102

110103
- name: Perf tests
111104
if: ${{ (matrix.python == '3.8') && (matrix.os.platform == 'x64') }}
112105
run: |
113-
pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
114-
dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
115-
106+
uv pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
107+
uv run dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
116108
# TODO: Run mono tests on Windows?

tools/geninterop/geninterop.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
1+
#!/usr/bin/env uv run
2+
# /// script
3+
# dependencies = ["pycparser"]
4+
# ///
45
"""
56
TypeOffset is a C# class that mirrors the in-memory layout of heap
67
allocated Python objects.

0 commit comments

Comments
 (0)