• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@rules_python//python:defs.bzl", "py_library")
16load("//pw_build:python.bzl", "pw_py_test")
17
18# Unlike most Pigweed modules, this package is private by default. This is
19# because use of pw_env_setup in the Bazel ecosystem is largely nonsense, so
20# nobody should ever be allowed to reference almost everything in here.
21package(default_visibility = ["//visibility:private"])
22
23licenses(["notice"])
24
25exports_files([
26    "pw_env_setup/cipd_setup/.cipd_version",
27    "pw_env_setup/cipd_setup/.cipd_version.digests",
28    "pw_env_setup/virtualenv_setup/constraint.list",
29    "pw_env_setup/virtualenv_setup/constraint_hashes_darwin.list",
30    "pw_env_setup/virtualenv_setup/constraint_hashes_linux.list",
31    "pw_env_setup/virtualenv_setup/constraint_hashes_windows.list",
32    "pw_env_setup/virtualenv_setup/pigweed_upstream_requirements.txt",
33    "pw_env_setup/virtualenv_setup/python_base_requirements.txt",
34    "pw_env_setup/virtualenv_setup/upstream_requirements_darwin_lock.txt",
35    "pw_env_setup/virtualenv_setup/upstream_requirements_linux_lock.txt",
36    "pw_env_setup/virtualenv_setup/upstream_requirements_windows_lock.txt",
37] + glob(["pw_env_setup/**/*.json"]))
38
39# Downstream projects should set this label flag to point to their pigweed.json
40# file.
41label_flag(
42    name = "pigweed_json",
43    # We don't provide a default pigweed.json. Every project needs their own!
44    build_setting_default = "//pw_build:unspecified_backend",
45)
46
47py_library(
48    name = "pw_env_setup",
49    srcs = [
50        "pw_env_setup/config_file.py",
51    ],
52    imports = ["."],
53    # This library should be considered Pigweed implementation details.
54    # Projects outside of Pigweed should never directly depend on the API of
55    # this module.
56    visibility = ["//:__subpackages__"],
57    deps = [
58        "@rules_python//python/runfiles",
59    ],
60)
61
62py_library(
63    name = "pw_env_setup_private",
64    srcs = [
65        "pw_env_setup/__init__.py",
66        "pw_env_setup/apply_visitor.py",
67        "pw_env_setup/batch_visitor.py",
68        "pw_env_setup/cipd_setup/__init__.py",
69        "pw_env_setup/cipd_setup/update.py",
70        "pw_env_setup/cipd_setup/wrapper.py",
71        "pw_env_setup/config_file.py",
72        "pw_env_setup/environment.py",
73        "pw_env_setup/github_visitor.py",
74        "pw_env_setup/gni_visitor.py",
75        "pw_env_setup/json_visitor.py",
76        "pw_env_setup/python_packages.py",
77        "pw_env_setup/shell_visitor.py",
78        "pw_env_setup/virtualenv_setup/__init__.py",
79        "pw_env_setup/virtualenv_setup/__main__.py",
80        "pw_env_setup/virtualenv_setup/install.py",
81    ],
82    data = [
83        "pw_env_setup/cipd_setup/.cipd_version",
84        "pw_env_setup/cipd_setup/.cipd_version.digests",
85        "pw_env_setup/cipd_setup/arm.json",
86        "pw_env_setup/cipd_setup/bazelisk.json",
87        "pw_env_setup/cipd_setup/buildifier.json",
88        "pw_env_setup/cipd_setup/clang.json",
89        "pw_env_setup/cipd_setup/clang_next.json",
90        "pw_env_setup/cipd_setup/cmake.json",
91        "pw_env_setup/cipd_setup/compatibility.json",
92        "pw_env_setup/cipd_setup/coverage.json",
93        "pw_env_setup/cipd_setup/default.json",
94        "pw_env_setup/cipd_setup/doxygen.json",
95        "pw_env_setup/cipd_setup/flatc.json",
96        "pw_env_setup/cipd_setup/go.json",
97        "pw_env_setup/cipd_setup/host_tools.json",
98        "pw_env_setup/cipd_setup/kythe.json",
99        "pw_env_setup/cipd_setup/luci.json",
100        "pw_env_setup/cipd_setup/msrv_python.json",
101        "pw_env_setup/cipd_setup/openjdk.json",
102        "pw_env_setup/cipd_setup/pigweed.json",
103        "pw_env_setup/cipd_setup/python.json",
104        "pw_env_setup/cipd_setup/python310.json",
105        "pw_env_setup/cipd_setup/python311.json",
106        "pw_env_setup/cipd_setup/rbe.json",
107        "pw_env_setup/cipd_setup/riscv.json",
108        "pw_env_setup/cipd_setup/ruff.json",
109        "pw_env_setup/cipd_setup/testing.json",
110        "pw_env_setup/cipd_setup/upstream.json",
111        "pw_env_setup/cipd_setup/web.json",
112        "pw_env_setup/virtualenv_setup/constraint.list",
113        "pw_env_setup/virtualenv_setup/constraint_hashes_linux.list",
114        "pw_env_setup/virtualenv_setup/python_base_requirements.txt",
115        ":pigweed_json",
116    ],
117    imports = ["."],
118    # Nobody in the Bazel ecosystem should ever use these parts of pw_env_setup.
119    visibility = ["//docs:__pkg__"],
120    deps = [
121        "@python_packages//six",
122    ],
123)
124
125pw_py_test(
126    name = "config_file_test",
127    srcs = ["config_file_test.py"],
128    deps = [
129        ":pw_env_setup",
130    ],
131)
132
133pw_py_test(
134    name = "json_visitor_test",
135    srcs = ["json_visitor_test.py"],
136    deps = [
137        ":pw_env_setup_private",
138        "@python_packages//six",
139    ],
140)
141
142pw_py_test(
143    name = "cipd_setup_update_test",
144    srcs = ["cipd_setup_update_test.py"],
145    deps = [
146        ":pw_env_setup_private",
147        "@python_packages//parameterized",
148    ],
149)
150
151pw_py_test(
152    name = "environment_test",
153    srcs = ["environment_test.py"],
154    deps = [
155        ":pw_env_setup_private",
156    ],
157)
158
159pw_py_test(
160    name = "python_packages_test",
161    srcs = ["python_packages_test.py"],
162    deps = [
163        ":pw_env_setup_private",
164        "@python_packages//toml",
165    ],
166)
167