https://kotlinlang.org logo
Title
m

martmists

05/02/2022, 10:30 PM
As a quick status update from my end, I've been working on a KSP processor and Gradle plugin for KNative interop with the CPython API over here: https://github.com/Martmists-GH/kpy-plugin This is different from the kotlin-python project, which aims to implement a python target similar to Kotlin/JS While it still has some small problems, it seems to mostly be functioning correctly, so if anyone wants to try it out here it is.
🆒 5
p

Piotr Krzemiński

05/06/2022, 5:55 AM
looks interesting! could you provide some minimal "hello world" example?
m

martmists

05/06/2022, 9:32 AM
Assuming you've set up the project as shown in the readme:
package somemodule

@PyExport
fun hello(target: String) {
    println("Hello, $target!")
}
then simply run
pip install .
in the root to install from setup.py, and then
>>> import somemodule
>>> somemodule.hello("world")
Hello, world!
should work. Most of the things you can do are shown in the kpy-sample directory (though not using the gradle plugin as gradle doesn't like having a sibling project as plugin) Some things that I haven't fully worked out yet include registering custom type conversions, for example to only convert from/to numpy arrays. For now, only simple types and user-defined pyexports are able to be converted.
p

Piotr Krzemiński

05/06/2022, 9:38 AM
impressive (didn't try it out yet)! it's funny how the announcement of your project aligns with pausing of Python backend development. Fingers crossed that it will become usable one day 🙂