Skip to content

Commit 5684a35

Browse files
committed
Use uv to run build python scripts
1 parent ccaf6c0 commit 5684a35

File tree

6 files changed

+51
-37
lines changed

6 files changed

+51
-37
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ jobs:
1010
os: [windows-2019, ubuntu-22.04]
1111

1212
steps:
13-
- uses: actions/setup-python@v4
14-
with:
15-
python-version: 3.9
16-
1713
- name: Cache interpreters
1814
uses: actions/cache@v3
1915
id: cache
@@ -31,13 +27,9 @@ jobs:
3127
with:
3228
version: "0.9.17"
3329

34-
- name: Install requirements
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: pip install -r requirements.txt
37-
3830
- name: Create interpreters
3931
if: steps.cache.outputs.cache-hit != 'true'
40-
run: python tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .
32+
run: uv run tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .
4133

4234
- name: Tar interpreters
4335
if: steps.cache.outputs.cache-hit != 'true'
@@ -60,9 +52,10 @@ jobs:
6052
arch: [x64, x86]
6153

6254
steps:
63-
- uses: actions/setup-python@v4
55+
- name: Install uv
56+
uses: astral-sh/setup-uv@v7
6457
with:
65-
python-version: 3.9
58+
version: "0.9.17"
6659

6760
- name: Check out repository code
6861
uses: actions/checkout@v3
@@ -86,7 +79,7 @@ jobs:
8679
arch: ${{ matrix.arch }}
8780

8881
- name: Perform build
89-
run: python tools/build.py build_binaries ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}
82+
run: uv run tools/build.py build_binaries ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}
9083

9184
- uses: actions/upload-artifact@v4
9285
with:
@@ -102,9 +95,10 @@ jobs:
10295
Build-PBO:
10396
runs-on: windows-latest
10497
steps:
105-
- uses: actions/setup-python@v4
98+
- name: Install uv
99+
uses: astral-sh/setup-uv@v7
106100
with:
107-
python-version: 3.9
101+
version: "0.9.17"
108102

109103
- name: Check out repository code
110104
uses: actions/checkout@v3
@@ -119,7 +113,7 @@ jobs:
119113
- name: Install Mikero's tools
120114
uses: arma-actions/mikero-tools@bec8b18fc507ee3180cadeaf35249d3f2702b1ff
121115

122-
- run: python tools/build.py build_pbos
116+
- run: uv run tools/build.py build_pbos
123117

124118
- uses: actions/upload-artifact@v4
125119
with:
@@ -140,9 +134,10 @@ jobs:
140134
arch: [x64, x86]
141135

142136
steps:
143-
- uses: actions/setup-python@v4
137+
- name: Install uv
138+
uses: astral-sh/setup-uv@v7
144139
with:
145-
python-version: 3.9
140+
version: "0.9.17"
146141

147142
- name: Check out repository code
148143
uses: actions/checkout@v3
@@ -173,10 +168,10 @@ jobs:
173168
run: sudo apt install -y gcc-multilib
174169

175170
- name: Copy templates
176-
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
171+
run: uv run tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
177172

178173
- name: Run basic tests
179-
run: python tools/build.py run_tests ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}
174+
run: uv run tools/build.py run_tests ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}
180175

181176
Consolidate:
182177
needs:
@@ -185,9 +180,10 @@ jobs:
185180
- Build-PBO
186181
runs-on: ubuntu-latest
187182
steps:
188-
- uses: actions/setup-python@v4
183+
- name: Install uv
184+
uses: astral-sh/setup-uv@v7
189185
with:
190-
python-version: 3.9
186+
version: "0.9.17"
191187

192188
- name: Check out repository code
193189
uses: actions/checkout@v3
@@ -215,13 +211,12 @@ jobs:
215211
run: chmod a+x @Pythia/PythiaTester*
216212

217213
- name: Copy templates
218-
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
214+
run: uv run tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
219215

220216
- name: Unpack interpreters
221217
run: for i in python-*.tar; do tar xf "$i" --directory "@Pythia"; done
222218

223-
- run: pip install -r requirements.txt
224-
- run: python tools/build.py safety_checks ${{ env.PYTHON_VERSION }}
219+
- run: uv run tools/build.py safety_checks ${{ env.PYTHON_VERSION }}
225220

226221
- name: Remove linux 32bit Pythia
227222
run: rm -rf @Pythia/python-*-embed-linux32 @Pythia/Pythia.so @Pythia/PythiaSetPythonPath.so @Pythia/PythiaTester @Pythia/install_requirements32.sh

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,10 @@ instead.
265265
Building requirements
266266
---------------------
267267

268-
- Any Python 3 installation
268+
- uv
269269
- Visual Studio Community 2022
270270
- WSL2 with clang and Docker installed and configured
271271
- MakePBO
272-
- uv
273272

274273
Building
275274
--------
@@ -278,17 +277,15 @@ Building
278277

279278
Run this on Windows (requires WSL2 and Docker to be installed and configured!)
280279

281-
python -m pip install -r requirements.txt
282280
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
283281

284282
# Setup WSL for both x86 and x64 architectures
285283
wsl /bin/bash -ic "sudo dpkg --add-architecture i386"
286284
wsl /bin/bash -ic "sudo apt update"
287285
wsl /bin/bash -ic "sudo apt install python3-pip patchelf libcrypt1:i386 clang gcc-multilib"
288-
wsl /bin/bash -ic "python3 -m pip install -r requirements.txt"
289286
wsl /bin/bash -ic "curl -LsSf https://astral.sh/uv/install.sh | sh"
290287

291-
python tools\rebuild_all.py
288+
uv run tools\rebuild_all.py
292289

293290
This will fetch and install all the python interpreters required both for
294291
building Pythia and then used by Pythia itself at runtime. See `build.py` which
@@ -301,7 +298,7 @@ is used by `rebuild_all.py` for details.
301298

302299
#### Later, for building everything else:
303300

304-
- `python tools\build.py --help`
301+
- `uv run tools\build.py --help`
305302
- See `rebuild_all.py` for usage
306303

307304
Common errors

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tools/build.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# /// script
2+
# dependencies = [
3+
# "auditwheel < 5",
4+
# "pefile",
5+
# "pyelftools", # elftools
6+
# "setuptools < 74",
7+
# ]
8+
# ///
9+
110
import argparse
211
import os
312
import shutil
@@ -6,7 +15,7 @@
615
import sys
716
from datetime import datetime
817

9-
import setuptools
18+
import setuptools.msvc
1019
from pkg_resources import parse_version
1120

1221
os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

tools/rebuild_all.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# /// script
2+
# dependencies = [
3+
# "auditwheel < 5",
4+
# "pefile",
5+
# "pyelftools",
6+
# "setuptools < 74",
7+
# ]
8+
# ///
9+
110
import argparse
211
import os.path
312
import posixpath
@@ -16,7 +25,7 @@ def rebuild_all(args):
1625
if not args.wsl and not args.clear:
1726
# Call ourselves through WSL to build the linux part of Pythia
1827
rebuild_all_py = posixpath.join(os.path.relpath(THIS_DIR), 'rebuild_all.py')
19-
_verbose_run(['wsl', '/bin/bash', '-lic', f'python3 {rebuild_all_py} {args.version} --wsl --clear'], check=True)
28+
_verbose_run(['wsl', '/bin/bash', '-lic', f'uv run {rebuild_all_py} {args.version} --wsl --clear'], check=True)
2029

2130
if args.clear:
2231
clear_pythia_directory()

tools/safety_checks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# /// script
2+
# dependencies = [
3+
# "auditwheel < 5",
4+
# "pefile",
5+
# "pyelftools", # elftools
6+
# "setuptools < 74",
7+
# ]
8+
# ///
9+
110
import argparse
211
import os
312
import sys

0 commit comments

Comments
 (0)