Pip packaging at last!#8405
Conversation
|
Something that took way longer to diagnose than it should have and that I'm saving here for posterity (and perhaps the search results of other unfortunate souls): cibuildwheel allows you to set environment variables for Windows via the Woe on me for using double quotes! The string is parsed as if it were a bash command and I needed to SSH into the runner using |
IIRC we explicitly state that Python binding for Halide are only supported for 64-bit targets. IMHO it's not worth supporting 32-bit targets at this point in history. |
steven-johnson
left a comment
There was a problem hiding this comment.
Absolutely brilliant.
0d3b947 to
f99dbe7
Compare
|
Summoning the build bots for full review. |
|
Failures are due to
Landing to confirm Test PyPI upload works. Docs to come. |
|
Fantastic! Thanks for doing this 🎉 I am looking forward to be able to ‘pip install halide’ 😊 Did I understand correctly that the default wheels will support WebAssembly as the target? If so, that’s awesome for integrating Halide into Jupyter notebooks. |
Thank you for the kind words, @dragly! 😊 You can try it right now from the Test PyPI index: $ pip install halide --pre --extra-index-url https://test.pypi.org/simpleWhen we release Halide 19.0.0 in a few weeks, then plain old
Yes. WebAssembly is now a required backend (along with X86). See #8344 I'm curious to learn more about the Jupyter notebook usage. Do you have an example of using Halide's WebAssembly backend in that context? |
We probably won't release a Halide 19 until LLVM 19 is final, I don't think there's a date for that yet, but it is in RC so hopefully not too long. |
19.1.0 final is expected on the 17th. Unless we have major blockers, our release shouldn't take long after that. |
Very nice! Worked right out of the box here.
I have been playing around with a wrapper around IPython's You can get pretty far on something like this without WebAssembly as well, but then you need a running Jupyter kernel. With WebAssembly, you can include interactive viewers in an HTML version of a notebook and it will just keep working with static hosting. I have for instance been using Jupyter Book both for some personal projects and for internal documentation of our Halide code at work. So I am hoping to include some interactive visualizations there too. The work-in-progress API looks something like this: factor = hl.Param(hl.UInt(8), "factor", 0)
darken = hl.Func("darken")
darken[x, y, c] = image[x, y, c] / factor
slider = Slider(factor, min_value=1, max_value=10, step=1)
display_halide(darken, controls=[slider])Which then results in output looking something like this: In the implementation I am compiling the Halide Func to WebAssembly and then invoking Emscripten to link it and generate the final .js and .wasm files. These are then loaded by a The code is currently a mess. I first wanted to see if making such a viewer was at all doable. However, now that it has become so easy to include Halide in a Python project, I will probably write up a post about it and share it in the near future :) |
|
@dragly -- This is super cool! Hope I get to play with it soon 🙂 |


This PR reworks our Python bindings and build system to support automatically packaging and deploying to (Test) PyPI.
Building LLVM here is a bear. Using caching has helped, but those caches are large and could expire. We should (later!) investigate ways to build suitable binaries using the buildbots. Building our custom manylinux docker containers on the buildbots is a start:
This currently supports the following platforms:
Wheels are provided for these platforms for each of Python 3.8-3.13.
Installing the
halidepip package makes Halide available to both the Python interpreter and to CMake'sfind_package. It is therefore recommended to install into a virtual environment rather than to a systemwide interpreter (at least globally).Depends on #8390
Fixes #888
Fixes #4876
Fixes #5360
Other notable changes:
pyproject.toml,CMakeLists.txt,vcpkg.json, andHalideRuntime.hversions in sync.setuptools-scm, which uses git tags to determine the base version number, an incrementing.devNNtag, and a+gHASHlocal suffix computed from the git hash..dev0suffix. I have already done this for all historical commits (see for examplev18.0.0.dev0)pyproject.toml-based build system,scikit-build-core.Further bugs fixed:
Pythonis now modeled as an optional feature of theHalideCMake package. For backwards compatibility, it will continue to be loaded even if not specified and available. Now, it may be listed as in theREQUIRED COMPONENTSargument tofind_package, which will raise an error if not present. In the future, the component will only be loaded if requested.Out of scope for this PR:
halide-binfor the Python-independent bits (i.e.libHalide) andhalidefor the Python bindings (depends on the former). This will improve CI performance and PyPI storage usage at the cost of considerable CI workflow complexity. The Python packaging ecosystem is not ready to build sets of dependent wheels at once.