8000 Use uv · pythonnet/pythonnet@1d4e2dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d4e2dc

Browse files
committed
Use uv
1 parent 7a9e3bf commit 1d4e2dc

File tree

4 files changed

+265
-21
lines changed

4 files changed

+265
-21
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,27 @@ jobs:
4949
with:
5050
dotnet-version: '6.0.x'
5151

52-
- name: Set up Python ${{ matrix.python }}
53-
uses: actions/setup-python@v2
52+
- name: Install the latest version of uv
53+
uses: astral-sh/setup-uv@v3
5454
with:
55-
python-version: ${{ matrix.python }}
56-
architecture: ${{ matrix.os.platform }}
55+
enable-cache: true
5756

5857
- name: Install dependencies
5958
run: |
60-
pip install --upgrade -r requirements.txt
61-
pip install numpy # for tests
62-
63-
- name: Build and Install
64-
run: |
65-
pip install -v .
59+
uv venv --python ${{ matrix.python }}
60+
uv sync
6661
6762
- name: Set Python DLL path and PYTHONHOME (non Windows)
6863
if: ${{ matrix.os.category != 'windows' }}
6964
run: |
70-
echo PYTHONNET_PYDLL=$(python -m find_libpython) >> $GITHUB_ENV
71-
echo PYTHONHOME=$(python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
65+
echo PYTHONNET_PYDLL=$(uv run find_libpython) >> $GITHUB_ENV
66+
echo PYTHONHOME=$(uv run python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
7267
7368
- name: Set Python DLL path and PYTHONHOME (Windows)
7469
if: ${{ matrix.os.category == 'windows' }}
7570
run: |
76-
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(python -m find_libpython)"
77-
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(python -c 'import sys; print(sys.prefix)')"
71+
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(uv run find_libpython)"
72+
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(uv run python -c 'import sys; print(sys.prefix)')"
7873
7974
- name: Embedding tests
8075
run: dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
@@ -83,24 +78,24 @@ jobs:
8378

8479
- name: Python Tests (Mono)
8580
if: ${{ matrix.os.category != 'windows' }}
86-
run: pytest --runtime mono
81+
run: uv run pytest --runtime mono
8782

8883
# TODO: Run these tests on Windows x86
8984
- name: Python Tests (.NET Core)
9085
if: ${{ matrix.os.platform == 'x64' }}
91-
run: pytest --runtime coreclr
86+
run: uv run pytest --runtime coreclr
9287

9388
- name: Python Tests (.NET Framework)
9489
if: ${{ matrix.os.category == 'windows' }}
95-
run: pytest --runtime netfx
90+
run: uv run pytest --runtime netfx
9691

9792
- name: Python tests run from .NET
9893
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
9994

10095
- name: Perf tests
10196
if: ${{ (matrix.python == '3.8') && (matrix.os.platform == 'x64') }}
10297
run: |
103-
pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
98+
uv pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
10499
dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
105100
106101
# TODO: Run mono tests on Windows?

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ classifiers = [
3434

3535
dynamic = ["version"]
3636

37+
[dependency-groups]
38+
dev = [
39+
"pytest >= 6",
40+
"find_libpython >= 0.3.0",
41+
]
42+
43+
test = [
44+
"numpy",
45+
"psutil"
46+
]
47+
3748
[[project.authors]]
3849
name = "The Contributors of the Python.NET Project"
3950
email = "pythonnet@python.org"

tools/geninterop/geninterop.py

Lines changed: 4 additions & 3 deletions
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)
0