Merge pull request #3806 from ellie-ys/main

Update install rustup
This commit is contained in:
Jim Fasarakis-Hilliard
2023-02-24 16:19:39 +02:00
committed by GitHub

View File

@@ -18,36 +18,49 @@ A Python-3 (CPython >= 3.11.0) Interpreter written in Rust :snake: :scream:
## Usage
#### Check out our [online demo](https://rustpython.github.io/demo/) running on WebAssembly.
**Check out our [online demo](https://rustpython.github.io/demo/) running on WebAssembly.**
RustPython requires Rust latest stable version (e.g 1.65.0 at November 10th 2022).
To check Rust version: `rustc --version` If you wish to update,
`rustup update stable`.
RustPython requires Rust latest stable version (e.g 1.67.1 at February 7th 2023). If you don't
currently have Rust installed on your system you can do so by following the instructions at [rustup.rs](https://rustup.rs/).
To build RustPython locally, do the following:
To check the version of Rust you're currently running, use `rustc --version`. If you wish to update,
`rustup update stable` will update your Rust installation to the most recent stable release.
$ git clone https://github.com/RustPython/RustPython
$ cd RustPython
# --release is needed (at least on windows) to prevent stack overflow
$ cargo run --release demo.py
Hello, RustPython!
To build RustPython locally, first, clone the source code:
```bash
git clone https://github.com/RustPython/RustPython
```
Then you can change into the RustPython directory and run the demo (Note: `--release` is
needed to prevent stack overflow on Windows):
```bash
$ cd RustPython
$ cargo run --release demo_closures.py
Hello, RustPython!
```
Or use the interactive shell:
$ cargo run --release
Welcome to rustpython
>>>>> 2+2
4
```bash
$ cargo run --release
Welcome to rustpython
>>>>> 2+2
4
```
NOTE: For windows users, please set `RUSTPYTHONPATH` environment variable as `Lib` path in project directory.
(e.g. When RustPython directory is `C:\RustPython`, set `RUSTPYTHONPATH` as `C:\RustPython\Lib`)
You can also install and run RustPython with the following:
$ cargo install --git https://github.com/RustPython/RustPython
$ rustpython
Welcome to the magnificent Rust Python interpreter
>>>>>
```bash
$ cargo install --git https://github.com/RustPython/RustPython
$ rustpython
Welcome to the magnificent Rust Python interpreter
>>>>>
```
(The `rustpython-*` crates are currently yanked from crates.io due to being out
of date and not building on newer rust versions; we hope to release a new
@@ -61,31 +74,37 @@ which compiles OpenSSL for you but requires a C compiler, perl, and `make`.
Once you've installed rustpython with SSL support, you can install pip by
running:
$ rustpython --install-pip
```bash
rustpython --install-pip
```
You can also install RustPython through the `conda` package manager, though
this isn't officially supported and may be out of date:
$ conda install rustpython -c conda-forge
$ rustpython
```bash
conda install rustpython -c conda-forge
rustpython
```
### WASI
You can compile RustPython to a standalone WebAssembly WASI module so it can run anywhere.
Build
```shell
$ cargo build --target wasm32-wasi --no-default-features --features freeze-stdlib,stdlib --release
```bash
cargo build --target wasm32-wasi --no-default-features --features freeze-stdlib,stdlib --release
```
Run by wasmer
```shell
$ wasmer run --dir . target/wasm32-wasi/release/rustpython.wasm extra_tests/snippets/stdlib_random.py
```bash
wasmer run --dir . target/wasm32-wasi/release/rustpython.wasm extra_tests/snippets/stdlib_random.py
```
Run by wapm
```shell
```bash
$ wapm install rustpython
$ wapm run rustpython
>>>>> 2+2
@@ -96,7 +115,7 @@ $ wapm run rustpython
You can build the WebAssembly WASI file with:
```
```bash
cargo build --release --target wasm32-wasi --features="freeze-stdlib"
```
@@ -104,17 +123,19 @@ cargo build --release --target wasm32-wasi --features="freeze-stdlib"
### JIT (Just in time) compiler
RustPython has a **very** experimental JIT compiler that compile python functions into native code.
RustPython has a **very** experimental JIT compiler that compile python functions into native code.
#### Building
By default the JIT compiler isn't enabled, it's enabled with the `jit` cargo feature.
$ cargo run --features jit
```bash
cargo run --features jit
```
This requires autoconf, automake, libtool, and clang to be installed.
#### Using
#### Using
To compile a function, call `__jit__()` on it.
@@ -176,11 +197,12 @@ latest release, or the [user guide](https://rustpython.github.io/docs/).
You can also generate documentation locally by running:
```shell
$ cargo doc # Including documentation for all dependencies
$ cargo doc --no-deps --all # Excluding all dependencies
cargo doc # Including documentation for all dependencies
cargo doc --no-deps --all # Excluding all dependencies
```
Documentation HTML files can then be found in the `target/doc` directory.
Documentation HTML files can then be found in the `target/doc` directory or you can append `--open` to the previous commands to
have the documentation open automatically on your default browser.
## Contributing
@@ -208,6 +230,7 @@ method.
[See this doc](wasm/README.md)
## Community
![Discord Banner](https://discordapp.com/api/guilds/1043121930691149845/widget.png?style=banner2)
Chat with us on [Discord][discord].