-
Notifications
You must be signed in to change notification settings - Fork 54
/
BUILD.tpl
68 lines (58 loc) · 1.75 KB
/
BUILD.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
licenses(["restricted"])
package(default_visibility = ["//visibility:public"])
# Point both runtimes to the same python binary to ensure we always
# use the python binary specified by ./configure.py script.
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
py_runtime(
name = "py2_runtime",
interpreter_path = "%{PYTHON_BIN_PATH}",
python_version = "PY2",
)
py_runtime(
name = "py3_runtime",
interpreter_path = "%{PYTHON_BIN_PATH}",
python_version = "PY3",
)
py_runtime_pair(
name = "py_runtime_pair",
py2_runtime = ":py2_runtime",
py3_runtime = ":py3_runtime",
)
toolchain(
name = "py_toolchain",
toolchain = ":py_runtime_pair",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
# See https://docs.python.org/3/extending/windows.html
cc_import(
name = "python_lib",
interface_library = select({
"@platforms//os:windows": ":python_import_lib",
# A placeholder for Unix platforms which makes --no_build happy.
"//conditions:default": "not-existing.lib",
}),
system_provided = 1,
)
cc_library(
name = "python_headers",
hdrs = [":python_include"],
deps = select({
"@platforms//os:windows": [":python_lib"],
"//conditions:default": [],
}),
includes = ["python_include"],
)
cc_library(
name = "python_embed",
hdrs = [":python_include"],
deps = select({
"@platforms//os:windows": [":python_lib"],
"//conditions:default": [],
}),
includes = ["python_include"],
linkopts = ["%{PYTHON_EMBED_LINKOPTS}"],
copts = ["%{PYTHON_EMBED_COPTS}"],
)
%{PYTHON_INCLUDE_GENRULE}
%{PYTHON_IMPORT_LIB_GENRULE}