Skip to content

Generate a Python module into JAR files#838

Draft
mikehearn wants to merge 3 commits into
micronaut-projects:8.0.xfrom
mikehearn:mh/integrate-pyi-generation
Draft

Generate a Python module into JAR files#838
mikehearn wants to merge 3 commits into
micronaut-projects:8.0.xfrom
mikehearn:mh/integrate-pyi-generation

Conversation

@mikehearn

Copy link
Copy Markdown
Contributor

This PR adds usage of the new j2pyi tool in https://github.com/oracle/graalpy-extensions/tree/main/pyinterfacegen to Micronaut Build such that projects get a Python module containing .pyi stubs for GraalPy included into the JAR.

It's not ready to merge yet because the j2pyi tool needs to be released to Maven Central first, and we may need to do more work on the bindings generation to make them high quality enough.

The idea is that some kind of tool can take the Python module out of the JARs and merge them together into a venv.

Testing

I tested micronaut-sql with this new set of plugins locally and it worked. I haven't tested any other module.

@mikehearn mikehearn marked this pull request as draft January 22, 2026 17:40
@graemerocher graemerocher requested a review from melix January 23, 2026 08:57
@graemerocher

Copy link
Copy Markdown
Contributor

@mikehearn can you show what you did to test Micronaut SQL, I want to test this against some modules. Thanks

@mikehearn mikehearn force-pushed the mh/integrate-pyi-generation branch from c3a247f to 08734f0 Compare February 2, 2026 13:45
@mikehearn

Copy link
Copy Markdown
Contributor Author

I've added a typecheck task. Note that this doesn't work yet because to type check the Python requires resolving the Python/Micronaut dependency graph. However, it is forward progress and lets us rule out syntax errors etc.

To test, use something like this:

cd micronaut-build
./gradlew publishToMavenLocal
cd ../micronaut-sql
cat << 'EOF' | patch -p1
diff --git a/settings.gradle b/settings.gradle
index 39bbb6109..90ef9848d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,9 @@
 pluginManagement {
+    // Include the local micronaut-build so all io.micronaut.build.* plugins resolve from our working copy
+    includeBuild("../micronaut-build")
     repositories {
+        // Prefer local builds if we ever need to publishToMavenLocal as a fallback
+        mavenLocal()
         gradlePluginPortal()
         mavenCentral()
     }
EOF
./gradlew jar
tree jdbc/build/graalpy-module
jar tf jdbc/build/libs/micronaut-jdbc-7.0.0-SNAPSHOT.jar|grep graalpy

@mikehearn mikehearn force-pushed the mh/integrate-pyi-generation branch from 08734f0 to 980a29d Compare March 12, 2026 12:37
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