diff --git a/README.md b/README.md index 0f9cdac6b..b164124b9 100644 --- a/README.md +++ b/README.md @@ -18,38 +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 +To build RustPython locally, first, clone the source code: - $ curl https://sh.rustup.rs -sSf | sh -s -- -y - $ cargo run --release demo.py - Hello, RustPython! +```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 @@ -63,13 +74,17 @@ 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 @@ -77,19 +92,19 @@ You can compile RustPython to a standalone WebAssembly WASI module so it can run 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 @@ -100,7 +115,7 @@ $ wapm run rustpython You can build the WebAssembly WASI file with: -``` +```bash cargo build --release --target wasm32-wasi --features="freeze-stdlib" ``` @@ -114,7 +129,9 @@ RustPython has an **very** experimental JIT compiler that compile python functio 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. @@ -180,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 @@ -212,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].