Skip to content

Commit 347778e

Browse files
committed
Use uv to run build python scripts
1 parent ccaf6c0 commit 347778e

File tree

6 files changed

+64
-45
lines changed

6 files changed

+64
-45
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 32 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
@@ -30,14 +26,11 @@ jobs:
3026
uses: astral-sh/setup-uv@v7
3127
with:
3228
version: "0.9.17"
33-
34-
- name: Install requirements
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: pip install -r requirements.txt
29+
enable-cache: false
3730

3831
- name: Create interpreters
3932
if: steps.cache.outputs.cache-hit != 'true'
40-
run: python tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .
33+
run: uv run tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .
4134

4235
- name: Tar interpreters
4336
if: steps.cache.outputs.cache-hit != 'true'
@@ -60,13 +53,15 @@ jobs:
6053
arch: [x64, x86]
6154

6255
steps:
63-
- uses: actions/setup-python@v4
64-
with:
65-
python-version: 3.9
66-
6756
- name: Check out repository code
6857
uses: actions/checkout@v3
6958

59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v7
61+
with:
62+
version: "0.9.17"
63+
enable-cache: false
64+
7065
- name: Create the directory
7166
run: mkdir "@Pythia"
7267

@@ -86,7 +81,7 @@ jobs:
8681
arch: ${{ matrix.arch }}
8782

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

9186
- uses: actions/upload-artifact@v4
9287
with:
@@ -102,13 +97,15 @@ jobs:
10297
Build-PBO:
10398
runs-on: windows-latest
10499
steps:
105-
- uses: actions/setup-python@v4
106-
with:
107-
python-version: 3.9
108-
109100
- name: Check out repository code
110101
uses: actions/checkout@v3
111102

103+
- name: Install uv
104+
uses: astral-sh/setup-uv@v7
105+
with:
106+
version: "0.9.17"
107+
enable-cache: false
108+
112109
- name: Cache tools
113110
uses: actions/cache@v3
114111
with:
@@ -119,7 +116,7 @@ jobs:
119116
- name: Install Mikero's tools
120117
uses: arma-actions/mikero-tools@bec8b18fc507ee3180cadeaf35249d3f2702b1ff
121118

122-
- run: python tools/build.py build_pbos
119+
- run: uv run tools/build.py build_pbos
123120

124121
- uses: actions/upload-artifact@v4
125122
with:
@@ -140,13 +137,15 @@ jobs:
140137
arch: [x64, x86]
141138

142139
steps:
143-
- uses: actions/setup-python@v4
144-
with:
145-
python-version: 3.9
146-
147140
- name: Check out repository code
148141
uses: actions/checkout@v3
149142

143+
- name: Install uv
144+
uses: astral-sh/setup-uv@v7
145+
with:
146+
version: "0.9.17"
147+
enable-cache: false
148+
150149
- name: Create the directory
151150
run: mkdir "@Pythia"
152151

@@ -173,10 +172,10 @@ jobs:
173172
run: sudo apt install -y gcc-multilib
174173

175174
- name: Copy templates
176-
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
175+
run: uv run tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
177176

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

181180
Consolidate:
182181
needs:
@@ -185,13 +184,15 @@ jobs:
185184
- Build-PBO
186185
runs-on: ubuntu-latest
187186
steps:
188-
- uses: actions/setup-python@v4
189-
with:
190-
python-version: 3.9
191-
192187
- name: Check out repository code
193188
uses: actions/checkout@v3
194189

190+
- name: Install uv
191+
uses: astral-sh/setup-uv@v7
192+
with:
193+
version: "0.9.17"
194+
enable-cache: false
195+
195196
- name: Download the binaries
196197
uses: actions/download-artifact@v4
197198
with:
@@ -215,13 +216,12 @@ jobs:
215216
run: chmod a+x @Pythia/PythiaTester*
216217

217218
- name: Copy templates
218-
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
219+
run: uv run tools/build.py copy_templates ${{ env.PYTHON_VERSION }}
219220

220221
- name: Unpack interpreters
221222
run: for i in python-*.tar; do tar xf "$i" --directory "@Pythia"; done
222223

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

226226
- name: Remove linux 32bit Pythia
227227
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)