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 e953b0a

Browse filesBrowse files
aiutobrandjon
authored andcommitted
Use rules_pkg to create distributions (bazel-contrib#234)
This adds a packaging target to create a Bazel Federation-compliant distribution.
1 parent 5a45316 commit e953b0a
Copy full SHA for e953b0a

File tree

Expand file treeCollapse file tree

9 files changed

+103
-6
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+103
-6
lines changed

‎BUILD

Copy file name to clipboardExpand all lines: BUILD
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ package(default_visibility = ["//visibility:public"])
1515

1616
licenses(["notice"]) # Apache 2.0
1717

18-
exports_files(["LICENSE"])
18+
exports_files(["LICENSE", "version.bzl"])
19+
20+
filegroup(
21+
name = "distribution",
22+
srcs = [
23+
"BUILD",
24+
"LICENSE",
25+
"internal_deps.bzl",
26+
"internal_setup.bzl",
27+
"//python:distribution",
28+
"//tools:distribution",
29+
],
30+
visibility = ["//distro:__pkg__"],
31+
)

‎WORKSPACE

Copy file name to clipboardExpand all lines: WORKSPACE
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
workspace(name = "rules_python")
1616

1717
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18+
1819
http_archive(
1920
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",
21+
url = "https://github.com/bazelbuild/bazel-federation/releases/download/0.0.1/bazel_federation-0.0.1.tar.gz",
22+
sha256 = "506dfbfd74ade486ac077113f48d16835fdf6e343e1d4741552b450cfc2efb53",
2423
)
2524

2625
load("@bazel_federation//:repositories.bzl", "rules_python_deps")
@@ -29,6 +28,9 @@ rules_python_deps()
2928
load("@bazel_federation//setup:rules_python.bzl", "rules_python_setup")
3029
rules_python_setup(use_pip=True)
3130

31+
# Everything below this line is used only for developing rules_python. Users
32+
# should not copy it to their WORKSPACE.
33+
3234
load("//:internal_deps.bzl", "rules_python_internal_deps")
3335
rules_python_internal_deps()
3436

‎distro/BUILD

Copy file name to clipboard
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package(
2+
default_visibility = ["//visibility:private"],
3+
)
4+
5+
load("@rules_python//:version.bzl", "version")
6+
load("@rules_pkg//:pkg.bzl", "pkg_tar")
7+
load("@rules_pkg//releasing:defs.bzl", "print_rel_notes")
8+
9+
# Build the artifact to put on the github release page.
10+
pkg_tar(
11+
name = "rules_python-%s" % version,
12+
srcs = [
13+
"//:distribution",
14+
],
15+
extension = "tar.gz",
16+
# It is all source code, so make it read-only.
17+
mode = "0444",
18+
# Make it owned by root so it does not have the uid of the CI robot.
19+
owner = "0.0",
20+
package_dir = ".",
21+
strip_prefix = ".",
22+
)
23+
24+
print_rel_notes(
25+
name = "relnotes",
26+
outs = ["relnotes.txt"],
27+
deps_method = "py_repositories",
28+
repo = "rules_python",
29+
setup_file = "python:repositories.bzl",
30+
toolchains_method = "rules_python_toolchains",
31+
version = version,
32+
)

‎internal_deps.bzl

Copy file name to clipboardExpand all lines: internal_deps.bzl
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_federation//:repositories.bzl", "bazel_stardoc")
1+
load("@bazel_federation//:repositories.bzl", "bazel_stardoc", "rules_pkg")
22
load("@bazel_federation//:third_party_repositories.bzl", "futures_2_whl", "futures_3_whl", "google_cloud_language_whl", "grpc_whl", "mock_whl", "subpar")
33
load("@rules_python//python:pip.bzl", "pip_import")
44

@@ -18,6 +18,9 @@ def rules_python_internal_deps():
1818
piptool()
1919
examples()
2020

21+
# For packaging and distribution
22+
rules_pkg()
23+
2124

2225
def piptool():
2326
pip_import(

‎python/BUILD

Copy file name to clipboardExpand all lines: python/BUILD
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ package(default_visibility = ["//visibility:public"])
2828

2929
licenses(["notice"]) # Apache 2.0
3030

31+
filegroup(
32+
name = "distribution",
33+
srcs = glob(["**"]) + [
34+
"//python/constraints:distribution",
35+
"//python/runfiles:distribution",
36+
],
37+
visibility = ["//:__pkg__"],
38+
)
39+
3140
# ========= Core rules =========
3241

3342
exports_files([

‎python/constraints/BUILD

Copy file name to clipboardExpand all lines: python/constraints/BUILD
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ package(default_visibility = ["//visibility:public"])
1616

1717
licenses(["notice"])
1818

19+
filegroup(
20+
name = "distribution",
21+
srcs = glob(["**"]),
22+
visibility = ["//python:__pkg__"],
23+
)
24+
1925
# A constraint_setting to use for constraints related to the location of the
2026
# system Python 2 interpreter on a platform.
2127
alias(

‎python/runfiles/BUILD

Copy file name to clipboardExpand all lines: python/runfiles/BUILD
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232

3333
load("//python:defs.bzl", "py_library")
3434

35+
filegroup(
36+
name = "distribution",
37+
srcs = glob(["**"]),
38+
visibility = ["//python:__pkg__"],
39+
)
40+
3541
py_library(
3642
name = "runfiles",
3743
srcs = ["runfiles.py"],

‎tools/BUILD

Copy file name to clipboardExpand all lines: tools/BUILD
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ licenses(["notice"]) # Apache 2.0
1717

1818
# These files are generated and updated by ./update_tools.sh
1919
exports_files(["piptool.par", "whltool.par"])
20+
21+
filegroup(
22+
name = "distribution",
23+
srcs = [
24+
"BUILD",
25+
] + glob([
26+
"*.par",
27+
]),
28+
visibility = ["//:__pkg__"],
29+
)

‎version.bzl

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""The version of rules_python."""
15+
16+
version = "0.0.1"

0 commit comments

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