English | 简体中文
A cross-language interaction framework based on Java ASM for static translation and dynamic loading of Python.
-
Use the core module for custom compilation and loading.
If you only want to load compiled bytecode, just import the
dependencies { implementation 'com.github.Chi-Re.Javathon:core:0.1.2' }
libmodule and write your own loader.dependencies { implementation 'com.github.Chi-Re.Javathon:lib:0.1.2' }
-
If you wish to use it in project development, you can use the Gradle plugin for mixed Python and Java development.
plugins { id 'io.github.Chi-Re.javathon' version '0.0.1' }
Specify the source code folder and the compiled output folder.
pythonGen { outputDir = file("build/generated/output") // The specified folder will be automatically implemented sourceDir = file("pySrc") }
Note:
- If you want mixed development, the project must add the
libmodule as a dependency. - The packaging part during build only supports customization, so pay attention when building a
jar.
- If you want mixed development, the project must add the
Building: gradlew core:dist
After the build is complete, the result is located at ~/core/build/libs/Javathon.jar
Run the built Javathon.jar file in the following way.
If you want to build a Python project, run:
java -cp Javathon.jar chire.python.PyCompiler input outputIf you only want to run a Python project, run:
java -cp Javathon.jar chire.python.PyInterpreter input classPathNote:
inputmust be the root directory of the Python project source code.outputwill automatically detect whether it is a file or a folder, but if it is a file, it must end with.jar.classPathis the entry path, in the formatxxx.xxx.xxx. For inner classes, use$to connect (consistent with Java'sClass.forNamesyntax).
Currently not stable enough; the interfaces exposed by the lib module are subject to change.
Note: The above is an AI translation. If there are any mistakes, I apologize. You can provide feedback in the issues. Thank you.