generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vendored AWS CLI as initial scaffolding
This sets up the initial dependencies and file structures for adding an AWS CLI target. This currently supports only AWS CLI v1. This also temporarily disables bzlmod while we work through Python dependency exposure.
- Loading branch information
1 parent
afe5f33
commit 7a17ea6
Showing
6 changed files
with
161 additions
and
3 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
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 +1,40 @@ | ||
# Marker that this is the root of a Bazel workspace. | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("//aws:repositories.bzl", "aws_register_toolchains") | ||
|
||
http_archive( | ||
name = "rules_python", | ||
sha256 = "0a8003b044294d7840ac7d9d73eef05d6ceb682d7516781a4ec62eeb34702578", | ||
strip_prefix = "rules_python-0.24.0", | ||
url = "https://github.com/bazelbuild/rules_python/releases/download/0.24.0/rules_python-0.24.0.tar.gz", | ||
) | ||
|
||
http_archive( | ||
name = "bazel_skylib", | ||
sha256 = "de9d2cedea7103d20c93a5cc7763099728206bd5088342d0009315913a592cc0", | ||
strip_prefix = "bazel-skylib-1.4.2", | ||
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/refs/tags/1.4.2.tar.gz"], | ||
) | ||
|
||
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") | ||
load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies") | ||
|
||
py_repositories() | ||
|
||
python_register_toolchains( | ||
name = "python3", | ||
python_version = "3.10", | ||
) | ||
|
||
load("@python3//:defs.bzl", "interpreter") | ||
|
||
pip_install_dependencies() | ||
|
||
aws_register_toolchains( | ||
name = "arbitrary", | ||
aws_version = "1.14.2", | ||
register = False, | ||
) | ||
|
||
load("@aws_cli//:requirements.bzl", _aws_install_deps = "install_deps") | ||
|
||
_aws_install_deps(python_interpreter_target = interpreter) |
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 @@ | ||
exports_files(["**"]) |
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,98 @@ | ||
commit 7a48f25c940c96770ec873d7563c4b033b3869b9 | ||
Author: Alex Eagle <[email protected]> | ||
Date: Tue Apr 4 20:57:15 2023 -0700 | ||
|
||
Add a py_binary to execute the cli. | ||
|
||
To create the requirements.bzl file, here is what I did: | ||
- discover runtime dependencies by scanning the setup.py for install_requires | ||
- create a requirements.in with those dependencies and run through the usual rules_python incantations | ||
(I did this by patching it in the rules_python/examples/pip_parse) | ||
- copy the resulting requirements.bzl, and remove the | ||
"python_interpreter_target": "@python39_x86_64-unknown-linux-gn | ||
u//:bin/python3" | ||
entry that causes errors. | ||
|
||
diff --git a/BUILD b/BUILD | ||
new file mode 100644 | ||
index 000000000..6d73846d5 | ||
--- /dev/null | ||
+++ b/BUILD | ||
@@ -0,0 +1 @@ | ||
+# No targets in this package | ||
diff --git a/awscli/BUILD b/awscli/BUILD | ||
new file mode 100644 | ||
index 000000000..b63937386 | ||
--- /dev/null | ||
+++ b/awscli/BUILD | ||
@@ -0,0 +1,12 @@ | ||
+load("@rules_python//python:defs.bzl", "py_library") | ||
+load("@aws_cli//:requirements.bzl", "all_requirements") | ||
+ | ||
+package(default_visibility = ["//visibility:public"]) | ||
+ | ||
+py_library( | ||
+ name = "awscli_lib", | ||
+ imports = [".."], | ||
+ srcs = glob(["**/*.py"]), | ||
+ data = glob(["**/*"], exclude=["**/*.py"]), | ||
+ deps = all_requirements, | ||
+) | ||
diff --git a/requirements.bzl b/requirements.bzl | ||
new file mode 100644 | ||
index 000000000..60e1bb045 | ||
--- /dev/null | ||
+++ b/requirements.bzl | ||
@@ -0,0 +1,52 @@ | ||
+"""Starlark representation of locked requirements. | ||
+ | ||
+@generated by rules_python pip_parse repository rule | ||
+from @//:requirements_lock.txt | ||
+""" | ||
+ | ||
+load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library") | ||
+ | ||
+all_requirements = ["@awscli_botocore//:pkg", "@awscli_colorama//:pkg", "@awscli_docutils//:pkg", "@awscli_jmespath//:pkg", "@awscli_pyasn1//:pkg", "@awscli_python_dateutil//:pkg", "@awscli_pyyaml//:pkg", "@awscli_rsa//:pkg", "@awscli_s3transfer//:pkg", "@awscli_six//:pkg", "@awscli_urllib3//:pkg"] | ||
+ | ||
+all_whl_requirements = ["@awscli_botocore//:whl", "@awscli_colorama//:whl", "@awscli_docutils//:whl", "@awscli_jmespath//:whl", "@awscli_pyasn1//:whl", "@awscli_python_dateutil//:whl", "@awscli_pyyaml//:whl", "@awscli_rsa//:whl", "@awscli_s3transfer//:whl", "@awscli_six//:whl", "@awscli_urllib3//:whl"] | ||
+ | ||
+_packages = [("awscli_botocore", "botocore==1.16.19 --hash=sha256:5cb537e7a4cf2d59a2a8dfbbc8e14ec3bc5b640eb81a1bf3bb0523c0a75e6b1b --hash=sha256:7b8b1f082665c8670b9aa70143ee527c5d04939fe027a63ac5958359be20ccb0"), ("awscli_colorama", "colorama==0.4.3 --hash=sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff --hash=sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"), ("awscli_docutils", "docutils==0.15.2 --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 --hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99"), ("awscli_jmespath", "jmespath==0.10.0 --hash=sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9 --hash=sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f"), ("awscli_pyasn1", "pyasn1==0.4.8 --hash=sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d --hash=sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"), ("awscli_python_dateutil", "python-dateutil==2.8.2 --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"), ("awscli_pyyaml", "pyyaml==5.3.1 --hash=sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97 --hash=sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76 --hash=sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2 --hash=sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e --hash=sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648 --hash=sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf --hash=sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f --hash=sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2 --hash=sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee --hash=sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a --hash=sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d --hash=sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c --hash=sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"), ("awscli_rsa", "rsa==3.4.2 --hash=sha256:25df4e10c263fb88b5ace923dd84bf9aa7f5019687b5e55382ffcdb8bede9db5 --hash=sha256:43f682fea81c452c98d09fc316aae12de6d30c4b5c84226642cf8f8fd1c93abd"), ("awscli_s3transfer", "s3transfer==0.3.7 --hash=sha256:35627b86af8ff97e7ac27975fe0a98a312814b46c6333d8a6b889627bcd80994 --hash=sha256:efa5bd92a897b6a8d5c1383828dca3d52d0790e0756d49740563a3fb6ed03246"), ("awscli_six", "six==1.16.0 --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"), ("awscli_urllib3", "urllib3==1.25.11 --hash=sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2 --hash=sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e")] | ||
+_config = {"download_only": False, "enable_implicit_namespace_pkgs": False, "environment": {}, "extra_pip_args": [], "isolated": True, "pip_data_exclude": [], "python_interpreter": "python3", "quiet": True, "repo": "awscli", "repo_prefix": "awscli_", "timeout": 600} | ||
+_annotations = {} | ||
+ | ||
+def _clean_name(name): | ||
+ return name.replace("-", "_").replace(".", "_").lower() | ||
+ | ||
+def requirement(name): | ||
+ return "@awscli_" + _clean_name(name) + "//:pkg" | ||
+ | ||
+def whl_requirement(name): | ||
+ return "@awscli_" + _clean_name(name) + "//:whl" | ||
+ | ||
+def data_requirement(name): | ||
+ return "@awscli_" + _clean_name(name) + "//:data" | ||
+ | ||
+def dist_info_requirement(name): | ||
+ return "@awscli_" + _clean_name(name) + "//:dist_info" | ||
+ | ||
+def entry_point(pkg, script = None): | ||
+ if not script: | ||
+ script = pkg | ||
+ return "@awscli_" + _clean_name(pkg) + "//:rules_python_wheel_entry_point_" + script | ||
+ | ||
+def _get_annotation(requirement): | ||
+ # This expects to parse `setuptools==58.2.0 --hash=sha256:2551203ae6955b9876741a26ab3e767bb3242dafe86a32a749ea0d78b6792f11` | ||
+ # down to `setuptools`. | ||
+ name = requirement.split(" ")[0].split("=")[0].split("[")[0] | ||
+ return _annotations.get(name) | ||
+ | ||
+def install_deps(**whl_library_kwargs): | ||
+ whl_config = dict(_config) | ||
+ whl_config.update(whl_library_kwargs) | ||
+ for name, requirement in _packages: | ||
+ whl_library( | ||
+ name = name, | ||
+ requirement = requirement, | ||
+ annotation = _get_annotation(requirement), | ||
+ **whl_config | ||
+ ) |
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