Skip to content

feat: pyo3 support module prefix + naming - #3726

Merged
UebelAndre merged 8 commits into
bazelbuild:mainfrom
andyscott:ags/pyo3-module-path
Jan 22, 2026
Merged

feat: pyo3 support module prefix + naming#3726
UebelAndre merged 8 commits into
bazelbuild:mainfrom
andyscott:ags/pyo3-module-path

Conversation

@andyscott

Copy link
Copy Markdown
Contributor

Adds support for specifying the module name + module prefix for pyo3 extensions.

@andyscott
andyscott force-pushed the ags/pyo3-module-path branch from 7a660ad to 3a98fed Compare November 13, 2025 01:56
@andyscott andyscott changed the title pyo3: support module prefix + naming feat: pyo3 support module prefix + naming Nov 13, 2025
@andyscott
andyscott force-pushed the ags/pyo3-module-path branch from 35bc452 to e19bd9c Compare November 15, 2025 05:43

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Just one question

Comment thread extensions/pyo3/test/module_prefix/BUILD.bazel

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One more question for you guys!

name = "module_prefix",
srcs = ["bar.rs"],
edition = "2021",
imports = ["."],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you explain how this interacts with imports? Is imports = ["."] required? What happens if a subdirectory is added? Does it make the module not imported?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Import values behave just like they do for regular Python library import paths under Bazel.

I reworked the test to use the default import path (the repo root) instead of the package's dir. The python test case is adjusted accordingly so it looks like the rest of the test cases in the pyo3 extension workspace.

@ags-openai ags-openai Dec 10, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens if a subdirectory is added? Does it make the module not imported?

As in something like imports = ["some_dir"]? It'd try to strip this off of the prefix of the module path for python. Since the shared lib is being placed in a directory with a module path prefix turned to dirs it would effectively try to trim the module name prefixes this PR is adding support for.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@UebelAndre gentle ping 🙏

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for the delay! Last thing, can you add an additional variant that uses imports? Similar to:

pyo3_extension(
name = "string_sum_import",
srcs = ["string_sum_import.rs"],
edition = "2021",
imports = ["."],
)
py_test(
name = "string_sum_import_test",
srcs = ["string_sum_import_test.py"],
deps = [":string_sum_import"],
)

@ags-openai

Copy link
Copy Markdown

Yes. But before we embark on another cycle of review: is there any additional feedback I can address this time through?

@UebelAndre

Copy link
Copy Markdown
Collaborator

Thanks!

@ags-openai

Copy link
Copy Markdown

How do we get this merged?

@UebelAndre
UebelAndre enabled auto-merge January 22, 2026 01:38
@UebelAndre

Copy link
Copy Markdown
Collaborator

Hey, I was on break and there was a CI outage. Rebased and added to the queue!

@andyscott

andyscott commented Jan 22, 2026 via email

Copy link
Copy Markdown
Contributor Author

@UebelAndre
UebelAndre added this pull request to the merge queue Jan 22, 2026
Merged via the queue into bazelbuild:main with commit 9415a9a Jan 22, 2026
3 checks passed
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.

3 participants