Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Bazel recursive stubgen example #54

Open
wants to merge 2 commits into
base: bazel
Choose a base branch
from

Conversation

cemlyn007
Copy link

I made this branch mainly for another MR I am trying to merge with the help of @nicholasjng. If/when the nanobind-bazel MR can land, would you maintainers want this example merged as well?

It's meant to be a slight modification of the existing example to create an example sub-module and makes a small modification to the setup.py to copy files whilst preserving the module structure.

@cemlyn007 cemlyn007 changed the base branch from master to bazel November 17, 2024 22:04
Copy link
Collaborator

@nicholasjng nicholasjng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition! I think this is very valuable to have for nanobind-bazel.

I actually have write access to this repo, since I sometimes need to update the bazel branch when configurations change (or setuptools breaks again). If @wjakob agrees, I can take over all Bazel-related PRs on this repo.

@@ -0,0 +1 @@
from ..nanobind_example_ext.sub_ext import sub
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that all other submodules reference the top-level nanobind extension, right?

So if I do sm.def_submodule("div_ext", "A submodule for dividing integers"); I need to import from ...nanobind_example_ext.sub_ext.div_ext import div in src/nanobind_example/sub_ext/div_ext/__init__.py?

@@ -102,7 +102,10 @@ def bazel_build(self, ext: BazelExtension) -> None:
should_copy = True

if should_copy:
shutil.copyfile(root / fp, libdir / fp)
dstdir = libdir / os.path.relpath(root, srcdir)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think I should just spend some time on a file inclusion function compatible with shutil.copytree(). Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants