-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pip packaging new attempt #6886
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c9fcc2
Update .gitignore for Python packaging
alexreinking 25decbb
Simplify python_bindings inclusion logic
alexreinking 63b12cc
Add dummy FindHalide.cmake
alexreinking 9ce0690
Make python_bindings standalone
alexreinking 61861fc
Move Python packaging rules to python_bindings
alexreinking c995db0
Add setuptools build
alexreinking 397ca5b
Use FetchContent by default (handle in separate PR)
alexreinking e86a07d
Merge branch 'main' into packaging/pip
steven-johnson dc4dccf
Merge branch 'main' into packaging/pip
steven-johnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This file should NOT be installed. | ||
# It is used by python_bindings (and future externalizable projects) to satisfy | ||
# calls to `find_package(Halide)` when used in-tree. | ||
|
||
message(VERBOSE "Spoofing find_package(Halide) since in-tree builds already have Halide available.") | ||
set(Halide_FOUND 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel", | ||
"scikit-build", | ||
"pybind11==2.6.2", | ||
"cmake>=3.22", | ||
"ninja; platform_system!='Windows'" | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from skbuild import setup, cmaker, utils | ||
alexreinking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from setuptools import find_packages | ||
from pathlib import Path | ||
import pybind11 | ||
from tempfile import TemporaryDirectory as mkdtemp_ctx | ||
import textwrap | ||
|
||
|
||
def get_version(): | ||
""" | ||
Builds a dummy project that prints the found Halide version. The "version" | ||
of these Halide bindings is whatever version of Halide they're building | ||
against. | ||
""" | ||
|
||
cmakelists_txt = textwrap.dedent( | ||
""" | ||
cmake_minimum_required(VERSION 3.22) | ||
project(dummy) | ||
find_package(Halide REQUIRED) | ||
file(WRITE halide_version.txt "${Halide_VERSION}") | ||
""" | ||
) | ||
|
||
with mkdtemp_ctx() as srcdir, mkdtemp_ctx() as dstdir: | ||
src, dst = Path(srcdir), Path(dstdir) | ||
(src / "CMakeLists.txt").write_text(cmakelists_txt) | ||
with utils.push_dir(dst): | ||
cmkr = cmaker.CMaker() | ||
cmkr.configure(cmake_source_dir=src, clargs=("--no-warn-unused-cli",)) | ||
version = (src / "halide_version.txt").read_text().strip() | ||
return version | ||
|
||
|
||
setup( | ||
name="halide", | ||
version=get_version(), | ||
author="The Halide team", | ||
author_email="", | ||
description="", | ||
long_description=Path("readme.md").read_text(), | ||
python_requires=">=3.6", | ||
packages=find_packages(where="src"), | ||
package_dir={"": "src"}, | ||
cmake_args=[ | ||
f"-Dpybind11_ROOT={pybind11.get_cmake_dir()}", | ||
"-DCMAKE_REQUIRE_FIND_PACKAGE_pybind11=YES", | ||
"-DHalide_INSTALL_PYTHONDIR=src", | ||
"-DCMAKE_INSTALL_RPATH=$ORIGIN", | ||
"-DHalide_Python_INSTALL_IMPORTED_DEPS=ON", | ||
"--no-warn-unused-cli", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orthogonal to this PR, but we should probably document why we use this version of pybind11; IIRC it's because it's a version that we believe to be readily available on multiple distros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, nm, it's
scikit-build
in pipThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I no longer recall, so to-do in another PR. Maybe create an issue about upgrading it? Maybe there were breaking API changes?