Skip to content

Commit a888a9b

Browse files
committed
Added rules_rust_pyo3
1 parent 8798aca commit a888a9b

File tree

91 files changed

+7325
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+7325
-0
lines changed

.bazelci/presubmit.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,49 @@ tasks:
11011101
- "//..."
11021102
test_targets:
11031103
- "//..."
1104+
extensions_pyo3_linux:
1105+
platform: ubuntu2204
1106+
name: Extensions PyO3
1107+
working_directory: extensions/pyo3
1108+
build_flags: *aspects_flags
1109+
test_flags: *aspects_flags
1110+
build_targets:
1111+
- "//..."
1112+
test_targets:
1113+
- "//..."
1114+
extensions_pyo3_linux_rbe:
1115+
platform: rbe_ubuntu2204
1116+
name: Extensions PyO3
1117+
working_directory: extensions/pyo3
1118+
shell_commands:
1119+
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
1120+
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
1121+
build_flags: *aspects_flags
1122+
test_flags: *aspects_flags
1123+
build_targets:
1124+
- "//..."
1125+
test_targets:
1126+
- "//..."
1127+
extensions_pyo3_macos:
1128+
platform: macos_arm64
1129+
name: Extensions PyO3
1130+
working_directory: extensions/pyo3
1131+
build_flags: *aspects_flags
1132+
test_flags: *aspects_flags
1133+
build_targets:
1134+
- "//..."
1135+
test_targets:
1136+
- "//..."
1137+
extensions_pyo3_windows:
1138+
platform: windows
1139+
name: Extensions PyO3
1140+
working_directory: extensions/pyo3
1141+
build_flags: *aspects_flags
1142+
test_flags: *aspects_flags
1143+
build_targets:
1144+
- "//..."
1145+
test_targets:
1146+
- "//..."
11041147
extensions_wasm_bindgen_linux:
11051148
platform: ubuntu2204
11061149
name: Extensions wasm-bindgen

.bcr/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ moduleRoots:
77
- "extensions/mdbook"
88
- "extensions/prost"
99
- "extensions/protobuf"
10+
- "extensions/pyo3"
1011
- "extensions/wasm_bindgen"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_rust",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"github": "UebelAndre",
7+
"name": "UebelAndre"
8+
},
9+
{
10+
"email": "[email protected]",
11+
"github": "illicitonion",
12+
"name": "Daniel Wagner-Hall"
13+
},
14+
{
15+
"email": "[email protected]",
16+
"github": "scentini",
17+
"name": "Rosica Dejanovska"
18+
}
19+
],
20+
"repository": ["github:bazelbuild/rules_rust"],
21+
"versions": [],
22+
"yanked_versions": {}
23+
}

.bcr/extensions/pyo3/presubmit.yml

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: ""
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+
"integrity": "**leave this alone**",
3+
"strip_prefix": "extensions/pyo3",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{VERSION}.tar.gz"
5+
}

docs/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ stardoc(
242242
deps = ["@rules_rust_prost//:bzl_lib"],
243243
)
244244

245+
stardoc(
246+
name = "rust_pyo3",
247+
out = "src/rust_pyo3.md",
248+
input = "@rules_rust_pyo3//:defs.bzl",
249+
deps = ["@rules_rust_pyo3//:bzl_lib"],
250+
)
251+
245252
stardoc(
246253
name = "rust_wasm_bindgen",
247254
out = "src/rust_wasm_bindgen.md",
@@ -283,6 +290,7 @@ mdbook(
283290
":rust_mdbook",
284291
":rust_prost",
285292
":rust_protobuf",
293+
":rust_pyo3",
286294
":rust_repositories",
287295
":rust_settings",
288296
":rust_toolchains",

docs/MODULE.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ local_path_override(
2929
path = "../extensions/prost",
3030
)
3131

32+
bazel_dep(name = "rules_rust_pyo3", version = "0.0.0")
33+
local_path_override(
34+
module_name = "rules_rust_pyo3",
35+
path = "../extensions/pyo3",
36+
)
37+
3238
bazel_dep(name = "rules_rust_protobuf", version = "0.0.0")
3339
local_path_override(
3440
module_name = "rules_rust_protobuf",

docs/src/rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
- [rust_bindgen](rust_bindgen.md): rules for generating C++ bindings.
1717
- [rust_prost](rust_prost.md): rules for generating [protobuf](https://developers.google.com/protocol-buffers) and [gRPC](https://grpc.io) stubs using [prost](https://github.com/tokio-rs/prost).
1818
- [rust_protobuf](rust_protobuf.md): rules for generating [protobuf](https://developers.google.com/protocol-buffers) and [gRPC](https://grpc.io) stubs with [rust-protobuf](https://github.com/stepancheg/rust-protobuf/)
19+
- [rust_pyo3](rust_pyo3.md): Bazel rules for [PyO3](https://pyo3.rs/v0.23.4/).
1920
- [rust_wasm_bindgen](rust_wasm_bindgen.md): rules for generating [WebAssembly](https://www.rust-lang.org/what/wasm) bindings.

extensions/pyo3/.bazelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bazel-out
2+
bazel-testlogs
3+
bazel-pyo3
4+
bazel-bin

extensions/pyo3/.bazelrc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
###############################################################################
2+
## Bazel Configuration Flags
3+
##
4+
## `.bazelrc` is a Bazel configuration file.
5+
## https://bazel.build/docs/best-practices#bazelrc-file
6+
###############################################################################
7+
8+
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
9+
common --enable_platform_specific_config
10+
11+
# Enable the only currently supported report type
12+
# https://bazel.build/reference/command-line-reference#flag--combined_report
13+
coverage --combined_report=lcov
14+
15+
# Avoid fully cached builds reporting no coverage and failing CI
16+
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
17+
coverage --experimental_fetch_all_coverage_outputs
18+
19+
# Disable network access in the sandbox by default.
20+
build --sandbox_default_allow_network=false
21+
22+
# Do not use the host detected python toolchain. Always use one explicitly
23+
# registered in the WORKSPACE.
24+
common --repo_env=BAZEL_DO_NOT_DETECT_PYTHON_TOOLCHAIN=1
25+
26+
# # Enable rustfmt for all targets in the workspace
27+
build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
28+
build:rustfmt --output_groups=+rustfmt_checks
29+
build:no_rustfmt --output_groups=-rustfmt_checks
30+
31+
# Enable clippy for all targets in the workspace
32+
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
33+
build:clippy --output_groups=+clippy_checks
34+
build:no_clippy --output_groups=-clippy_checks
35+
36+
# Enable unpretty for all targets in the workspace
37+
build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect
38+
build:unpretty --output_groups=+rust_unpretty
39+
40+
# `unpretty` requires the nightly toolchain. See tracking issue:
41+
# https://github.com/rust-lang/rust/issues/43364
42+
build:unpretty --config=nightly
43+
44+
# Convenience configs for enabling linting and formatting
45+
build:strict --config=rustfmt
46+
build:strict --config=clippy
47+
build:no_strict --config=no_rustfmt
48+
build:no_strict --config=no_clippy
49+
50+
# When running test enable all linters and formatters
51+
test --config=strict
52+
53+
###############################################################################
54+
## Incompatibility flags
55+
###############################################################################
56+
57+
# https://github.com/bazelbuild/bazel/issues/8195
58+
build --incompatible_disallow_empty_glob=true
59+
60+
# https://github.com/bazelbuild/bazel/issues/12821
61+
build --nolegacy_external_runfiles
62+
63+
# Required for cargo_build_script support before Bazel 7
64+
build --incompatible_merge_fixed_and_default_shell_env
65+
66+
# Disable legacy __init__.py behavior which is known to conflict with
67+
# modern python versions (3.9+)
68+
build --incompatible_default_to_explicit_init_py
69+
70+
###############################################################################
71+
## Bzlmod
72+
###############################################################################
73+
74+
# A configuration for disabling bzlmod.
75+
common:no-bzlmod --noenable_bzlmod --enable_workspace
76+
77+
# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock
78+
common --lockfile_mode=off
79+
80+
# Allow bazel configuration flags to locate the core rules to avoid adding local
81+
# override paths to the `MODULE.bazel` file and breaking downstream consumers.
82+
common --override_module=rules_rust=../../
83+
84+
###############################################################################
85+
## Custom user flags
86+
##
87+
## This should always be the last thing in the `.bazelrc` file to ensure
88+
## consistent behavior when setting flags in that file as `.bazelrc` files are
89+
## evaluated top to bottom.
90+
###############################################################################
91+
92+
try-import %workspace%/user.bazelrc

0 commit comments

Comments
 (0)