@@ -25,16 +25,6 @@ PYBIND_DEPS = [
2525 "@rules_python//python/cc:current_py_cc_headers" ,
2626]
2727
28- # Builds a Python extension module using pybind11.
29- # This can be directly used in Python with the import statement.
30- # Assuming the name NAME, the following targets will be defined:
31- # 1. NAME.so - the shared/dynamic library for the extension module
32- # 2. NAME.pyd - a copy of NAME.so named for Python on Windows; see
33- # https://github.com/pybind/pybind11_bazel/issues/74
34- # 3. NAME - an alias pointing to either NAME.so or NAME.pyd as per
35- # the platform OS (not-Windows or Windows, respectively)
36- # Generally, the user will "depend" on this extension module via the
37- # data attribute of their py_* target; specifying NAME is preferred.
3828def pybind_extension (
3929 name ,
4030 copts = [],
@@ -43,6 +33,28 @@ def pybind_extension(
4333 tags = [],
4434 deps = [],
4535 ** kwargs ):
36+ """Builds a Python extension module using pybind11.
37+
38+ Args:
39+ name: The name of the extension module.
40+ copts: Compiler options for building the module.
41+ features: Features required for building the module.
42+ linkopts: Linker options for building the module.
43+ tags: Tags for the module.
44+ deps: Dependencies required for building the module.
45+ **kwargs: Additional keyword arguments.
46+
47+ This can be directly used in Python with the import statement.
48+ Assuming the name NAME, the following targets will be defined:
49+ 1. NAME.so - the shared/dynamic library for the extension module
50+ 2. NAME.pyd - a copy of NAME.so named for Python on Windows; see
51+ https://github.com/pybind/pybind11_bazel/issues/74
52+ 3. NAME - an alias pointing to either NAME.so or NAME.pyd as per
53+ the platform OS (not-Windows or Windows, respectively)
54+ Generally, the user will "depend" on this extension module via the
55+ data attribute of their py_* target; specifying NAME is preferred.
56+ """
57+
4658 # Mark common dependencies as required for build_cleaner.
4759 tags = tags + ["req_dep=%s" % dep for dep in PYBIND_DEPS ]
4860
@@ -82,14 +94,15 @@ def pybind_extension(
8294 visibility = kwargs .get ("visibility" ),
8395 )
8496
85- # Builds a pybind11 compatible library. This can be linked to a pybind_extension.
8697def pybind_library (
8798 name ,
8899 copts = [],
89100 features = [],
90101 tags = [],
91102 deps = [],
92103 ** kwargs ):
104+ """Builds a pybind11 compatible library. This can be linked to a pybind_extension."""
105+
93106 # Mark common dependencies as required for build_cleaner.
94107 tags = tags + ["req_dep=%s" % dep for dep in PYBIND_DEPS ]
95108
@@ -102,14 +115,15 @@ def pybind_library(
102115 ** kwargs
103116 )
104117
105- # Builds a C++ test for a pybind_library.
106118def pybind_library_test (
107119 name ,
108120 copts = [],
109121 features = [],
110122 tags = [],
111123 deps = [],
112124 ** kwargs ):
125+ """Builds a C++ test for a pybind_library."""
126+
113127 # Mark common dependencies as required for build_cleaner.
114128 tags = tags + ["req_dep=%s" % dep for dep in PYBIND_DEPS ]
115129
0 commit comments