|
1 | 1 | # GraalVM Implementation of Python |
2 | 2 |
|
3 | | -This is GraalPy, an implementation of the Python language. |
4 | | -A primary goal is to support SciPy and its constituent libraries. |
5 | | -GraalPy can usually execute pure Python code faster than CPython (but not when C extensions are involved). |
6 | | -GraalPy currently aims to be compatible with Python 3.10, but it is some way from there. |
7 | | -While your specific workload may function, any Python program that uses external packages could hit something unsupported. |
| 3 | +GraalPy is an implementation of the Python language on top of GraalVM. |
| 4 | +A primary goal is to support PyTorch, SciPy, and their constituent libraries, as well as to work with other data science and machine learning libraries from the rich Python ecosystem. |
| 5 | +GraalPy can usually execute pure Python code faster than CPython, and nearly match CPython performance when C extensions are involved. |
| 6 | +GraalPy currently aims to be compatible with Python 3.10. |
| 7 | +While many workloads run fine, any Python program that uses external packages could hit something unsupported. |
8 | 8 | At this point, the Python implementation is made available for experimentation and curious end-users. |
| 9 | +We welcome issue reports of all kinds and are working hard to close our compatibility gaps. |
9 | 10 |
|
10 | 11 | ### Trying It |
11 | 12 |
|
12 | | -The easiest option to try GraalPy is [Pyenv](https://github.com/pyenv/pyenv/), the Python version manager. |
| 13 | +The easiest option to try GraalPy is [pyenv](https://github.com/pyenv/pyenv/), the Python version manager. |
13 | 14 | It allows you to easily install different GraalPy releases. |
14 | | -To get version 22.3.0, for example, just run `pyenv install graalpy-22.3.0`. |
15 | | - |
16 | | -To try GraalPy with a full GraalVM, including the support for Java embedding and interop with other languages, you can use the bundled releases from [www.graalvm.org](https://www.graalvm.org/downloads/). |
| 15 | +To install version 22.3.0, for example, just run `pyenv install graalpy-22.3.0`. |
17 | 16 |
|
18 | 17 | Another option is to use [Conda-Forge](https://conda-forge.org/). |
19 | | -To get an environment with the latest GraalPy, use `conda create -c conda-forge -n graalpy graalpy`. |
| 18 | +To get an environment with the latest version of GraalPy, use the following command: |
| 19 | + |
| 20 | +```bash |
| 21 | +conda create -c conda-forge -n graalpy graalpy |
| 22 | +``` |
| 23 | + |
| 24 | +To try GraalPy with a full GraalVM, including the support for Java embedding and interoperability with other languages, you can use the bundled releases from [www.graalvm.org](https://www.graalvm.org/downloads/). |
| 25 | + |
| 26 | +>**Note:** There is currently no installer for Windows. |
20 | 27 |
|
21 | 28 | ### Building from Source |
22 | 29 |
|
23 | 30 | #### Requirements |
24 | 31 |
|
25 | | -* [mx](https://github.com/graalvm/mx) - a separate Python tool co-developed for GraalVM development. This tool must be |
26 | | - downloaded and put onto your PATH: |
27 | | - ``` |
| 32 | +* [mx](https://github.com/graalvm/mx) |
| 33 | + |
| 34 | + There is a separate Python tool for GraalVM development. This tool must be downloaded and added to your PATH: |
| 35 | + |
| 36 | + ```shell |
28 | 37 | git clone https://github.com/graalvm/mx.git |
29 | 38 | export PATH=$PWD/mx:$PATH |
30 | 39 | ``` |
31 | 40 | * LabsJDK |
32 | 41 |
|
33 | | -The following command will download and install JDKs to built GraalVM upon. If successful, it will print the path to set into your JAVA_HOME. |
34 | | -```shell |
35 | | -mx fetch-jdk |
36 | | -``` |
| 42 | + The following command will download and install JDKs upon which to build GraalVM. If successful, it will print the path for the value of your `JAVA_HOME` environment variable. |
| 43 | + ```shell |
| 44 | + mx fetch-jdk |
| 45 | + ``` |
37 | 46 |
|
38 | 47 | #### Building |
39 | 48 |
|
40 | | -Run `mx --dy /compiler python-gvm` in the `graalpython` repository root. If the build is fine, it will print the full |
41 | | -path to the `graalpy` executable as the last line of output. |
42 | | - |
43 | | -For more information and some examples of what you can do with GraalPy, |
44 | | -check out the [reference](https://www.graalvm.org/reference-manual/python/). |
| 49 | +Run `mx --dy /compiler python-gvm` in the root directory of the `graalpython` repository. |
| 50 | +If the build succeeds, it will print the full path to the `graalpy` executable as the last line of output. |
| 51 | +This builds a `bash` launcher that executes GraalPy on the JVM. |
| 52 | +To build a native launcher for lower footprint and better startup, run `mx python-svm` instead. |
45 | 53 |
|
46 | | -### Create a Virtual Environment |
47 | | - |
48 | | -The best way of using the GraalVM implementation of Python is out of a virtual environment. To do so |
49 | | -execute the following command in the project directory: |
50 | | -``` |
51 | | -graalpy -m venv <dir-to-venv> |
52 | | -``` |
53 | | - |
54 | | -To activate the environment in your shell session call: |
55 | | -``` |
56 | | -source <dir-to-venv>/bin/activate |
57 | | -``` |
58 | | - |
59 | | -In the venv, multiple executables are available, like `python`, `python3` and `graalpy`. |
60 | | - |
61 | | -### Installing Packages |
62 | | - |
63 | | -You should be able to use the `pip` command from a GraalPy venv to install packages. |
64 | | -Our `pip` ships some patches for packages that we test internally, these will be applied automatically where necessary. |
65 | | -Support for as many extension modules as possible is a high priority for us. |
66 | | -We are actively building out our support for the Python C API to make extensions such as NumPy, SciPy, Scikit-learn, Pandas, Tensorflow and the like work fully. |
67 | | -This means that some might already work, but we're still actively working on compatibility especially with native extensions. |
| 54 | +For more information and some examples of what you can do with GraalPy, see the [reference documentation](https://www.graalvm.org/reference-manual/python/). |
68 | 55 |
|
69 | 56 | ### Polyglot Usage |
70 | 57 |
|
71 | | -We have a [document](docs/user/Interoperability.md) describing how we implement the |
72 | | -cross-language interop. This will hopefully give you an idea how to use it. |
| 58 | +See the [documentation](docs/user/Interoperability.md) that describes how we implement |
| 59 | +cross-language interoperability. |
| 60 | +This should give you an idea about how to use it. |
73 | 61 |
|
74 | 62 | ### Jython Support |
75 | 63 |
|
76 | 64 | We are working on a mode that is "mostly compatible" with some of Jython's |
77 | 65 | features, minus of course that Jython implements Python 2.7 and we implement |
78 | | -Python 3.10+. We describe the current status of the compatibility mode |
79 | | -[here](docs/user/Jython.md). |
| 66 | +Python 3.10+. |
| 67 | +We describe the current status of the compatibility mode [here](docs/user/Jython.md). |
| 68 | + |
| 69 | +We are working on a mode that is "mostly compatible" with some of Jython's features, considering the fact that Jython implements Python 2.7 and we implement Python 3.10+. |
| 70 | +For more details about compatibility, see [here](docs/user/Jython.md). |
80 | 71 |
|
81 | 72 | ### Contributing |
82 | 73 |
|
|
0 commit comments