Skip to content

Commit 7332460

Browse files
committed
Swift: teach bazel to install python dependencies
1 parent 080271f commit 7332460

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

.github/workflows/swift-codegen.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- uses: ./.github/actions/fetch-codeql
1717
- uses: bazelbuild/setup-bazelisk@v2
18-
- uses: actions/setup-python@v3
19-
with:
20-
python-version: '~3.8'
21-
cache: 'pip'
22-
- name: Install python dependencies
23-
run: |
24-
pip install -r swift/codegen/requirements.txt
2518
- name: Run unit tests
2619
run: |
2720
bazel test //swift/codegen/test --test_output=errors

.github/workflows/swift-qltest.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ jobs:
2929
- uses: actions/checkout@v3
3030
- uses: ./.github/actions/fetch-codeql
3131
- uses: bazelbuild/setup-bazelisk@v2
32-
- uses: actions/setup-python@v3
33-
with:
34-
python-version: '~3.8'
35-
cache: 'pip'
36-
- name: Install python dependencies
37-
run: |
38-
pip install -r codegen/requirements.txt
3932
- name: Build Swift extractor
4033
run: |
4134
bazel run //swift:create-extractor-pack

misc/bazel/workspace.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ def codeql_workspace(repository_name = "codeql"):
4545
"https://github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
4646
],
4747
)
48+
49+
maybe(
50+
repo_rule = http_archive,
51+
name = "rules_python",
52+
sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
53+
strip_prefix = "rules_python-0.8.1",
54+
urls = [
55+
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.1.tar.gz",
56+
],
57+
)
58+

misc/bazel/workspace_deps.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
2+
load("@rules_python//python:pip.bzl", "pip_install")
23

3-
def codeql_workspace_deps():
4+
def codeql_workspace_deps(repository_name = "codeql"):
5+
pip_install(
6+
name = "swift_codegen_deps",
7+
requirements = "@%s//swift/codegen:requirements.txt" % repository_name,
8+
)
49
rules_pkg_dependencies()

swift/codegen/lib/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
load("@swift_codegen_deps//:requirements.bzl", "requirement")
12
py_library(
23
name = "lib",
34
srcs = glob(["*.py"]),
5+
deps = [
6+
requirement("pystache"),
7+
requirement("pyyaml"),
8+
requirement("inflection"),
9+
],
410
visibility = ["//swift/codegen:__subpackages__"],
511
)

swift/codegen/test/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
load("@swift_codegen_deps//:requirements.bzl", "requirement")
2+
13
py_library(
24
name = "utils",
35
testonly = True,
46
srcs = ["utils.py"],
5-
deps = ["//swift/codegen/lib"],
7+
deps = [
8+
"//swift/codegen/lib",
9+
requirement("pytest"),
10+
],
611
)
712

813
[

0 commit comments

Comments
 (0)