-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
rules_python
to provide pip dependencies
Setup a hermetic Python 3.10 interpreter and pip environment with numpy, matplotlib, pandas, and tornado. This commit defines a `//scripts:plot_data` py_binary that uses the provided interpreter and pip environment: bazel run //scripts:plot_data -- <abs-path-csvfile> Due to the Bazel execution root, the absolute path to the csvfile must be provided. Change-Id: I039c77b81a37ae4abd4f2b1bb2fd2f8613c05ad9
- Loading branch information
Showing
7 changed files
with
437 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
load("@rules_python//python:pip.bzl", "compile_pip_requirements") | ||
|
||
# https://github.com/bazelbuild/rules_python/blob/1722988cc407b08a4e7770295452076706823f9d/docs/pip.md#compile_pip_requirements | ||
compile_pip_requirements(name = "requirements") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
numpy | ||
matplotlib | ||
pandas | ||
tornado |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Toyota Motor Corporation. All rights reserved. | ||
# Copyright 2022-2023 Woven Planet. All rights reserved. | ||
""" | ||
Sets up Python environment with Pip dependencies for users of @bazel_tooling. | ||
""" | ||
|
||
load("@python3_10//:defs.bzl", "interpreter") | ||
load("@rules_python//python:pip.bzl", "pip_parse") | ||
load("//python:requirements.bzl", "install_deps") | ||
|
||
def tooling_python_setup(): | ||
pip_parse( | ||
name = "pip", | ||
python_interpreter_target = interpreter, | ||
requirements = "//python:requirements.txt", | ||
) | ||
|
||
install_deps() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@rules_python//python:defs.bzl", "py_binary") | ||
load("@pip//:requirements.bzl", "requirement") | ||
|
||
py_binary( | ||
name = "plot_data", | ||
srcs = ["plot_data.py"], | ||
deps = [ | ||
requirement("numpy"), | ||
requirement("matplotlib"), | ||
requirement("pandas"), | ||
requirement("tornado"), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters