• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright 2023 The Bazel Authors. All rights reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -o errexit -o nounset -o pipefail
17
18# Set by GH actions, see
19# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
20TAG=${GITHUB_REF_NAME}
21# A prefix is added to better match the GitHub generated archives.
22PREFIX="rules_python-${TAG}"
23ARCHIVE="rules_python-$TAG.tar.gz"
24git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
25SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
26
27cat > release_notes.txt << EOF
28## Using Bzlmod with Bazel 6
29
30**NOTE: bzlmod support is still beta. APIs subject to change.**
31
32Add to your \`MODULE.bazel\` file:
33
34\`\`\`starlark
35bazel_dep(name = "rules_python", version = "${TAG}")
36
37pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
38
39pip.parse(
40    name = "pip",
41    requirements_lock = "//:requirements_lock.txt",
42)
43
44use_repo(pip, "pip")
45\`\`\`
46
47## Using WORKSPACE
48
49Paste this snippet into your \`WORKSPACE\` file:
50
51\`\`\`starlark
52load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
53
54http_archive(
55    name = "rules_python",
56    sha256 = "${SHA}",
57    strip_prefix = "${PREFIX}",
58    url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
59)
60
61load("@rules_python//python:repositories.bzl", "py_repositories")
62
63py_repositories()
64\`\`\`
65
66### Gazelle plugin
67
68Paste this snippet into your \`WORKSPACE\` file:
69
70\`\`\`starlark
71load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
72http_archive(
73    name = "rules_python_gazelle_plugin",
74    sha256 = "${SHA}",
75    strip_prefix = "${PREFIX}/gazelle",
76    url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
77)
78
79# To compile the rules_python gazelle extension from source,
80# we must fetch some third-party go dependencies that it uses.
81
82load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
83
84_py_gazelle_deps()
85\`\`\`
86EOF
87