Skip to content

Commit

Permalink
Document how to find Halide from a pip installation (#8411)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinking authored Sep 6, 2024
1 parent 3a34741 commit 63609cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ Currently, we provide wheels for: Windows x86-64, macOS x86-64, macOS arm64, and
Linux x86-64. The Linux wheels are built for manylinux_2_28, which makes them
broadly compatible (Debian 10, Ubuntu 18.10, Fedora 29).

*For C++ usage of the pip package:* On Linux and macOS, CMake's `find_package`
command should find Halide as long as you're in the same virtual environment you
installed it in. On Windows, you will need to add the virtual environment root
directory to `CMAKE_PREFIX_PATH`. This can be done by running
`set CMAKE_PREFIX_PATH=%VIRTUAL_ENV%` in `cmd`.

Other build systems can find the Halide root path by running `python -c
"import halide; print(halide.install_dir())"`.

## Homebrew

Alternatively, if you use macOS, you can install Halide via
Expand Down
12 changes: 8 additions & 4 deletions doc/HalideCMakePackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ vendor-specific extensions to C++. This is not necessary to simply use Halide,
but we do not allow such extensions in the Halide repo.

Finally, we use [`find_package`][find_package] to locate Halide on your system.
If Halide is not globally installed, you will need to add the root of the Halide
installation directory to [`CMAKE_PREFIX_PATH`][cmake_prefix_path] at the CMake
command line.
When using the pip package on Linux and macOS, CMake's `find_package`
command should find Halide as long as you're in the same virtual environment you
installed it in. On Windows, you will need to add the virtual environment root
directory to [`CMAKE_PREFIX_PATH`][cmake_prefix_path]:

```shell
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/path/to/Halide-install"
$ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%VIRTUAL_ENV%
```

If `find_package` cannot find Halide, set `CMAKE_PREFIX_PATH` to the Halide
installation directory.

## JIT mode

To use Halide in JIT mode (like the [tutorials][halide-tutorials] do, for
Expand Down
8 changes: 8 additions & 0 deletions python_bindings/src/halide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ def patch_dll_dirs():
del patch_dll_dirs

from .halide_ import *
# noinspection PyUnresolvedReferences
from .halide_ import _, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9


def install_dir():
import os
return os.path.dirname(__file__)


from ._generator_helpers import (
_create_python_generator,
_generatorcontext_enter,
Expand Down

0 comments on commit 63609cc

Please sign in to comment.