Skip to content

Commit f51764f

Browse files
authored
Merge pull request #3806 from ellie-ys/main
Update install rustup
2 parents 8ca35fd + 64f95fe commit f51764f

File tree

1 file changed

+59
-36
lines changed

1 file changed

+59
-36
lines changed

README.md

+59-36
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,49 @@ A Python-3 (CPython >= 3.11.0) Interpreter written in Rust :snake: :scream:
1818

1919
## Usage
2020

21-
#### Check out our [online demo](https://rustpython.github.io/demo/) running on WebAssembly.
21+
**Check out our [online demo](https://rustpython.github.io/demo/) running on WebAssembly.**
2222

23-
RustPython requires Rust latest stable version (e.g 1.65.0 at November 10th 2022).
24-
To check Rust version: `rustc --version` If you wish to update,
25-
`rustup update stable`.
23+
RustPython requires Rust latest stable version (e.g 1.67.1 at February 7th 2023). If you don't
24+
currently have Rust installed on your system you can do so by following the instructions at [rustup.rs](https://rustup.rs/).
2625

27-
To build RustPython locally, do the following:
26+
To check the version of Rust you're currently running, use `rustc --version`. If you wish to update,
27+
`rustup update stable` will update your Rust installation to the most recent stable release.
2828

29-
$ git clone https://github.com/RustPython/RustPython
30-
$ cd RustPython
31-
# --release is needed (at least on windows) to prevent stack overflow
32-
$ cargo run --release demo.py
33-
Hello, RustPython!
29+
To build RustPython locally, first, clone the source code:
30+
31+
```bash
32+
git clone https://github.com/RustPython/RustPython
33+
```
34+
35+
Then you can change into the RustPython directory and run the demo (Note: `--release` is
36+
needed to prevent stack overflow on Windows):
37+
38+
```bash
39+
$ cd RustPython
40+
$ cargo run --release demo_closures.py
41+
Hello, RustPython!
42+
```
3443

3544
Or use the interactive shell:
3645

37-
$ cargo run --release
38-
Welcome to rustpython
39-
>>>>> 2+2
40-
4
41-
46+
```bash
47+
$ cargo run --release
48+
Welcome to rustpython
49+
>>>>> 2+2
50+
4
51+
```
52+
4253
NOTE: For windows users, please set `RUSTPYTHONPATH` environment variable as `Lib` path in project directory.
4354
(e.g. When RustPython directory is `C:\RustPython`, set `RUSTPYTHONPATH` as `C:\RustPython\Lib`)
4455

4556
You can also install and run RustPython with the following:
4657

47-
$ cargo install --git https://github.com/RustPython/RustPython
48-
$ rustpython
49-
Welcome to the magnificent Rust Python interpreter
50-
>>>>>
58+
```bash
59+
$ cargo install --git https://github.com/RustPython/RustPython
60+
$ rustpython
61+
Welcome to the magnificent Rust Python interpreter
62+
>>>>>
63+
```
5164

5265
(The `rustpython-*` crates are currently yanked from crates.io due to being out
5366
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`.
6174
Once you've installed rustpython with SSL support, you can install pip by
6275
running:
6376

64-
$ rustpython --install-pip
77+
```bash
78+
rustpython --install-pip
79+
```
6580

6681
You can also install RustPython through the `conda` package manager, though
6782
this isn't officially supported and may be out of date:
6883

69-
$ conda install rustpython -c conda-forge
70-
$ rustpython
71-
84+
```bash
85+
conda install rustpython -c conda-forge
86+
rustpython
87+
```
7288

7389
### WASI
7490

7591
You can compile RustPython to a standalone WebAssembly WASI module so it can run anywhere.
7692

7793
Build
78-
```shell
79-
$ cargo build --target wasm32-wasi --no-default-features --features freeze-stdlib,stdlib --release
94+
95+
```bash
96+
cargo build --target wasm32-wasi --no-default-features --features freeze-stdlib,stdlib --release
8097
```
8198

8299
Run by wasmer
83-
```shell
84-
$ wasmer run --dir . target/wasm32-wasi/release/rustpython.wasm extra_tests/snippets/stdlib_random.py
100+
101+
```bash
102+
wasmer run --dir . target/wasm32-wasi/release/rustpython.wasm extra_tests/snippets/stdlib_random.py
85103
```
86104

87105
Run by wapm
88-
```shell
106+
107+
```bash
89108
$ wapm install rustpython
90109
$ wapm run rustpython
91110
>>>>> 2+2
@@ -96,25 +115,27 @@ $ wapm run rustpython
96115

97116
You can build the WebAssembly WASI file with:
98117

99-
```
118+
```bash
100119
cargo build --release --target wasm32-wasi --features="freeze-stdlib"
101120
```
102121

103122
> 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`.
104123
105124
### JIT (Just in time) compiler
106125

107-
RustPython has a **very** experimental JIT compiler that compile python functions into native code.
126+
RustPython has a **very** experimental JIT compiler that compile python functions into native code.
108127

109128
#### Building
110129

111130
By default the JIT compiler isn't enabled, it's enabled with the `jit` cargo feature.
112131

113-
$ cargo run --features jit
114-
132+
```bash
133+
cargo run --features jit
134+
```
135+
115136
This requires autoconf, automake, libtool, and clang to be installed.
116137

117-
#### Using
138+
#### Using
118139

119140
To compile a function, call `__jit__()` on it.
120141

@@ -176,11 +197,12 @@ latest release, or the [user guide](https://rustpython.github.io/docs/).
176197
You can also generate documentation locally by running:
177198

178199
```shell
179-
$ cargo doc # Including documentation for all dependencies
180-
$ cargo doc --no-deps --all # Excluding all dependencies
200+
cargo doc # Including documentation for all dependencies
201+
cargo doc --no-deps --all # Excluding all dependencies
181202
```
182203

183-
Documentation HTML files can then be found in the `target/doc` directory.
204+
Documentation HTML files can then be found in the `target/doc` directory or you can append `--open` to the previous commands to
205+
have the documentation open automatically on your default browser.
184206

185207
## Contributing
186208

@@ -208,6 +230,7 @@ method.
208230
[See this doc](wasm/README.md)
209231

210232
## Community
233+
211234
![Discord Banner](https://discordapp.com/api/guilds/1043121930691149845/widget.png?style=banner2)
212235

213236
Chat with us on [Discord][discord].

0 commit comments

Comments
 (0)