- GraalVM for JDK 23 (Latest)
- GraalVM for JDK 24 (Early Access)
- GraalVM for JDK 21
- GraalVM for JDK 17
- Archives
- Dev Build
Python Standalone Applications
GraalPy enables you to create a Python application or library as a native application or JAR file with no external dependencies. The Truffle framework on which GraalPy is built virtualizes all filesystem accesses, including those to the standard library and installed pure Python packages. Packages that include native code can still circumvent this, however!
GraalPy includes a module named standalone
to create a Python binary for Linux, macOS, and Windows.
The modules bundles all your application’s resources into a single file.
Prerequisite: GraalPy distribution beginning with version 23.1.0. See GraalPy releases.
For example, if you want to produce a native executable from a Python file named my_script.py along with packages you have installed in a virtual environment named my_venv, run the following command:
graalpy -m standalone native \
--module my_script.py \
--output my_binary \
--venv my_env
It produces a native my_binary file which includes your Python code, the GraalPy runtime, and the Python standard library in a single, self-contained executable.
Use graalpy -m standalone native --help
for further options.
Security Considerations #
Creating a native executable or a JAR file that includes Python code could be seen as a mild form of obfuscation, but it does not protect your source code. Python source code is not stored verbatim into the executable (only the GraalPy bytecode is stored), but bytecode is easy to convert back into Python source code.