xref: /aosp_15_r20/external/bazelbuild-rules_python/WORKSPACE (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1# Copyright 2017 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
15workspace(name = "rules_python")
16
17# Everything below this line is used only for developing rules_python. Users
18# should not copy it to their WORKSPACE.
19
20load("//:internal_deps.bzl", "rules_python_internal_deps")
21
22rules_python_internal_deps()
23
24load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
25
26rules_jvm_external_deps()
27
28load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
29
30rules_jvm_external_setup()
31
32load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps")
33
34stardoc_external_deps()
35
36load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")
37
38stardoc_pinned_maven_install()
39
40load("//:internal_setup.bzl", "rules_python_internal_setup")
41
42rules_python_internal_setup()
43
44load("//python:repositories.bzl", "python_register_multi_toolchains")
45load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
46
47python_register_multi_toolchains(
48    name = "python",
49    default_version = MINOR_MAPPING.values()[-2],
50    # Integration tests verify each version, so register all of them.
51    python_versions = TOOL_VERSIONS.keys(),
52)
53
54load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
55
56# Used for Bazel CI
57http_archive(
58    name = "bazelci_rules",
59    sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
60    strip_prefix = "bazelci_rules-1.0.0",
61    url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
62)
63
64load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
65
66# Creates a default toolchain config for RBE.
67# Use this as is if you are using the rbe_ubuntu16_04 container,
68# otherwise refer to RBE docs.
69rbe_preconfig(
70    name = "buildkite_config",
71    toolchain = "ubuntu1804-bazel-java11",
72)
73
74local_repository(
75    name = "rules_python_gazelle_plugin",
76    path = "gazelle",
77)
78
79# The rules_python gazelle extension has some third-party go dependencies
80# which we need to fetch in order to compile it.
81load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
82
83# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
84# This rule loads and compiles various go dependencies that running gazelle
85# for python requirements.
86_py_gazelle_deps()
87
88# This interpreter is used for various rules_python dev-time tools
89load("@python//3.11.9:defs.bzl", "interpreter")
90
91#####################
92# Install twine for our own runfiles wheel publishing.
93# Eventually we might want to install twine automatically for users too, see:
94# https://github.com/bazelbuild/rules_python/issues/1016.
95load("@rules_python//python:pip.bzl", "pip_parse")
96
97pip_parse(
98    name = "rules_python_publish_deps",
99    python_interpreter_target = interpreter,
100    requirements_darwin = "//tools/publish:requirements_darwin.txt",
101    requirements_lock = "//tools/publish:requirements.txt",
102    requirements_windows = "//tools/publish:requirements_windows.txt",
103)
104
105load("@rules_python_publish_deps//:requirements.bzl", "install_deps")
106
107install_deps()
108
109pip_parse(
110    name = "pypiserver",
111    python_interpreter_target = interpreter,
112    requirements_lock = "//examples/wheel:requirements_server.txt",
113)
114
115load("@pypiserver//:requirements.bzl", install_pypiserver = "install_deps")
116
117install_pypiserver()
118
119#####################
120# Install sphinx for doc generation.
121
122pip_parse(
123    name = "dev_pip",
124    python_interpreter_target = interpreter,
125    requirements_lock = "//docs:requirements.txt",
126)
127
128load("@dev_pip//:requirements.bzl", docs_install_deps = "install_deps")
129
130docs_install_deps()
131
132# This wheel is purely here to validate the wheel extraction code. It's not
133# intended for anything else.
134http_file(
135    name = "wheel_for_testing",
136    downloaded_file_path = "numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
137    sha256 = "0d60fbae8e0019865fc4784745814cff1c421df5afee233db6d88ab4f14655a2",
138    urls = [
139        "https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
140    ],
141)
142
143# rules_proto expects //external:python_headers to point at the python headers.
144bind(
145    name = "python_headers",
146    actual = "//python/cc:current_py_cc_headers",
147)
148