-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): move examples to a nested WORKSPACE (#337)
This lets users understand the example in isolation. They can copy/paste the example directory and it works correctly. This refactors the existing examples which are quite weak, only really demonstrating pip usage. This makes room for examples demonstrating other features (like protocol buffers) or package managers (like poetry). In a later commit I'll add bazel-integration-testing so we get a test target that confirms the examples build (including their WORKSPACE being self-contained)
- Loading branch information
Showing
21 changed files
with
71 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# For bazel-in-bazel testing | ||
# Trick bazel into treating BUILD files under examples/* and e2e/* as being regular files | ||
# This lets us glob() up all the files inside the examples to make them inputs to tests | ||
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) | ||
# To update these lines, run this command: | ||
# sed -i.bak "/^[^#].*--deleted_packages/s#=.*#=$(find examples/*/* \( -name BUILD -or -name BUILD.bazel \) | xargs -n 1 dirname | paste -sd, -)#" .bazelrc && rm .bazelrc.bak | ||
build --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld | ||
query --deleted_packages=examples/pip/boto,examples/pip/extras,examples/pip/helloworld |
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,5 @@ | ||
# pip example | ||
|
||
This shows how you can point Bazel at your requirements.txt file to get dependencies automatically installed. | ||
|
||
It also shows how a monorepo might have multiple python packages which each have a separate requirements.txt file. |
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,41 @@ | ||
workspace(name = "pip_example") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_python", | ||
url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.2/rules_python-0.0.2.tar.gz", | ||
strip_prefix = "rules_python-0.0.2", | ||
sha256 = "b5668cde8bb6e3515057ef465a35ad712214962f0b3a314e551204266c7be90c", | ||
) | ||
|
||
load("@rules_python//python:pip.bzl", "pip_import", "pip_repositories") | ||
|
||
pip_repositories() | ||
|
||
pip_import( | ||
name = "helloworld_deps", | ||
requirements = "//helloworld:requirements.txt", | ||
) | ||
|
||
load("@helloworld_deps//:requirements.bzl", _helloworld_install = "pip_install") | ||
|
||
_helloworld_install() | ||
|
||
pip_import( | ||
name = "boto_deps", | ||
requirements = "//boto:requirements.txt", | ||
) | ||
|
||
load("@boto_deps//:requirements.bzl", _boto_install = "pip_install") | ||
|
||
_boto_install() | ||
|
||
pip_import( | ||
name = "extras_deps", | ||
requirements = "//extras:requirements.txt", | ||
) | ||
|
||
load("@extras_deps//:requirements.bzl", _extras_install = "pip_install") | ||
|
||
_extras_install() |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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