-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathworkspace.bzl
53 lines (46 loc) · 1.53 KB
/
workspace.bzl
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
"""WORKSPACE setup functions."""
def _tensorflow_pip_impl(ctx):
python_program = ctx.which(ctx.attr.python_program)
library_path = ctx.execute([
python_program,
"-c",
"import tensorflow; print(tensorflow.sysconfig.get_lib())",
])
include_path = ctx.execute([
python_program,
"-c",
"import tensorflow; print(tensorflow.sysconfig.get_include())",
])
if library_path.return_code != 0:
fail("Failed to find library path. Did you remember to pip install " +
"tensorflow?: %s" % library_path.stderr)
if include_path.return_code != 0:
fail("Failed to find include path. Did you remember to pip install " +
"tensorflow?: %s" % include_path.stderr)
if "linux" in ctx.os.name:
library_filename = "libtensorflow_framework.so.2"
elif "mac" in ctx.os.name:
library_filename = "libtensorflow_framework.2.dylib"
ctx.symlink("/".join([library_path.stdout.strip(), library_filename]),
library_filename)
ctx.symlink(include_path.stdout.strip(), "include")
ctx.file("BUILD", """
cc_library(
name = "libtensorflow_framework",
srcs = ["{0}"],
hdrs = glob(["include/**"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
""".format(library_filename))
tensorflow_pip = repository_rule(
implementation = _tensorflow_pip_impl,
attrs = {
"python_program": attr.string(default = "python3"),
},
)
def tensorflow_compression_workspace():
tensorflow_pip(
name = "tensorflow_pip",
python_program = "python3",
)