Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe5e0fa

Browse filesBrowse files
authored
Comply with the standards of the Bazel federation (#223)
This commit allows rules_python to be a member of the Bazel federation, since it adds the required bzl files related to setup and dependencies. Moreover, it also changes the WORKSPACE to fetch all dependencies through the federation. rules_python_internal_setup() in internal_setup.bzl still needs some work since some of the dependencies don't export their proper setup functions yet, which means that the present commit has to work around that particular problem.
1 parent 4b84ad2 commit fe5e0fa
Copy full SHA for fe5e0fa

File tree

Expand file treeCollapse file tree

3 files changed

+108
-152
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+108
-152
lines changed

‎WORKSPACE

Copy file name to clipboardExpand all lines: WORKSPACE
+15-152Lines changed: 15 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -14,160 +14,23 @@
1414

1515
workspace(name = "rules_python")
1616

17-
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
18-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
19-
20-
#################################
21-
# Stardoc and its dependencies. #
22-
#################################
23-
24-
# Initialization taken from:
25-
# https://skydoc.bazel.build/docs/getting_started_stardoc.html
26-
27-
git_repository(
28-
name = "io_bazel_skydoc",
29-
remote = "https://github.com/bazelbuild/skydoc.git",
30-
tag = "0.3.0",
31-
)
32-
33-
load("@io_bazel_skydoc//:setup.bzl", "skydoc_repositories")
34-
skydoc_repositories()
35-
36-
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")
37-
rules_sass_dependencies()
38-
39-
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
40-
node_repositories()
41-
42-
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
43-
sass_repositories()
44-
45-
##########################################
46-
# Requirements for building our piptool. #
47-
##########################################
48-
49-
load("//python:pip.bzl", "pip_import")
50-
51-
pip_import(
52-
name = "piptool_deps",
53-
requirements = "//python:requirements.txt",
54-
)
55-
56-
load(
57-
"@piptool_deps//:requirements.bzl",
58-
_piptool_install = "pip_install",
59-
)
60-
61-
_piptool_install()
62-
63-
git_repository(
64-
name = "subpar",
65-
remote = "https://github.com/google/subpar",
66-
commit = "2917d275ee27d7935f7809413c74eddf71a46e5c", # 2019-08-02
67-
)
68-
69-
###################################
70-
# Test data for WHL tool testing. #
71-
###################################
72-
73-
http_file(
74-
name = "grpc_whl",
75-
downloaded_file_path = "grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl",
76-
sha256 = "c232d6d168cb582e5eba8e1c0da8d64b54b041dd5ea194895a2fe76050916561",
77-
# From https://pypi.python.org/pypi/grpcio/1.6.0
78-
urls = [("https://pypi.python.org/packages/c6/28/" +
79-
"67651b4eabe616b27472c5518f9b2aa3f63beab8f62100b26f05ac428639/" +
80-
"grpcio-1.6.0-cp27-cp27m-manylinux1_i686.whl")],
81-
)
82-
83-
http_file(
84-
name = "futures_3_1_1_whl",
85-
downloaded_file_path = "futures-3.1.1-py2-none-any.whl",
86-
sha256 = "c4884a65654a7c45435063e14ae85280eb1f111d94e542396717ba9828c4337f",
87-
# From https://pypi.python.org/pypi/futures
88-
urls = [("https://pypi.python.org/packages/a6/1c/" +
89-
"72a18c8c7502ee1b38a604a5c5243aa8c2a64f4bba4e6631b1b8972235dd/" +
90-
"futures-3.1.1-py2-none-any.whl")],
91-
)
92-
93-
http_file(
94-
name = "futures_2_2_0_whl",
95-
downloaded_file_path = "futures-2.2.0-py2.py3-none-any.whl",
96-
sha256 = "9fd22b354a4c4755ad8c7d161d93f5026aca4cfe999bd2e53168f14765c02cd6",
97-
# From https://pypi.python.org/pypi/futures/2.2.0
98-
urls = [("https://pypi.python.org/packages/d7/1d/" +
99-
"68874943aa37cf1c483fc61def813188473596043158faa6511c04a038b4/" +
100-
"futures-2.2.0-py2.py3-none-any.whl")],
101-
)
102-
103-
http_file(
104-
name = "mock_whl",
105-
downloaded_file_path = "mock-2.0.0-py2.py3-none-any.whl",
106-
sha256 = "5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1",
107-
# From https://pypi.python.org/pypi/mock
108-
urls = [("https://pypi.python.org/packages/e6/35/" +
109-
"f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/" +
110-
"mock-2.0.0-py2.py3-none-any.whl")],
111-
)
112-
113-
http_file(
114-
name = "google_cloud_language_whl",
115-
downloaded_file_path = "google_cloud_language-0.29.0-py2.py3-none-any.whl",
116-
sha256 = "a2dd34f0a0ebf5705dcbe34bd41199b1d0a55c4597d38ed045bd183361a561e9",
117-
# From https://pypi.python.org/pypi/google-cloud-language
118-
urls = [("https://pypi.python.org/packages/6e/86/" +
119-
"cae57e4802e72d9e626ee5828ed5a646cf4016b473a4a022f1038dba3460/" +
120-
"google_cloud_language-0.29.0-py2.py3-none-any.whl")],
121-
)
122-
123-
#########################
124-
# Imports for examples. #
125-
#########################
126-
127-
pip_import(
128-
name = "examples_helloworld",
129-
requirements = "//examples/helloworld:requirements.txt",
130-
)
131-
132-
load(
133-
"@examples_helloworld//:requirements.bzl",
134-
_helloworld_install = "pip_install",
135-
)
136-
137-
_helloworld_install()
138-
139-
pip_import(
140-
name = "examples_version",
141-
requirements = "//examples/version:requirements.txt",
142-
)
143-
144-
load(
145-
"@examples_version//:requirements.bzl",
146-
_version_install = "pip_install",
17+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18+
http_archive(
19+
name = "bazel_federation",
20+
url = "https://github.com/bazelbuild/bazel-federation/archive/4da9b5f83ffae17613fa025a0701fa9db9350d41.zip",
21+
sha256 = "5b1cf980e327a8f30fc81c00c04007c543e17c09ed612fb645753936de790ed7",
22+
strip_prefix = "bazel-federation-4da9b5f83ffae17613fa025a0701fa9db9350d41",
23+
type = "zip",
14724
)
14825

149-
_version_install()
26+
load("@bazel_federation//:repositories.bzl", "rules_python_deps")
27+
rules_python_deps()
15028

151-
pip_import(
152-
name = "examples_boto",
153-
requirements = "//examples/boto:requirements.txt",
154-
)
29+
load("@bazel_federation//setup:rules_python.bzl", "rules_python_setup")
30+
rules_python_setup(use_pip=True)
15531

156-
load(
157-
"@examples_boto//:requirements.bzl",
158-
_boto_install = "pip_install",
159-
)
160-
161-
_boto_install()
162-
163-
pip_import(
164-
name = "examples_extras",
165-
requirements = "//examples/extras:requirements.txt",
166-
)
167-
168-
load(
169-
"@examples_extras//:requirements.bzl",
170-
_extras_install = "pip_install",
171-
)
32+
load("//:internal_deps.bzl", "rules_python_internal_deps")
33+
rules_python_internal_deps()
17234

173-
_extras_install()
35+
load("//:internal_setup.bzl", "rules_python_internal_setup")
36+
rules_python_internal_setup()

‎internal_deps.bzl

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
load("@bazel_federation//:repositories.bzl", "bazel_stardoc", "rules_sass")
2+
load("@bazel_federation//:third_party_repositories.bzl", "futures_2_whl", "futures_3_whl", "google_cloud_language_whl", "grpc_whl", "mock_whl", "subpar")
3+
load("@rules_python//python:pip.bzl", "pip_import")
4+
5+
6+
def rules_python_internal_deps():
7+
bazel_stardoc()
8+
rules_sass()
9+
10+
subpar()
11+
12+
# Test data for WHL tool testing.
13+
futures_2_whl()
14+
futures_3_whl()
15+
google_cloud_language_whl()
16+
grpc_whl()
17+
mock_whl()
18+
19+
piptool()
20+
examples()
21+
22+
23+
def piptool():
24+
pip_import(
25+
name = "piptool_deps",
26+
requirements = "@rules_python//python:requirements.txt",
27+
)
28+
29+
30+
def examples():
31+
pip_import(
32+
name = "examples_helloworld",
33+
requirements = "@rules_python//examples/helloworld:requirements.txt",
34+
)
35+
pip_import(
36+
name = "examples_version",
37+
requirements = "@rules_python//examples/version:requirements.txt",
38+
)
39+
pip_import(
40+
name = "examples_boto",
41+
requirements = "@rules_python//examples/boto:requirements.txt",
42+
)
43+
pip_import(
44+
name = "examples_extras",
45+
requirements = "@rules_python//examples/extras:requirements.txt",
46+
)

‎internal_setup.bzl

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
2+
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
3+
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")
4+
load("@io_bazel_skydoc//:setup.bzl", "skydoc_repositories")
5+
6+
# Requirements for building our piptool.
7+
load(
8+
"@piptool_deps//:requirements.bzl",
9+
_piptool_install = "pip_install",
10+
)
11+
12+
# Imports for examples.
13+
load(
14+
"@examples_helloworld//:requirements.bzl",
15+
_helloworld_install = "pip_install",
16+
)
17+
load(
18+
"@examples_version//:requirements.bzl",
19+
_version_install = "pip_install",
20+
)
21+
load(
22+
"@examples_boto//:requirements.bzl",
23+
_boto_install = "pip_install",
24+
)
25+
load(
26+
"@examples_extras//:requirements.bzl",
27+
_extras_install = "pip_install",
28+
)
29+
30+
31+
def rules_python_internal_setup():
32+
# TODO(fweikert): The following four function calls should be replaced with
33+
# bazel_stardoc_setup(), rules_sass_setup() and rules_nodejs_setup().
34+
# However, those setup functions don't exist yet.
35+
skydoc_repositories()
36+
rules_sass_dependencies()
37+
node_repositories()
38+
sass_repositories()
39+
40+
# Requirements for building our piptool.
41+
_piptool_install()
42+
43+
# Imports for examples.
44+
_helloworld_install()
45+
_version_install()
46+
_boto_install()
47+
_extras_install()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.