Skip to content

Commit c4ee58a

Browse files
authored
Pin LLVM versions inside the repository (#8942)
1 parent c0ab358 commit c4ee58a

File tree

5 files changed

+968
-126
lines changed

5 files changed

+968
-126
lines changed

doc/BuildingHalideWithCMake.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ necessary, it is convenient to install Python system-wide on Windows (i.e.
230230
`C:\Program Files`) because CMake looks at standard paths and registry keys.
231231
This removes the need to manually set the `PATH`.
232232

233-
Once Python is installed, you can install the Python module dependencies either
234-
globally or in a [virtual environment][venv] by running
233+
Once Python is installed, you can install the Python module dependencies in
234+
a [virtual environment][venv] by running
235235

236236
```shell
237-
$ python -m pip install -r requirements.txt
237+
$ uv sync
238238
```
239239

240240
from the root of the repository.
@@ -271,12 +271,11 @@ $ sudo apt install clang-tools lld llvm-dev libclang-dev liblld-dev \
271271
### Python
272272

273273
When running the Python package, you will need to install additional
274-
dependencies. These are tabulated in `requirements.txt` and may be installed
275-
with:
274+
dependencies. These are tabulated as constraints in `pyproject.toml` and
275+
resolved to specific versions in `uv.lock`. They may be installed by running:
276276

277277
```shell
278-
$ python -m pip install -U pip "setuptools[core]" wheel
279-
$ python -m pip install -r requirements.txt
278+
$ uv sync --no-install-project
280279
```
281280

282281
# Building Halide

doc/Python.md

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Halide Bindings for Python
22

33
<!-- TOC -->
4+
45
* [Halide Bindings for Python](#halide-bindings-for-python)
56
* [Acquiring the Python bindings](#acquiring-the-python-bindings)
67
* [Building the Python bindings](#building-the-python-bindings)
@@ -29,6 +30,7 @@
2930
* [Notable Differences Between C++ and Python Generators](#notable-differences-between-c-and-python-generators)
3031
* [Keeping Up To Date](#keeping-up-to-date)
3132
* [License](#license)
33+
3234
<!-- TOC -->
3335

3436
Halide provides Python bindings for most of its public API. Python 3.10 (or
@@ -72,75 +74,49 @@ bindings require Halide to be built with RTTI and exceptions **enabled**, which
7274
in turn requires LLVM to be built with RTTI, but this is not the default for
7375
LLVM.
7476

75-
### Using CMake directly
76-
7777
Before configuring with CMake, you should ensure you have prerequisite packages
7878
installed in your local Python environment. The best way to get set up is to use
79-
a virtual environment:
79+
a virtual environment with `uv`:
8080

8181
```shell
82-
$ python3 -m venv venv
83-
$ . venv/bin/activate
84-
$ python3 -m pip install -U pip "setuptools[core]" wheel
85-
$ python3 -m pip install -r requirements.txt
82+
$ uv sync --no-install-project
8683
```
8784

88-
Or, if using `uv` the following command is equivalent:
89-
90-
```shell
91-
uv venv --python 3.12 # for example
92-
uv pip install -r requirements.txt
93-
```
85+
If you don't have LLVM installed already, you can try using the same ones the
86+
buildbots use by adding `--group ci-llvm-<VERSION>` to the `uv sync` command,
87+
where `<VERSION>` is the LLVM major version number (e.g. `23`) or `main`.
9488

95-
Then build and install Halide:
89+
If you install `ci-llvm-*`, you can set `Halide_LLVM_ROOT=$(halide-llvm
90+
--prefix)` in your environment.
9691

97-
```shell
98-
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
99-
$ cmake --build build
100-
$ cmake --install build --prefix .local
101-
```
102-
103-
Now you can set the `PYTHONPATH` variable to point to the freshly built Python
104-
package:
105-
106-
```shell
107-
$ export PYTHONPATH="$PWD/.local/lib/python3/site-packages"
108-
```
92+
Ensure you have `flatbuffers` and `wabt` installed, too.
10993

11094
### Using wheel infrastructure
11195

112-
You can also follow the same procedure that we use to build the published
113-
wheels. First, create a virtual environment as before, but omit
114-
`requirements.txt`
96+
When using `uv`, this entire workflow can be run via:
11597

11698
```shell
117-
$ python3 -m venv venv
118-
$ . venv/bin/activate
119-
$ python3 -m pip install -U pip "setuptools[core]" wheel
99+
$ uv pip install . --no-build-isolation
120100
```
121101

122-
Next, ensure you have installed Halide's dependencies to locations where CMake
123-
can find them, given your environment. The variables `Halide_LLVM_ROOT`,
124-
`flatbuffers_ROOT`, and `wabt_ROOT` specify locations for the relevant packages
125-
directly. If they are all installed to a common prefix, you can add it to the
126-
environment variable `CMAKE_PREFIX_PATH`.
102+
### Using CMake directly
127103

128-
Then it should be as simple as:
104+
Assuming dependencies are available, you can build the Python bindings directly
105+
with CMake:
129106

130107
```shell
131-
$ pip install .
108+
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
109+
$ cmake --build build
110+
$ cmake --install build --prefix .local
132111
```
133112

134-
When using `uv`, this entire workflow can be run via
113+
Now you can set the `PYTHONPATH` variable to point to the freshly built Python
114+
package:
135115

136116
```shell
137-
$ uv sync
117+
$ export PYTHONPATH="$PWD/.local/lib/python3/site-packages"
138118
```
139119

140-
If you need a different Python version, you can add `--python 3.xy` to this
141-
command. If you wish to install compatible build tools into the venv (e.g.
142-
CMake, ninja), rather than use your system tools, pass `--group tools` here.
143-
144120
## Documentation and Examples
145121

146122
As mentioned elsewhere, the Python API attempts to mimic the
@@ -538,9 +514,9 @@ add_halide_python_extension_library(my_extension
538514
This compiles the Generator code in `logical_op_generator.py` with the
539515
registered name `logical_op_generator` to produce the target `xor_filter`, and
540516
then wraps the compiled output with a Python extension. The result will be a
541-
shared library of the form `<target>.<soabi>.so`, where `<soabi>` describes
542-
the specific Python version and platform (e.g., `cpython-310-darwin` for
543-
Python 3.10 on OSX.)
517+
shared library of the form `<target>.<soabi>.so`, where `<soabi>` describes the
518+
specific Python version and platform (e.g., `cpython-310-darwin` for Python 3.10
519+
on OSX.)
544520

545521
Note that you can combine multiple Halide libraries into a single Python module;
546522
this is convenient for packaging, but also because all the libraries in a single

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ tools = [
8080
"tbump>=6.11",
8181
]
8282

83+
ci-base = [
84+
{ include-group = "dev" },
85+
{ include-group = "apps" },
86+
{ include-group = "tools" },
87+
]
88+
89+
ci-llvm-main = [{ include-group = "ci-base" }, "halide-llvm==23.0.0.dev0+g80f627e6"]
90+
ci-llvm-22 = [{ include-group = "ci-base" }, "halide-llvm==22.1.0rc3"]
91+
ci-llvm-21 = [{ include-group = "ci-base" }, "halide-llvm==21.1.8"]
92+
ci-llvm-20 = [{ include-group = "ci-base" }, "halide-llvm==20.1.8"]
93+
8394
[project.urls]
8495
Homepage = "https://halide-lang.org"
8596
Documentation = "https://github.com/halide/Halide/blob/main/doc/Python.md"
@@ -175,3 +186,21 @@ search = "#define HALIDE_VERSION_MINOR {current_version}"
175186
src = "src/runtime/HalideRuntime.h"
176187
version_template = "{patch}"
177188
search = "#define HALIDE_VERSION_PATCH {current_version}"
189+
190+
[tool.uv]
191+
conflicts = [
192+
[
193+
{ group = "ci-llvm-main" },
194+
{ group = "ci-llvm-22" },
195+
{ group = "ci-llvm-21" },
196+
{ group = "ci-llvm-20" },
197+
],
198+
]
199+
200+
[tool.uv.sources]
201+
halide-llvm = { index = "halide" }
202+
203+
[[tool.uv.index]]
204+
name = "halide"
205+
url = "https://pypi.halide-lang.org/simple"
206+
explicit = true

requirements.txt

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

0 commit comments

Comments
 (0)