-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Patch MODULE.bazel in nanobind example
Done via a small Python script for portability. This ensures that we test the nanobind example build against the latest version in CI.
- Loading branch information
1 parent
757096c
commit 2611dba
Showing
3 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/keith/pre-commit-buildifier | ||
rev: 7.3.1 | ||
rev: 7.3.1.1 | ||
hooks: | ||
- id: buildifier | ||
- id: buildifier-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Redeclare a dependency on nanobind_bazel by overwriting the content of MODULE.bazel. | ||
Used in nanobind-bazel CI to test against development versions in pull requests. | ||
""" | ||
|
||
import re | ||
import sys | ||
from pathlib import Path | ||
|
||
# TODO: Support arbitrary paths in the template below | ||
_LOCAL_NANOBIND_BAZEL = """ | ||
bazel_dep(name = "nanobind_bazel", version = "") | ||
local_path_override( | ||
module_name = "nanobind_bazel", | ||
path = "../", | ||
) | ||
""" | ||
|
||
|
||
def main(): | ||
bazel_project = Path(sys.argv[1]) | ||
module_bazel = bazel_project / "MODULE.bazel" | ||
if not module_bazel.exists(): | ||
raise FileNotFoundError(module_bazel) | ||
|
||
content = module_bazel.read_text() | ||
module_bazel.write_text( | ||
re.sub( | ||
r"bazel_dep\(name = \"nanobind_bazel\", version = [\w\".]*\)", | ||
_LOCAL_NANOBIND_BAZEL, | ||
content, | ||
) | ||
) | ||
|
||
if __name__ == "__main__": | ||
main() |