We plan to provide a tool for generating Java interfaces for Python packages, providing a more seamless and user-friendly experience for creating Java applications that leverage Python packages.
Goals
The polyglot Value API can be used to interact dynamically with objects and call methods or functions from GraalPy and other Graal Languages. Such a value can also be mapped to a Java type via Value.as(java.lang.Class), which allows Java developers to program against a Java interface to interact with Python objects rather than the dynamic Value API. This, however, requires GraalPy users to provide appropriate Java interfaces for the Python packages they want to use.
The goal of this project is to create a tool that can generate Java interfaces for Python types. This is especially useful to automate the interface creation step, allowing developers to generate and regenerate Java interfaces whenever they change or upgrade the Python packages they would like to embed in Java.
Non-Goals
In the first version, it likely won't be possible to fully automate the generation of Java interfaces. The goal is not to integrate this generator into the Maven and Gradle build cycles just yet but rather to create a standalone tool that can be reused multiple times.
The generator relies on Python type annotations and typeshed files (.pyi) to improve type inference for return values and arguments. However, the goal is not to accurately detect all types, and the generator will often fall back to Value or the Java Object class for ambiguous cases.
TL;DR
We plan to provide a tool for generating Java interfaces for Python packages, providing a more seamless and user-friendly experience for creating Java applications that leverage Python packages.
Goals
The polyglot
Value
API can be used to interact dynamically with objects and call methods or functions from GraalPy and other Graal Languages. Such a value can also be mapped to a Java type viaValue.as(java.lang.Class)
, which allows Java developers to program against a Java interface to interact with Python objects rather than the dynamicValue
API. This, however, requires GraalPy users to provide appropriate Java interfaces for the Python packages they want to use. The goal of this project is to create a tool that can generate Java interfaces for Python types. This is especially useful to automate the interface creation step, allowing developers to generate and regenerate Java interfaces whenever they change or upgrade the Python packages they would like to embed in Java.Non-Goals
In the first version, it likely won't be possible to fully automate the generation of Java interfaces. The goal is not to integrate this generator into the Maven and Gradle build cycles just yet but rather to create a standalone tool that can be reused multiple times. The generator relies on Python type annotations and typeshed files (.pyi) to improve type inference for return values and arguments. However, the goal is not to accurately detect all types, and the generator will often fall back to
Value
or the JavaObject
class for ambiguous cases.