Skip to content

Make python SDK targets configurable #109

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ PYBIND_FEATURES = [

PYBIND_DEPS = [
Label("@pybind11//:pybind11"),
"@rules_python//python/cc:current_py_cc_headers",
]

def pybind_extension(
Expand All @@ -32,6 +31,7 @@ def pybind_extension(
linkopts = [],
tags = [],
deps = [],
python_headers_target = "@rules_python//python/cc:current_py_cc_headers",
**kwargs):
"""Builds a Python extension module using pybind11.

Expand All @@ -42,6 +42,7 @@ def pybind_extension(
linkopts: Linker options for building the module.
tags: Tags for the module.
deps: Dependencies required for building the module.
python_headers_target: The cc_library target that exposes the python C SDK headers
**kwargs: Additional keyword arguments.

This can be directly used in Python with the import statement.
Expand Down Expand Up @@ -72,7 +73,7 @@ def pybind_extension(
}),
linkshared = 1,
tags = tags,
deps = deps + PYBIND_DEPS,
deps = deps + PYBIND_DEPS + [python_headers_target],
**kwargs
)

Expand Down Expand Up @@ -100,6 +101,7 @@ def pybind_library(
features = [],
tags = [],
deps = [],
python_headers_target = "@rules_python//python/cc:current_py_cc_headers",
**kwargs):
"""Builds a pybind11 compatible library. This can be linked to a pybind_extension."""

Expand All @@ -111,7 +113,7 @@ def pybind_library(
copts = copts + PYBIND_COPTS,
features = features + PYBIND_FEATURES,
tags = tags,
deps = deps + PYBIND_DEPS,
deps = deps + PYBIND_DEPS + [python_headers_target],
**kwargs
)

Expand All @@ -121,6 +123,8 @@ def pybind_library_test(
features = [],
tags = [],
deps = [],
python_headers_target = "@rules_python//python/cc:current_py_cc_headers",
python_library_target = "@rules_python//python/cc:current_py_cc_libs",
**kwargs):
"""Builds a C++ test for a pybind_library."""

Expand All @@ -133,7 +137,8 @@ def pybind_library_test(
features = features + PYBIND_FEATURES,
tags = tags,
deps = deps + PYBIND_DEPS + [
"@rules_python//python/cc:current_py_cc_libs",
python_headers_target,
python_library_target,
],
**kwargs
)
Expand Down