Repository navigation
136 lines (114 loc) · 4.51 KB
/
Copy pathPythonWheel.yml
File metadata and controls
136 lines (114 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Python wheel
# Pull request check of pynumerics. The wheel ships a Numerics.dll built from the pull request's own
# source (dotnet build, net10.0), so a change to the C# library and the Python package is tested
# together; build_wheel.py writes that assembly's identity (version, assembly version, SHA-256, source
# commit and build command) into the wheel's _version.py. Releases ship the nuget.org assembly instead
# (PythonPublish.yml).
on:
pull_request:
branches: [ main ]
paths:
- 'Numerics/**'
- 'python/pynumerics/**'
- '.github/docker/linux-test/**'
- '.github/workflows/PythonWheel.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
wheel:
name: pynumerics (${{ matrix.os }}, Python ${{ matrix.python }})
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04, windows-2025 ]
python: [ '3.12', '3.14' ]
defaults:
run:
shell: bash
working-directory: python/pynumerics
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Build Numerics.dll from this pull request
working-directory: .
run: dotnet build Numerics/Numerics.csproj -c Release -f net10.0
- name: Build the wheel (Numerics.dll and its identity from the local build)
run: |
python -m pip install build
python scripts/build_wheel.py --dll ../../Numerics/bin/Release/net10.0/Numerics.dll --download --out dist
- name: Install the wheel into a clean environment
run: |
python -m venv "$RUNNER_TEMP/venv"
if [ -x "$RUNNER_TEMP/venv/bin/python" ]; then PY="$RUNNER_TEMP/venv/bin/python"; else PY="$RUNNER_TEMP/venv/Scripts/python.exe"; fi
echo "PY=$PY" >> "$GITHUB_ENV"
"$PY" -m pip install dist/pynumerics-*-py3-none-any.whl pytest numpydoc ruff scipy statsmodels scikit-learn shapely "arviz>=0.17,<1" "dataretrieval>=1.4" "wetterdienst>=0.184" "kiwis-pie>=0.10.5"
- name: Lint
run: |
"$PY" -m ruff check src tests scripts
- name: Test the installed wheel
run: |
cp -r tests "$RUNNER_TEMP/tests"
cp -r docs "$RUNNER_TEMP/docs"
cp -r scripts "$RUNNER_TEMP/scripts"
cp pyproject.toml "$RUNNER_TEMP/pyproject.toml"
cd "$RUNNER_TEMP"
"$PY" -m pytest -q -p no:cacheprovider -m "not benchmark" tests
- name: Upload the wheel
if: matrix.os == 'ubuntu-24.04' && matrix.python == '3.12'
uses: actions/upload-artifact@v4
with:
name: pynumerics-wheel
path: python/pynumerics/dist/*.whl
docker:
name: pynumerics (linux-test Docker image)
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build the image
run: docker build -t numerics-linux-test .github/docker/linux-test
- name: Build the wheel from this pull request, then run ruff and pytest against it
run: |
mkdir -p "$RUNNER_TEMP/wheel"
docker run --rm -e CHECKS="wheel pytest" \
-v "$GITHUB_WORKSPACE:/src:ro" -v "$RUNNER_TEMP/wheel:/out" numerics-linux-test
- name: Install the wheel in a fresh container and check its identity
run: docker run --rm -v "$RUNNER_TEMP/wheel:/dist:ro" numerics-linux-test identity-check.sh /dist
docs:
name: pynumerics docs (warnings as errors)
runs-on: ubuntu-24.04
timeout-minutes: 15
defaults:
run:
shell: bash
working-directory: python/pynumerics
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Importing pynumerics does not start .NET, so the API reference builds without the runtime
# or Numerics.dll; the code blocks of every page run in tests/test_docs.py in the wheel job.
- name: Build the documentation
run: |
python -m pip install -e ".[docs]"
python -m sphinx -W --keep-going -b html docs docs/_build/html
- name: Upload the documentation
uses: actions/upload-artifact@v4
with:
name: pynumerics-docs
path: python/pynumerics/docs/_build/html