Skip to content

Commit c2418e9

Browse files
tarun292facebook-github-bot
authored andcommitted
Add support for pretty table third party python library in OSS
Summary: This diff does two things: - The python profiler CLI tool depends on the third-party library `prettytable`. We add support for this in `third-party/TARGETS` to make this tool buildable in OSS. - Added a new file `prebuilt_python_defs.bzl` to make the addition of third-party python dependencies more scalable. Reviewed By: larryliu0820 Differential Revision: D47855991 Privacy Context Container: L1124100 fbshipit-source-id: 914791cd9c754167f5b2bf12bb1b7037ae19d062
1 parent 82ecb51 commit c2418e9

File tree

3 files changed

+47
-30
lines changed

3 files changed

+47
-30
lines changed

shim/xplat/executorch/build/env_interface.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ _EXTERNAL_DEPS = {
3131
"gflags": [], # TODO(larryliu0820): Add support
3232
"gmock": [], # TODO(larryliu0820): Add support
3333
"libtorch": [], # TODO(larryliu0820): Add support
34+
"prettytable": "//third-party:prettytable",
3435
"pybind11": [], # TODO(larryliu0820): Add support
3536
# Core C++ PyTorch functionality like Tensor and ScalarType.
3637
"torch-core-cpp": [], # TODO(larryliu0820): Add support

third-party/TARGETS

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
load("@fbsource//xplat/executorch/build/runtime_wrapper.bzl", "runtime")
2-
load("@prelude//rules.bzl", "prebuilt_python_library", "remote_file")
3-
load(":glob_defs.bzl", "subdir_glob")
42
load(":gflags.bzl", "define_gflags")
3+
load(":glob_defs.bzl", "subdir_glob")
4+
load(":prebuilt_python_defs.bzl", "add_prebuilt_python_library_targets")
55

66
define_gflags()
77

8-
# TODO(chenlai): linux-specific needs to be fixed
9-
remote_file(
10-
name = "pyyaml-download",
11-
url = "https://files.pythonhosted.org/packages/12/fc/a4d5a7554e0067677823f7265cb3ae22aed8a238560b5133b58cda252dad/PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl",
12-
sha1 = "11aa9c5fe2d890b6a73212beadc7c8a4265ebc39",
13-
out = "pyyaml.whl",
14-
)
15-
16-
prebuilt_python_library(
17-
name = "pyyaml",
18-
binary_src = ":pyyaml-download",
19-
visibility = ["PUBLIC"],
20-
deps = [":pyyaml-download"],
21-
)
22-
23-
# TODO(chenlai): linux-specific needs to be fixed
24-
remote_file(
25-
name = "typing-extensions-download",
26-
url = "https://files.pythonhosted.org/packages/75/e1/932e06004039dd670c9d5e1df0cd606bf46e29a28e65d5bb28e894ea29c9/typing_extensions-4.2.0-py3-none-any.whl",
27-
sha1 = "ff0849420e94f425818bff5d0f25e3cdfaba8601",
28-
out = "typing_extensions-4.2.0-py3-none-any.whl",
29-
)
8+
prebuilt_python_library_defs = {
9+
"prettytable": {
10+
"additional_deps": [":wcwidth"],
11+
"out": "prettytable-3.8.0-py3-none-any.whl",
12+
"sha1": "22a8347abd5a72e4ea8d5f5bb2956d956148e6fa",
13+
"url": "https://files.pythonhosted.org/packages/25/1e/4c284713b092ec384fad4399452f43f6446ad9aabc9c0b3c3c0920cc53b6/prettytable-3.8.0-py3-none-any.whl",
14+
},
15+
"pyyaml": {
16+
"out": "pyyaml.whl",
17+
"sha1": "11aa9c5fe2d890b6a73212beadc7c8a4265ebc39",
18+
"url": "https://files.pythonhosted.org/packages/12/fc/a4d5a7554e0067677823f7265cb3ae22aed8a238560b5133b58cda252dad/PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl",
19+
},
20+
"typing-extensions": {
21+
"out": "typing_extensions-4.2.0-py3-none-any.whl",
22+
"sha1": "ff0849420e94f425818bff5d0f25e3cdfaba8601",
23+
"url": "https://files.pythonhosted.org/packages/75/e1/932e06004039dd670c9d5e1df0cd606bf46e29a28e65d5bb28e894ea29c9/typing_extensions-4.2.0-py3-none-any.whl",
24+
},
25+
"wcwidth": {
26+
"out": "wcwidth-0.1.5-py2.py3-none-any.whl",
27+
"sha1": "f132a6fdff56d1d8bf572f00ef6985a327784bbd",
28+
"url": "https://files.pythonhosted.org/packages/8b/30/f46badba94cedcd5ceb5918a7c5a34f3a1b9e902e045b7d8d39c1db3d99a/wcwidth-0.1.5-py2.py3-none-any.whl",
29+
},
30+
}
3031

31-
prebuilt_python_library(
32-
name = "typing-extensions",
33-
binary_src = ":typing-extensions-download",
34-
visibility = ["PUBLIC"],
35-
deps = [":typing-extensions-download"],
36-
)
32+
add_prebuilt_python_library_targets(prebuilt_python_library_defs)
3733

3834
runtime.python_library(
3935
name = "torchgen",

third-party/prebuilt_python_defs.bzl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@prelude//rules.bzl", "prebuilt_python_library", "remote_file")
2+
3+
def define_prebuilt_python_library(name, url, sha1, out, additional_deps = []):
4+
remote_file(
5+
name = "{}-download".format(name),
6+
url = url,
7+
sha1 = sha1,
8+
out = out,
9+
)
10+
11+
prebuilt_python_library(
12+
name = name,
13+
binary_src = ":{}-download".format(name),
14+
visibility = ["PUBLIC"],
15+
deps = [":{}-download".format(name)] + additional_deps,
16+
)
17+
18+
def add_prebuilt_python_library_targets(targets):
19+
for name, config in targets.items():
20+
define_prebuilt_python_library(name, **config)

0 commit comments

Comments
 (0)