xref: /aosp_15_r20/external/bazelbuild-rules_python/WORKSPACE (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1*60517a1eSAndroid Build Coastguard Worker# Copyright 2017 The Bazel Authors. All rights reserved.
2*60517a1eSAndroid Build Coastguard Worker#
3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*60517a1eSAndroid Build Coastguard Worker#
7*60517a1eSAndroid Build Coastguard Worker#    http://www.apache.org/licenses/LICENSE-2.0
8*60517a1eSAndroid Build Coastguard Worker#
9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*60517a1eSAndroid Build Coastguard Worker# limitations under the License.
14*60517a1eSAndroid Build Coastguard Worker
15*60517a1eSAndroid Build Coastguard Workerworkspace(name = "rules_python")
16*60517a1eSAndroid Build Coastguard Worker
17*60517a1eSAndroid Build Coastguard Worker# Everything below this line is used only for developing rules_python. Users
18*60517a1eSAndroid Build Coastguard Worker# should not copy it to their WORKSPACE.
19*60517a1eSAndroid Build Coastguard Worker
20*60517a1eSAndroid Build Coastguard Workerload("//:internal_deps.bzl", "rules_python_internal_deps")
21*60517a1eSAndroid Build Coastguard Worker
22*60517a1eSAndroid Build Coastguard Workerrules_python_internal_deps()
23*60517a1eSAndroid Build Coastguard Worker
24*60517a1eSAndroid Build Coastguard Workerload("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
25*60517a1eSAndroid Build Coastguard Worker
26*60517a1eSAndroid Build Coastguard Workerrules_jvm_external_deps()
27*60517a1eSAndroid Build Coastguard Worker
28*60517a1eSAndroid Build Coastguard Workerload("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
29*60517a1eSAndroid Build Coastguard Worker
30*60517a1eSAndroid Build Coastguard Workerrules_jvm_external_setup()
31*60517a1eSAndroid Build Coastguard Worker
32*60517a1eSAndroid Build Coastguard Workerload("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps")
33*60517a1eSAndroid Build Coastguard Worker
34*60517a1eSAndroid Build Coastguard Workerstardoc_external_deps()
35*60517a1eSAndroid Build Coastguard Worker
36*60517a1eSAndroid Build Coastguard Workerload("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")
37*60517a1eSAndroid Build Coastguard Worker
38*60517a1eSAndroid Build Coastguard Workerstardoc_pinned_maven_install()
39*60517a1eSAndroid Build Coastguard Worker
40*60517a1eSAndroid Build Coastguard Workerload("//:internal_setup.bzl", "rules_python_internal_setup")
41*60517a1eSAndroid Build Coastguard Worker
42*60517a1eSAndroid Build Coastguard Workerrules_python_internal_setup()
43*60517a1eSAndroid Build Coastguard Worker
44*60517a1eSAndroid Build Coastguard Workerload("//python:repositories.bzl", "python_register_multi_toolchains")
45*60517a1eSAndroid Build Coastguard Workerload("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
46*60517a1eSAndroid Build Coastguard Worker
47*60517a1eSAndroid Build Coastguard Workerpython_register_multi_toolchains(
48*60517a1eSAndroid Build Coastguard Worker    name = "python",
49*60517a1eSAndroid Build Coastguard Worker    default_version = MINOR_MAPPING.values()[-2],
50*60517a1eSAndroid Build Coastguard Worker    # Integration tests verify each version, so register all of them.
51*60517a1eSAndroid Build Coastguard Worker    python_versions = TOOL_VERSIONS.keys(),
52*60517a1eSAndroid Build Coastguard Worker)
53*60517a1eSAndroid Build Coastguard Worker
54*60517a1eSAndroid Build Coastguard Workerload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
55*60517a1eSAndroid Build Coastguard Worker
56*60517a1eSAndroid Build Coastguard Worker# Used for Bazel CI
57*60517a1eSAndroid Build Coastguard Workerhttp_archive(
58*60517a1eSAndroid Build Coastguard Worker    name = "bazelci_rules",
59*60517a1eSAndroid Build Coastguard Worker    sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
60*60517a1eSAndroid Build Coastguard Worker    strip_prefix = "bazelci_rules-1.0.0",
61*60517a1eSAndroid Build Coastguard Worker    url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
62*60517a1eSAndroid Build Coastguard Worker)
63*60517a1eSAndroid Build Coastguard Worker
64*60517a1eSAndroid Build Coastguard Workerload("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
65*60517a1eSAndroid Build Coastguard Worker
66*60517a1eSAndroid Build Coastguard Worker# Creates a default toolchain config for RBE.
67*60517a1eSAndroid Build Coastguard Worker# Use this as is if you are using the rbe_ubuntu16_04 container,
68*60517a1eSAndroid Build Coastguard Worker# otherwise refer to RBE docs.
69*60517a1eSAndroid Build Coastguard Workerrbe_preconfig(
70*60517a1eSAndroid Build Coastguard Worker    name = "buildkite_config",
71*60517a1eSAndroid Build Coastguard Worker    toolchain = "ubuntu1804-bazel-java11",
72*60517a1eSAndroid Build Coastguard Worker)
73*60517a1eSAndroid Build Coastguard Worker
74*60517a1eSAndroid Build Coastguard Workerlocal_repository(
75*60517a1eSAndroid Build Coastguard Worker    name = "rules_python_gazelle_plugin",
76*60517a1eSAndroid Build Coastguard Worker    path = "gazelle",
77*60517a1eSAndroid Build Coastguard Worker)
78*60517a1eSAndroid Build Coastguard Worker
79*60517a1eSAndroid Build Coastguard Worker# The rules_python gazelle extension has some third-party go dependencies
80*60517a1eSAndroid Build Coastguard Worker# which we need to fetch in order to compile it.
81*60517a1eSAndroid Build Coastguard Workerload("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
82*60517a1eSAndroid Build Coastguard Worker
83*60517a1eSAndroid Build Coastguard Worker# See: https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md
84*60517a1eSAndroid Build Coastguard Worker# This rule loads and compiles various go dependencies that running gazelle
85*60517a1eSAndroid Build Coastguard Worker# for python requirements.
86*60517a1eSAndroid Build Coastguard Worker_py_gazelle_deps()
87*60517a1eSAndroid Build Coastguard Worker
88*60517a1eSAndroid Build Coastguard Worker# This interpreter is used for various rules_python dev-time tools
89*60517a1eSAndroid Build Coastguard Workerload("@python//3.11.9:defs.bzl", "interpreter")
90*60517a1eSAndroid Build Coastguard Worker
91*60517a1eSAndroid Build Coastguard Worker#####################
92*60517a1eSAndroid Build Coastguard Worker# Install twine for our own runfiles wheel publishing.
93*60517a1eSAndroid Build Coastguard Worker# Eventually we might want to install twine automatically for users too, see:
94*60517a1eSAndroid Build Coastguard Worker# https://github.com/bazelbuild/rules_python/issues/1016.
95*60517a1eSAndroid Build Coastguard Workerload("@rules_python//python:pip.bzl", "pip_parse")
96*60517a1eSAndroid Build Coastguard Worker
97*60517a1eSAndroid Build Coastguard Workerpip_parse(
98*60517a1eSAndroid Build Coastguard Worker    name = "rules_python_publish_deps",
99*60517a1eSAndroid Build Coastguard Worker    python_interpreter_target = interpreter,
100*60517a1eSAndroid Build Coastguard Worker    requirements_darwin = "//tools/publish:requirements_darwin.txt",
101*60517a1eSAndroid Build Coastguard Worker    requirements_lock = "//tools/publish:requirements.txt",
102*60517a1eSAndroid Build Coastguard Worker    requirements_windows = "//tools/publish:requirements_windows.txt",
103*60517a1eSAndroid Build Coastguard Worker)
104*60517a1eSAndroid Build Coastguard Worker
105*60517a1eSAndroid Build Coastguard Workerload("@rules_python_publish_deps//:requirements.bzl", "install_deps")
106*60517a1eSAndroid Build Coastguard Worker
107*60517a1eSAndroid Build Coastguard Workerinstall_deps()
108*60517a1eSAndroid Build Coastguard Worker
109*60517a1eSAndroid Build Coastguard Workerpip_parse(
110*60517a1eSAndroid Build Coastguard Worker    name = "pypiserver",
111*60517a1eSAndroid Build Coastguard Worker    python_interpreter_target = interpreter,
112*60517a1eSAndroid Build Coastguard Worker    requirements_lock = "//examples/wheel:requirements_server.txt",
113*60517a1eSAndroid Build Coastguard Worker)
114*60517a1eSAndroid Build Coastguard Worker
115*60517a1eSAndroid Build Coastguard Workerload("@pypiserver//:requirements.bzl", install_pypiserver = "install_deps")
116*60517a1eSAndroid Build Coastguard Worker
117*60517a1eSAndroid Build Coastguard Workerinstall_pypiserver()
118*60517a1eSAndroid Build Coastguard Worker
119*60517a1eSAndroid Build Coastguard Worker#####################
120*60517a1eSAndroid Build Coastguard Worker# Install sphinx for doc generation.
121*60517a1eSAndroid Build Coastguard Worker
122*60517a1eSAndroid Build Coastguard Workerpip_parse(
123*60517a1eSAndroid Build Coastguard Worker    name = "dev_pip",
124*60517a1eSAndroid Build Coastguard Worker    python_interpreter_target = interpreter,
125*60517a1eSAndroid Build Coastguard Worker    requirements_lock = "//docs:requirements.txt",
126*60517a1eSAndroid Build Coastguard Worker)
127*60517a1eSAndroid Build Coastguard Worker
128*60517a1eSAndroid Build Coastguard Workerload("@dev_pip//:requirements.bzl", docs_install_deps = "install_deps")
129*60517a1eSAndroid Build Coastguard Worker
130*60517a1eSAndroid Build Coastguard Workerdocs_install_deps()
131*60517a1eSAndroid Build Coastguard Worker
132*60517a1eSAndroid Build Coastguard Worker# This wheel is purely here to validate the wheel extraction code. It's not
133*60517a1eSAndroid Build Coastguard Worker# intended for anything else.
134*60517a1eSAndroid Build Coastguard Workerhttp_file(
135*60517a1eSAndroid Build Coastguard Worker    name = "wheel_for_testing",
136*60517a1eSAndroid Build Coastguard Worker    downloaded_file_path = "numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
137*60517a1eSAndroid Build Coastguard Worker    sha256 = "0d60fbae8e0019865fc4784745814cff1c421df5afee233db6d88ab4f14655a2",
138*60517a1eSAndroid Build Coastguard Worker    urls = [
139*60517a1eSAndroid Build Coastguard Worker        "https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
140*60517a1eSAndroid Build Coastguard Worker    ],
141*60517a1eSAndroid Build Coastguard Worker)
142*60517a1eSAndroid Build Coastguard Worker
143*60517a1eSAndroid Build Coastguard Worker# rules_proto expects //external:python_headers to point at the python headers.
144*60517a1eSAndroid Build Coastguard Workerbind(
145*60517a1eSAndroid Build Coastguard Worker    name = "python_headers",
146*60517a1eSAndroid Build Coastguard Worker    actual = "//python/cc:current_py_cc_headers",
147*60517a1eSAndroid Build Coastguard Worker)
148