-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port to use bzlmod and hermetic Python
Respell WORKSPACE.bazel into MODULE.bazel + WORKSPACE.bzlmod. For now, this means that our skylark external dependencies (like rules_python) are not upgraded by tools/upgrade.sh -- there's a TODO instead. Switch from the Ubuntu Python interpreter to a Bazel one (downloaded as an external). Since any given version of Blender only works with one specific version of CPython, this will make it easier to stay in sync long-term. This also lets us from the unittest_path_cleaner hack to avoid test pollution from Ubuntu libraries. Switch to using a pip() helper macro to specify the pip deps for our programs. The old long-hand spellings don't work with bzlmod. Switch to rules_python runfiles instead of bazel_tools runfiles. Add test/BUILD.bazel as a sub-package; writing out all of the test rules in the top-level BUILD.bazel was too much clutter.
- Loading branch information
1 parent
8fda070
commit 478e79c
Showing
17 changed files
with
166 additions
and
187 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
/.bazel | ||
/MODULE.bazel.lock |
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,51 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
module(name = "drake_blender") | ||
|
||
bazel_dep(name = "platforms", version = "0.0.10") | ||
bazel_dep(name = "rules_python", version = "0.32.2") | ||
|
||
# For the most part, a given version of Blender only supports exactly one | ||
# version of Python, so we'll pin ourselves to exactly that version. | ||
PYTHON_VERSION = "3.10" | ||
|
||
python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
python.toolchain(python_version = PYTHON_VERSION) | ||
use_repo(python, "python_versions") | ||
|
||
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | ||
pip.parse( | ||
hub_name = "requirements", | ||
python_version = PYTHON_VERSION, | ||
requirements_lock = "//:requirements.txt", | ||
) | ||
pip.parse( | ||
hub_name = "test_requirements", | ||
python_version = PYTHON_VERSION, | ||
requirements_lock = "//:test/requirements.txt", | ||
) | ||
pip.parse( | ||
hub_name = "examples_requirements", | ||
python_version = PYTHON_VERSION, | ||
requirements_lock = "//examples:requirements.txt", | ||
) | ||
use_repo(pip, "requirements") | ||
use_repo(pip, "test_requirements") | ||
use_repo(pip, "examples_requirements") | ||
|
||
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") | ||
|
||
# This is a sample file from https://www.blender.org/download/demo-files/, | ||
# licensed under CC0. Credit goes to Ramil Roosileht for creating it, | ||
# https://twitter.com/limarest_art. | ||
http_file( | ||
name = "color_attribute_painting", | ||
sha256 = "443b213229a4c863b2015beff623a700886c14928707a2fb24a6dd85fd80a207", | ||
urls = [ | ||
base + "/demo/sculpt_mode/color_attribute_painting.blend" | ||
for base in [ | ||
"https://mirrors.ocf.berkeley.edu/blender", | ||
"https://mirror.clarkson.edu/blender", | ||
] | ||
], | ||
) |
This file was deleted.
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,21 @@ | ||
# -*- bazel -*- | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
# This file provides dependencies that are not yet resolve-able via the bzlmod | ||
# module system. TODO(jwnimmer-tri) move this into MODULE.bazel as possible. | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") | ||
load("//tools:workspace_versions.bzl", "WORKSPACE_VERSIONS") | ||
|
||
[ | ||
http_file( | ||
name = name, | ||
executable = True, | ||
sha256 = sha256, | ||
url = "https://github.com/bazelbuild/buildtools/releases/download/v{}/{}".format( | ||
WORKSPACE_VERSIONS["buildifier"]["version"], | ||
name, | ||
), | ||
) | ||
for name, sha256 in WORKSPACE_VERSIONS["buildifier"]["binaries"].items() | ||
] |
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
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,52 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
load("@rules_python//python:defs.bzl", "py_test") | ||
load("@rules_python//python:pip.bzl", "compile_pip_requirements") | ||
load("//tools:defs.bzl", "bazel_lint_test", "pip", "py_lint_test") | ||
|
||
py_test( | ||
name = "server_test", | ||
srcs = ["server_test.py"], | ||
data = [ | ||
"//:server", | ||
# This texture file is a dependency for `one_texture_box.blend`. | ||
"4_color_texture.png", | ||
"depth.png", | ||
"label.png", | ||
# TODO(zachfang): Consider generating this image in the test code if | ||
# it's easier to maintain for our future use cases. | ||
"one_gltf_one_blend.label.png", | ||
"one_rgba_box.gltf", | ||
"one_rgba_one_texture_boxes.color.png", | ||
"one_rgba_one_texture_boxes.gltf", | ||
"one_texture_box.blend", | ||
"two_rgba_boxes.color.png", | ||
"two_rgba_boxes.gltf", | ||
], | ||
deps = [ | ||
pip("numpy", "[test]"), | ||
pip("pillow", "[test]"), | ||
pip("requests", "[test]"), | ||
], | ||
) | ||
|
||
bazel_lint_test( | ||
name = "bazel_lint_test", | ||
srcs = [ | ||
"BUILD.bazel", | ||
], | ||
) | ||
|
||
py_lint_test( | ||
name = "py_lint_test", | ||
srcs = [ | ||
"server_test.py", | ||
], | ||
) | ||
|
||
compile_pip_requirements( | ||
name = "requirements", | ||
requirements_in = "requirements.in", | ||
requirements_txt = "requirements.txt", | ||
tags = ["manual"], | ||
) |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.