Skip to content

Commit 21ed5dd

Browse files
authored
1 parent b9a715b commit 21ed5dd

File tree

4 files changed

+246
-1
lines changed

4 files changed

+246
-1
lines changed
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
"""rules_req_compile"""
2+
3+
module(
4+
name = "rules_req_compile",
5+
version = "1.0.0rc40",
6+
)
7+
8+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
9+
bazel_dep(name = "platforms", version = "1.0.0")
10+
bazel_dep(name = "rules_cc", version = "0.2.4")
11+
bazel_dep(name = "rules_python", version = "1.7.0")
12+
bazel_dep(name = "rules_venv", version = "0.7.0")
13+
14+
bazel_dep(name = "buildozer", version = "8.2.0.bcr.1", dev_dependency = True)
15+
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True)
16+
17+
python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
18+
python.toolchain(
19+
configure_coverage_tool = True,
20+
# Working around a rules_python issue with docker
21+
# https://github.com/bazelbuild/rules_python/pull/713
22+
ignore_root_user_error = True,
23+
is_default = True,
24+
python_version = "3.11",
25+
)
26+
use_repo(
27+
python,
28+
"python_3_11_aarch64-apple-darwin",
29+
"python_3_11_aarch64-unknown-linux-gnu",
30+
"python_3_11_x86_64-apple-darwin",
31+
"python_3_11_x86_64-pc-windows-msvc",
32+
"python_3_11_x86_64-unknown-linux-gnu",
33+
python311 = "python_3_11",
34+
)
35+
36+
requirements = use_extension("//:extensions.bzl", "requirements")
37+
requirements.parse(
38+
name = "req_compile_deps",
39+
requirements_locks = {
40+
"//3rdparty:requirements.linux_aarch64.txt": "@rules_req_compile//tools/constraints:linux_aarch_any",
41+
"//3rdparty:requirements.linux_x86_64.txt": "@rules_req_compile//tools/constraints:linux_x86_64",
42+
"//3rdparty:requirements.macos_aarch64.txt": "@rules_req_compile//tools/constraints:macos_aarch64",
43+
"//3rdparty:requirements.macos_x86_64.txt": "@rules_req_compile//tools/constraints:macos_x86_64",
44+
"//3rdparty:requirements.windows_x86_64.txt": "@rules_req_compile//tools/constraints:windows_x86_64",
45+
},
46+
)
47+
use_repo(requirements, "req_compile_deps")
48+
49+
sdist_deps = use_extension("//private:sdist.bzl", "sdist_deps")
50+
use_repo(
51+
sdist_deps,
52+
"req_compile_sdist_compiler__pip",
53+
"req_compile_sdist_compiler__setuptools",
54+
"req_compile_sdist_compiler__wheel",
55+
)
56+
57+
dev_requirements = use_extension("//extensions:python.bzl", "requirements", dev_dependency = True)
58+
dev_requirements.parse(
59+
name = "req_compile_test_sdist",
60+
# Required to compile sdists
61+
interpreter_linux_aarch64 = "@python_3_11_x86_64-unknown-linux-gnu//:python",
62+
interpreter_linux_x86_64 = "@python_3_11_x86_64-unknown-linux-gnu//:python",
63+
interpreter_macos_aarch64 = "@python_3_11_aarch64-apple-darwin//:python",
64+
interpreter_macos_x86_64 = "@python_3_11_x86_64-apple-darwin//:python",
65+
interpreter_windows = "@python_3_11_x86_64-pc-windows-msvc//:python",
66+
requirements_lock = "//private/tests/sdist:requirements.txt",
67+
)
68+
use_repo(dev_requirements, "req_compile_test_sdist", "req_compile_test_sdist__pyspark")
69+
70+
dev_requirements.parse(
71+
name = "req_compile_test_simple",
72+
requirements_lock = "//private/tests/simple:requirements.txt",
73+
)
74+
use_repo(dev_requirements, "req_compile_test_simple")
75+
76+
dev_requirements.parse(
77+
name = "req_compile_test_platlib",
78+
requirements_locks = {
79+
"//private/tests/platlib:requirements.linux.txt": "@platforms//os:linux",
80+
"//private/tests/platlib:requirements.macos.txt": "@platforms//os:macos",
81+
"//private/tests/platlib:requirements.windows.txt": "@platforms//os:windows",
82+
},
83+
)
84+
use_repo(dev_requirements, "req_compile_test_platlib")
85+
86+
dev_requirements.parse(
87+
name = "req_compile_test_transitive_ins",
88+
requirements_lock = "//private/tests/transitive_ins:requirements.txt",
89+
)
90+
use_repo(dev_requirements, "req_compile_test_transitive_ins")
91+
92+
dev_requirements.parse(
93+
name = "req_compile_test_pip_parse_compat_single_plat",
94+
requirements_lock = "//private/tests/pip_parse_compat:requirements.txt",
95+
)
96+
use_repo(dev_requirements, "req_compile_test_pip_parse_compat_single_plat")
97+
98+
dev_requirements.parse(
99+
name = "req_compile_test_pip_parse_compat_multi_plat",
100+
requirements_locks = {
101+
"//private/tests/pip_parse_compat:requirements.linux.txt": "@platforms//os:linux",
102+
"//private/tests/pip_parse_compat:requirements.macos.txt": "@platforms//os:macos",
103+
"//private/tests/pip_parse_compat:requirements.windows.txt": "@platforms//os:windows",
104+
},
105+
)
106+
use_repo(dev_requirements, "req_compile_test_pip_parse_compat_multi_plat")
107+
108+
dev_requirements.parse(
109+
name = "req_compile_test_annotations",
110+
requirements_locks = {
111+
"//private/tests/annotations:requirements.linux.txt": "@platforms//os:linux",
112+
"//private/tests/annotations:requirements.macos.txt": "@platforms//os:macos",
113+
"//private/tests/annotations:requirements.windows.txt": "@platforms//os:windows",
114+
},
115+
)
116+
use_repo(
117+
dev_requirements,
118+
"req_compile_test_annotations",
119+
"req_compile_test_annotations_linux__numpy",
120+
"req_compile_test_annotations_macos__numpy",
121+
"req_compile_test_annotations_windows__numpy",
122+
)
123+
124+
dev_requirements.package_annotation(
125+
additive_build_file_content = """\
126+
load("@rules_cc//cc:defs.bzl", "cc_library")
127+
load("@rules_req_compile//:defs.bzl", "py_package_annotation_target")
128+
129+
_INCLUDE_DIR = "site-packages/numpy/core/include"
130+
131+
cc_library(
132+
name = "headers",
133+
hdrs = glob(["{}/**/*.h".format(_INCLUDE_DIR)]),
134+
includes = [_INCLUDE_DIR],
135+
)
136+
137+
py_package_annotation_target(
138+
name = "pkg.headers",
139+
target = ":headers",
140+
)
141+
""",
142+
copy_executables = {
143+
"site-packages/numpy/testing/setup.py": "site-packages/numpy/testing/setup.copy.py",
144+
},
145+
copy_files = {
146+
"site-packages/numpy-1.26.4.dist-info/entry_points.txt": "site-packages/numpy-1.26.4.dist-info/entry_points.copy.txt",
147+
},
148+
copy_srcs = {
149+
"site-packages/numpy/conftest.py": "site-packages/numpy/conftest.copy.py",
150+
},
151+
data = [":pkg.headers"],
152+
package = "numpy",
153+
patches = [
154+
"//private/tests/annotations:numpy.patch",
155+
],
156+
deps = [
157+
# Show that label dependencies can be added.
158+
"@rules_python//python/runfiles",
159+
],
160+
)
161+
162+
# Sphinx is known to have a circular dependency. The annotations here solve for that.
163+
dev_requirements.package_annotation(
164+
package = "sphinxcontrib-htmlhelp",
165+
deps = ["-sphinx"],
166+
)
167+
dev_requirements.package_annotation(
168+
package = "sphinxcontrib-applehelp",
169+
deps = ["-sphinx"],
170+
)
171+
dev_requirements.package_annotation(
172+
package = "sphinxcontrib-devhelp",
173+
deps = ["-sphinx"],
174+
)
175+
dev_requirements.package_annotation(
176+
package = "sphinxcontrib-jsmath",
177+
deps = ["-sphinx"],
178+
)
179+
dev_requirements.package_annotation(
180+
package = "sphinxcontrib-qthelp",
181+
deps = ["-sphinx"],
182+
)
183+
dev_requirements.package_annotation(
184+
deps_excludes = ["sphinx"],
185+
package = "sphinxcontrib-serializinghtml",
186+
)
187+
188+
find_links_test_repository = use_repo_rule("//private/tests/find_links:find_links_test_repo.bzl", "find_links_test_repository")
189+
190+
find_links_test_repository(
191+
name = "req_compile_find_links_test",
192+
build_file = "//private/tests/find_links:BUILD.find_links.bazel",
193+
dev_dependency = True,
194+
pyspark_wheel_data = "@req_compile_test_sdist__pyspark//:whl.json",
195+
requirements_in = "//private/tests/find_links:requirements.in",
196+
requirements_txt = "//private/tests/find_links:requirements.txt",
197+
# Needs to match `--find-links` in `//private/tests/find_links:requirements.in`
198+
wheeldir = "wheeldir",
199+
)
200+
201+
# Use a separate extension since the @req_compile_find_links_test is generated by an extension
202+
# that also depend upon //extensions:python.bzl
203+
find_links_requirements = use_extension("//private/tests/find_links:extension.bzl", "requirements", dev_dependency = True)
204+
find_links_requirements.parse(
205+
name = "req_compile_test_find_links",
206+
requirements_lock = "@req_compile_find_links_test//:requirements.txt",
207+
)
208+
use_repo(find_links_requirements, "req_compile_test_find_links")
209+
210+
dev_requirements.parse(
211+
name = "req_compile_test_cross_platform",
212+
requirements_locks = {
213+
"//private/tests/cross_platform:requirements.linux.txt": "@platforms//os:linux",
214+
"//private/tests/cross_platform:requirements.macos.txt": "@platforms//os:macos",
215+
"//private/tests/cross_platform:requirements.windows.txt": "@platforms//os:windows",
216+
},
217+
)
218+
use_repo(dev_requirements, "req_compile_test_cross_platform")
219+
220+
bazel_dep(name = "rules_go", version = "0.59.0", dev_dependency = True)
221+
222+
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk", dev_dependency = True)
223+
go_sdk.download(version = "1.23.1")
224+
225+
bazel_dep(name = "gazelle", version = "0.47.0", dev_dependency = True)
226+
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
227+
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.8.1", dev_dependency = True)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bcr_test_module:
2+
module_path: "private/examples/multiplatform_py_test"
3+
matrix:
4+
platform: ["macos_arm64", "ubuntu2004", "windows"]
5+
bazel: [7.x, 8.x]
6+
tasks:
7+
run_tests:
8+
name: "Run test module"
9+
platform: ${{ platform }}
10+
bazel: ${{ bazel }}
11+
test_targets:
12+
- "//..."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"strip_prefix": "",
3+
"url": "https://github.com/periareon/req-compile/releases/download/1.0.0rc40/rules_req_compile-1.0.0rc40.tar.gz",
4+
"integrity": "sha256-ke/V6hcxxXOsaB/Lr7d+rv4omqB2UH+1r3YzJ1Czs0c="
5+
}

modules/rules_req_compile/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"1.0.0rc34",
2323
"1.0.0rc35",
2424
"1.0.0rc37",
25-
"1.0.0rc38"
25+
"1.0.0rc38",
26+
"1.0.0rc40"
2627
],
2728
"yanked_versions": {}
2829
}

0 commit comments

Comments
 (0)