Skip to content

Update install rustup #3806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 59 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these changes are made after warnigns from markdown lint.


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
Expand All @@ -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
Expand All @@ -96,25 +115,27 @@ $ wapm run rustpython

You can build the WebAssembly WASI file with:

```
```bash
cargo build --release --target wasm32-wasi --features="freeze-stdlib"
```

> Note: we use the `freeze-stdlib` to include the standard library inside the binary. You also have to run once `rustup target add wasm32-wasi`.

### 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.

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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].
Expand Down