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

Expose nanobind's stubgen as a py_binary #35

Merged
merged 6 commits into from
Jul 24, 2024
Merged

Expose nanobind's stubgen as a py_binary #35

merged 6 commits into from
Jul 24, 2024

Conversation

nicholasjng
Copy link
Owner

Adds typing_extensions as a unconditional dependency for the stubgen target.

The plan is to wrap the py_binary into a nanobind stubgen rule that lives in the same file as all other rules.

Closes #14.

@nicholasjng nicholasjng added the enhancement New feature or request label Jul 18, 2024
@nicholasjng nicholasjng self-assigned this Jul 18, 2024
Adds `typing_extensions` as a unconditional dependency
for the stubgen target.

The plan is to wrap the py_binary into a nanobind stubgen
rule that lives in the same file as all other rules.
nicholasjng and others added 3 commits July 18, 2024 21:49
Everything is being forwarded to the py_binary that previously existed in the
top-level BUILD file.

There are still some difficulties locating the module object, since it
exists in multiple places. Maybe it too needs to be sourced from $BINDIR.
Stubgen does not understand file system paths to modules, so we need to
make an indirection and convert paths to nanobind extension targets to
Pythonic module paths via a Python script.
@nicholasjng nicholasjng force-pushed the add-stubgen branch 3 times, most recently from 38f445d to 28df2cc Compare July 22, 2024 15:33
Extracts runfiles dir and bindir from the invoker's script path,
and proceeds to put the generated stub file directly into the $(BINDIR).

What is left outstanding is to support pattern and marker files, but
that has lower prio for now.
@nicholasjng nicholasjng force-pushed the add-stubgen branch 8 times, most recently from a9e24a7 to 6d5c1bf Compare July 24, 2024 13:52
This makes the bindir available from Windows.

Also, harden the stub output path generation on Windows in the case that
the binary location in runfiles is not a symlink.

Also also, add a pattern file to the binary's data deps if provided,
ensuring that the file exists in the repo as an addressable target, and
is visible to the stubgen wrapper in the runfiles dir.
@nicholasjng
Copy link
Owner Author

Finally.

@nicholasjng nicholasjng merged commit dc9d28d into master Jul 24, 2024
16 checks passed
@nicholasjng nicholasjng deleted the add-stubgen branch July 24, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement stubgen as a py_binary
1 participant