You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GraalPy enables you to create a Python application or library as a native application or JAR file with no external dependencies.
4
-
The [Truffle framework](https://github.com/oracle/graal/tree/master/truffle) on which GraalPy is built virtualizes all filesystem accesses, including those to the standard library and installed pure Python packages.
5
-
Packages that include native code can still circumvent this, however!
3
+
GraalPy enables you to package your Python applications or libraries into native executables or JAR files with no external dependencies. This means users can run your application without installing Python or any packages.
6
4
7
-
GraalPy includes a module named `standalone` to create a Python binary for Linux, macOS, and Windows.
8
-
The modules bundles all your application's resources into a single file.
5
+
GraalPy uses the [Truffle framework](https://github.com/oracle/graal/tree/master/truffle) to bundle your Python code, dependencies, and the Python runtime into standalone executables. Truffle's filesystem virtualization allows everything to work from a single file, though packages with native C extensions may have limitations.
9
6
10
-
> Prerequisite: GraalPy distribution beginning with version 23.1.0. See [GraalPy releases](https://github.com/oracle/graalpython/releases).
7
+
GraalPy includes a module named `standalone` to create a Python binary for Linux, macOS, and Windows. The module bundles all your application's resources into a single file.
11
8
12
-
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:
9
+
> **Prerequisite:** GraalPy 23.1.0 or later. [Download here](https://github.com/oracle/graalpython/releases) or verify your version with `graalpy --version`.
10
+
11
+
## Quickstart of Python Standalone Applications
12
+
13
+
To create an native executable from a Python file with its dependencies, use this command:
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.
22
+
Where:
23
+
24
+
*`--module my_script.py` states the main Python file that contains your application's entry point
25
+
*`--output my_binary` states the name for your standalone executable (no file extension needed)
26
+
*`--venv my_env` states the path to virtual environment with installed packages (you can omit this if there are no dependencies)
27
+
28
+
This 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.
22
29
Use `graalpy -m standalone native --help` for further options.
23
30
24
31
### Security Considerations of Python Standalone Applications
25
32
26
-
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.
27
-
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.
33
+
Standalone executables do not protect your source code. Your Python code becomes bytecode, and bytecode can be easily decompiled back to readable Python code.
0 commit comments