8000 Use rules_pkg to create distributions by aiuto · Pull Request #234 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content

Use rules_pkg to create distributions #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
8000
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])
exports_files(["LICENSE", "version.bzl"])

filegroup(
name = "distribution",
srcs = [
"BUILD",
"LICENSE",
"internal_deps.bzl",
"internal_setup.bzl",
"//python:distribution",
"//tools:distribution",
],
visibility = ["//distro:__pkg__"],
)
10 changes: 6 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
workspace(name = "rules_python")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_federation",
url = "https://github.com/bazelbuild/bazel-federation/archive/4da9b5f83ffae17613fa025a0701fa9db9350d41.zip",
sha256 = "5b1cf980e327a8f30fc81c00c04007c543e17c09ed612fb645753936de790ed7",
strip_prefix = "bazel-federation-4da9b5f83ffae17613fa025a0701fa9db9350d41",
type = "zip",
url = "https://github.com/bazelbuild/bazel-federation/releases/download/0.0.1/bazel_federation-0.0.1.tar.gz",
sha256 = "506dfbfd74ade486ac077113f48d16835fdf6e343e1d4741552b450cfc2efb53",
)

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

# Everything below this line is used only for developing rules_python. Users
# should not copy it to their WORKSPACE.

load("//:internal_deps.bzl", "rules_python_internal_deps")
rules_python_internal_deps()

Expand Down
32 changes: 32 additions & 0 deletions distro/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package(
default_visibility = ["//visibility:private"],
)

load("@rules_python//:version.bzl", "version")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_pkg//releasing:defs.bzl", "print_rel_notes")

# Build the artifact to put on the github release page.
pkg_tar(
name = "rules_python-%s" % version,
srcs = [
"//:distribution",
],
extension = "tar.gz",
# It is all source code, so make it read-only.
mode = "0444",
# Make it owned by root so it does not have the uid of the CI robot.
owner = "0.0",
package_dir = ".",
strip_prefix = ".",
)

print_rel_notes(
name = "relnotes",
outs = ["relnotes.txt"],
deps_method = "py_repositories",
repo = "rules_python",
setup_file = "python:repositories.bzl",
toolchains_method = "rules_python_toolchains",
version = version,
)
5 changes: 4 additions & 1 deletion internal_deps.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@bazel_federation//:repositories.bzl", "bazel_stardoc")
load("@bazel_federation//:repositories.bzl", "bazel_stardoc", "rules_pkg")
load("@bazel_federation//:third_party_repositories.bzl", "futures_2_whl", "futures_3_whl", "google_cloud_language_whl", "grpc_whl", "mock_whl", "subpar")
load("@rules_python//python:pip.bzl", "pip_import")

Expand All @@ -18,6 +18,9 @@ def rules_python_internal_deps():
piptool()
examples()

# For packaging and distribution
rules_pkg()


def piptool():
pip_import(
Expand Down
9 changes: 9 additions & 0 deletions python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//python/constraints:distribution",
"//python/runfiles:distribution",
],
visibility = ["//:__pkg__"],
)

# ========= Core rules =========

exports_files([
Expand Down
6 changes: 6 additions & 0 deletions python/constraints/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"])

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

# A constraint_setting to use for constraints related to the location of the
# system Python 2 interpreter on a platform.
alias(
Expand Down
6 changes: 6 additions & 0 deletions python/runfiles/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@

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

filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

py_library(
name = "runfiles",
srcs = ["runfiles.py"],
Expand Down
10 changes: 10 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ licenses(["notice"]) # Apache 2.0

# These files are generated and updated by ./update_tools.sh
exports_files(["piptool.par", "whltool.par"])

filegroup(
name = "distribution",
srcs = [
"BUILD",
] + glob([
"*.par",
]),
visibility = ["//:__pkg__"],
)
16 changes: 16 additions & 0 deletions version.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The version of rules_python."""

version = "0.0.1"
0