File tree Expand file tree Collapse file tree 7 files changed +143
-0
lines changed Expand file tree Collapse file tree 7 files changed +143
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ load("//tensorflow:workspace.bzl", "tf_repositories")
18
18
# Please add all new TensorFlow dependencies in workspace.bzl.
19
19
tf_repositories ()
20
20
21
+ register_toolchains ("@local_config_python//:py_toolchain" )
22
+
21
23
load ("@io_bazel_rules_closure//closure:defs.bzl" , "closure_repositories" )
22
24
23
25
closure_repositories ()
Original file line number Diff line number Diff line change @@ -2,6 +2,34 @@ licenses(["restricted"])
2
2
3
3
package(default_visibility = ["//visibility:public"])
4
4
5
+ # Point both runtimes to the same python binary to ensure we always
6
+ # use the python binary specified by ./configure.py script.
7
+ load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
8
+
9
+ py_runtime(
10
+ name = "py2_runtime",
11
+ interpreter_path = "%{ PYTHON_BIN_PATH} ",
12
+ python_version = "PY2",
13
+ )
14
+
15
+ py_runtime(
16
+ name = "py3_runtime",
17
+ interpreter_path = "%{ PYTHON_BIN_PATH} ",
18
+ python_version = "PY3",
19
+ )
20
+
21
+ py_runtime_pair(
22
+ name = "py_runtime_pair",
23
+ py2_runtime = ":py2_runtime",
24
+ py3_runtime = ":py3_runtime",
25
+ )
26
+
27
+ toolchain(
28
+ name = "py_toolchain",
29
+ toolchain = ":py_runtime_pair",
30
+ toolchain_type = "@bazel_tools//tools/python:toolchain_type",
31
+ )
32
+
5
33
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
6
34
# See https://docs.python.org/3/extending/windows.html
7
35
cc_import(
Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ def _create_local_python_repository(repository_ctx):
323
323
"numpy_include" ,
324
324
)
325
325
_tpl (repository_ctx , "BUILD" , {
326
+ "%{PYTHON_BIN_PATH}" : python_bin ,
326
327
"%{PYTHON_INCLUDE_GENRULE}" : python_include_rule ,
327
328
"%{PYTHON_IMPORT_LIB_GENRULE}" : python_import_lib_genrule ,
328
329
"%{NUMPY_INCLUDE_GENRULE}" : numpy_include_rule ,
Original file line number Diff line number Diff line change @@ -2,6 +2,34 @@ licenses(["restricted"])
2
2
3
3
package (default_visibility = ["//visibility:public" ])
4
4
5
+ # Point both runtimes to the same python binary to ensure we always
6
+ # use the python binary specified by ./configure.py script.
7
+ load ("@bazel_tools//tools/python:toolchain.bzl" , "py_runtime_pair" )
8
+
9
+ py_runtime (
10
+ name = "py2_runtime" ,
11
+ interpreter_path = "/usr/bin/python2" ,
12
+ python_version = "PY2" ,
13
+ )
14
+
15
+ py_runtime (
16
+ name = "py3_runtime" ,
17
+ interpreter_path = "/usr/bin/python2" ,
18
+ python_version = "PY3" ,
19
+ )
20
+
21
+ py_runtime_pair (
22
+ name = "py_runtime_pair" ,
23
+ py2_runtime = ":py2_runtime" ,
24
+ py3_runtime = ":py3_runtime" ,
25
+ )
26
+
27
+ toolchain (
28
+ name = "py_toolchain" ,
29
+ toolchain = ":py_runtime_pair" ,
30
+ toolchain_type = "@bazel_tools//tools/python:toolchain_type" ,
31
+ )
32
+
5
33
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
6
34
# See https://docs.python.org/3/extending/windows.html
7
35
cc_import (
Original file line number Diff line number Diff line change @@ -2,6 +2,34 @@ licenses(["restricted"])
2
2
3
3
package (default_visibility = ["//visibility:public" ])
4
4
5
+ # Point both runtimes to the same python binary to ensure we always
6
+ # use the python binary specified by ./configure.py script.
7
+ load ("@bazel_tools//tools/python:toolchain.bzl" , "py_runtime_pair" )
8
+
9
+ py_runtime (
10
+ name = "py2_runtime" ,
11
+ interpreter_path = "/usr/bin/python3" ,
12
+ python_version = "PY2" ,
13
+ )
14
+
15
+ py_runtime (
16
+ name = "py3_runtime" ,
17
+ interpreter_path = "/usr/bin/python3" ,
18
+ python_version = "PY3" ,
19
+ )
20
+
21
+ py_runtime_pair (
22
+ name = "py_runtime_pair" ,
23
+ py2_runtime = ":py2_runtime" ,
24
+ py3_runtime = ":py3_runtime" ,
25
+ )
26
+
27
+ toolchain (
28
+ name = "py_toolchain" ,
29
+ toolchain = ":py_runtime_pair" ,
30
+ toolchain_type = "@bazel_tools//tools/python:toolchain_type" ,
31
+ )
32
+
5
33
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
6
34
# See https://docs.python.org/3/extending/windows.html
7
35
cc_import (
Original file line number Diff line number Diff line change @@ -2,6 +2,34 @@ licenses(["restricted"])
2
2
3
3
package (default_visibility = ["//visibility:public" ])
4
4
5
+ # Point both runtimes to the same python binary to ensure we always
6
+ # use the python binary specified by ./configure.py script.
7
+ load ("@bazel_tools//tools/python:toolchain.bzl" , "py_runtime_pair" )
8
+
9
+ py_runtime (
10
+ name = "py2_runtime" ,
11
+ interpreter_path = "C:/Python36/python.exe" ,
12
+ python_version = "PY2" ,
13
+ )
14
+
15
+ py_runtime (
16
+ name = "py3_runtime" ,
17
+ interpreter_path = "C:/Python36/python.exe" ,
18
+ python_version = "PY3" ,
19
+ )
20
+
21
+ py_runtime_pair (
22
+ name = "py_runtime_pair" ,
23
+ py2_runtime = ":py2_runtime" ,
24
+ py3_runtime = ":py3_runtime" ,
25
+ )
26
+
27
+ toolchain (
28
+ name = "py_toolchain" ,
29
+ toolchain = ":py_runtime_pair" ,
30
+ toolchain_type = "@bazel_tools//tools/python:toolchain_type" ,
31
+ )
32
+
5
33
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
6
34
# See https://docs.python.org/3/extending/windows.html
7
35
cc_import (
Original file line number Diff line number Diff line change @@ -2,6 +2,34 @@ licenses(["restricted"])
2
2
3
3
package (default_visibility = ["//visibility:public" ])
4
4
5
+ # Point both runtimes to the same python binary to ensure we always
6
+ # use the python binary specified by ./configure.py script.
7
+ load ("@bazel_tools//tools/python:toolchain.bzl" , "py_runtime_pair" )
8
+
9
+ py_runtime (
10
+ name = "py2_runtime" ,
11
+ interpreter_path = "C:/Python37/python.exe" ,
12
+ python_version = "PY2" ,
13
+ )
14
+
15
+ py_runtime (
16
+ name = "py3_runtime" ,
17
+ interpreter_path = "C:/Python37/python.exe" ,
18
+ python_version = "PY3" ,
19
+ )
20
+
21
+ py_runtime_pair (
22
+ name = "py_runtime_pair" ,
23
+ py2_runtime = ":py2_runtime" ,
24
+ py3_runtime = ":py3_runtime" ,
25
+ )
26
+
27
+ toolchain (
28
+ name = "py_toolchain" ,
29
+ toolchain = ":py_runtime_pair" ,
30
+ toolchain_type = "@bazel_tools//tools/python:toolchain_type" ,
31
+ )
32
+
5
33
# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
6
34
# See https://docs.python.org/3/extending/windows.html
7
35
cc_import (
You can’t perform that action at this time.
0 commit comments