Skip to content
Open
Show file tree
Hide file tree
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
32 changes: 16 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ concurrency:
cancel-in-progress: true

env:
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc,ucd_3_2_0
CARGO_ARGS_NO_SSL: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,host_env,doc,ucd_3_2_0
CARGO_ARGS: --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc,ucd_3_2_0
CARGO_ARGS_NO_SSL: --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,sqlite,host_env,doc,ucd_3_2_0
CARGO_ARGS_MOST_FEATS: --features capi,encodings,jit,sqlite,threading
# Crates excluded from workspace builds:
# - rustpython_wasm: requires wasm target
Expand Down Expand Up @@ -300,17 +300,17 @@ jobs:
- name: Build c-api tests
if: env.RUN_RUST_TESTS == 'true' && runner.os != 'Windows' # Requires pyo3 0.29+ on Windows
working-directory: crates/capi
run: cargo test --no-run --locked
run: cargo test --no-run --locked --features malachite-bigint

- name: run c-api tests
if: env.RUN_RUST_TESTS == 'true' && runner.os != 'Windows' # Requires pyo3 0.29+ on Windows
working-directory: crates/capi
run: cargo test --locked --lib --bins --tests
run: cargo test --locked --features malachite-bigint --lib --bins --tests

- name: Run c-api doctests
if: env.RUN_RUST_TESTS == 'true' && runner.os != 'Windows' # Requires pyo3 0.29+ on Windows
working-directory: crates/capi
run: cargo test --doc --locked
run: cargo test --doc --locked --features malachite-bigint

- name: Check host_env without ctypes
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Windows'
Expand All @@ -319,13 +319,13 @@ jobs:
- name: check compilation without host_env (sandbox mode)
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Linux'
run: |
cargo check --locked -p rustpython-vm --no-default-features --features compiler
cargo check --locked -p rustpython-stdlib --no-default-features --features compiler
cargo build --locked --no-default-features --features stdlib,importlib,stdio,encodings,freeze-stdlib
cargo check --locked -p rustpython-vm --no-default-features --features malachite-bigint,compiler
cargo check --locked -p rustpython-stdlib --no-default-features --features malachite-bigint,compiler
cargo build --locked --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,freeze-stdlib

- name: Test FileIO without other host modules
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Linux'
run: cargo test --locked -p rustpython-vm --no-default-features --features compiler,host_io --test host_io
run: cargo test --locked -p rustpython-vm --no-default-features --features malachite-bigint,compiler,host_io --test host_io

- name: sandbox smoke test
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Linux'
Expand All @@ -336,15 +336,15 @@ jobs:
- name: Test openssl build
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Linux'
run: |
cargo build --locked --no-default-features --features ssl-openssl
cargo build --locked --no-default-features --features malachite-bigint,ssl-openssl
cargo build --locked --release --features threading,jit,ssl-openssl ${{ env.CARGO_ARGS_NO_SSL }}
target/release/rustpython -B extra_tests/snippets/stdlib_ssl.py
target/release/rustpython -B -m test -v --single-process --timeout=300 test_ssl
timeout-minutes: 30

- name: Test vendored OpenSSL build
if: env.RUN_RUST_TESTS == 'true' && runner.os == 'Linux'
run: cargo build --locked --no-default-features --features ssl-openssl-vendor
run: cargo build --locked --no-default-features --features malachite-bigint,ssl-openssl-vendor

# - name: Install tk-dev for tkinter build
# run: sudo apt-get update && sudo apt-get install -y tk-dev
Expand Down Expand Up @@ -507,7 +507,7 @@ jobs:
# `cargo check` does not link, so it cannot catch an undefined symbol.
- name: Link the wasm32-wasip2 build
if: ${{ matrix.target == 'wasm32-wasip2' }}
run: cargo build --locked --target wasm32-wasip2 --no-default-features --features freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0
run: cargo build --locked --target wasm32-wasip2 --no-default-features --features malachite-bigint,freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0

- name: Check compilation with ssl
if: ${{ !matrix.skip_ssl }}
Expand Down Expand Up @@ -901,12 +901,12 @@ jobs:
${{ runner.os }}-

- name: Build tests under miri
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test --no-run --locked -p rustpython-vm -- miri_test
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test --no-run --locked -p rustpython-vm --features malachite-bigint -- miri_test
env:
MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-permissive-provenance"

- name: Run tests under miri
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test --locked -p rustpython-vm -- miri_test
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test --locked -p rustpython-vm --features malachite-bigint -- miri_test
env:
# miri-ignore-leaks because the type-object circular reference means that there will always be
# a memory leak, at least until we have proper cyclic gc
Expand Down Expand Up @@ -953,7 +953,7 @@ jobs:
${{ runner.os }}-

- name: cargo clippy
run: cargo --locked clippy --keep-going --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings
run: cargo --locked clippy --keep-going --manifest-path=crates/wasm/Cargo.toml --features malachite-bigint -- -Dwarnings

- name: install wasm-pack
run: curl https://wasm-bindgen.github.io/wasm-pack/installer/init.sh -sSf | sh
Expand Down Expand Up @@ -1240,7 +1240,7 @@ jobs:

- name: build rustpython
if: env.RUN_WASM_WASI == 'true'
run: cargo build --locked --profile wasm-release --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0 --verbose
run: cargo build --locked --profile wasm-release --target wasm32-wasip1 --no-default-features --features malachite-bigint,freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0 --verbose
- name: Check WASI FileIO contract
if: env.RUN_WASM_WASI == 'true'
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cron-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- .github/workflows/cron-ci.yaml

env:
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0
CARGO_ARGS: --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0

jobs:
# codecov collects code coverage data from the rust tests, python snippets and python test suite.
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
- run: sudo apt-get update && sudo apt-get -y install lcov

- name: Run cargo-llvm-cov with Rust tests.
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --verbose --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --verbose --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0

- name: Run cargo-llvm-cov with Python snippets.
run: python scripts/cargo-llvm-cov.py
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
libtool: true

- name: Build RustPython
run: cargo build --release --target=${{ matrix.target }} --verbose --no-default-features --features stdlib,stdio,importlib,encodings,sqlite,host_env,ssl-rustls-aws-lc,threading,jit,doc
run: cargo build --release --target=${{ matrix.target }} --verbose --no-default-features --features malachite-bigint,stdlib,stdio,importlib,encodings,sqlite,host_env,ssl-rustls-aws-lc,threading,jit,doc

- name: Rename Binary
run: cp target/${{ matrix.target }}/release/rustpython target/rustpython-release-${{ runner.os }}-${{ matrix.target }}
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
targets: wasm32-wasip1

- name: Build RustPython
run: cargo build --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib,doc --release
run: cargo build --target wasm32-wasip1 --no-default-features --features malachite-bigint,freeze-stdlib,stdlib,doc --release

- name: Rename Binary
run: cp target/wasm32-wasip1/release/rustpython.wasm target/rustpython-release-wasm32-wasip1.wasm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_RELEASE_DEBUG: 0
# Keep feature list in sync with CI's release build in .github/workflows/ci.yaml.
CARGO_ARGS: --workspace --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,threading,jit,doc --exclude rustpython_wasm --exclude rustpython-venvlauncher
CARGO_ARGS: --workspace --no-default-features --features malachite-bigint,stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,threading,jit,doc --exclude rustpython_wasm --exclude rustpython-venvlauncher

jobs:
build-caches:
Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Before completing a task, run the checks that match the change:
cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi

# C-API tests, from their directory so their separate Cargo config applies
(cd crates/capi && cargo test)
(cd crates/capi && cargo test --features malachite-bigint)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the public C-API test instructions

This fixes the agent instructions, but the public contributor workflow at CONTRIBUTING.md:95-100 still tells users to run bare cargo test from crates/capi. Because that package has no default backend and its RustPython dependencies now disable defaults, following the documented command reaches the new no-backend compile_error! before any tests run; update the contributor command to pass --features malachite-bigint too.

AGENTS.md reference: AGENTS.md:L42-L43

Useful? React with 👍 / 👎.


# Clippy, with the same C-API separation
cargo clippy --workspace --all-targets --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi
(cd crates/capi && cargo clippy --all-targets)
(cd crates/capi && cargo clippy --features malachite-bigint --all-targets)

# A Python test module, or one test in it (release mode: faster to run)
cargo run --release -- -m test test_unicode
Expand Down Expand Up @@ -102,7 +102,7 @@ Markers take one of these forms:

## Other Notes

- **WebAssembly**: `cargo build --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib --release`
- **WebAssembly**: `cargo build --target wasm32-wasip1 --no-default-features --features malachite-bigint,freeze-stdlib,stdlib --release`
- **Linux build and debug on macOS**: see [CONTRIBUTING.md](CONTRIBUTING.md#testing-on-linux-from-macos).
- **venvlauncher (Windows)**: all 4 venvlauncher binaries use the same source code. Do NOT add multiple `[[bin]]` entries to Cargo.toml. Build once and copy with different names.
- **CI workflows**: a change to any file under `.github/workflows/` must pass a [zizmor](https://docs.zizmor.sh/) scan in CI.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ separate `cargo` config that only applies there:

```shell
$ cd crates/capi
$ cargo test
$ cargo test --features malachite-bigint
```

Python unit tests can be run by compiling RustPython and running the test module:
Expand Down
31 changes: 20 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ license.workspace = true

[features]
capi = ["dep:rustpython-capi", "threading"]
default = ["threading", "stdlib", "stdio", "importlib", "ssl-rustls-aws-lc", "host_env", "mimalloc", "doc", "ucd_3_2_0"]
default = ["malachite-bigint", "threading", "stdlib", "stdio", "importlib", "ssl-rustls-aws-lc", "host_env", "mimalloc", "doc", "ucd_3_2_0"]
malachite-bigint = ["rustpython-capi?/malachite-bigint", "rustpython-pylib?/malachite-bigint", "rustpython-stdlib?/malachite-bigint", "rustpython-vm/malachite-bigint", "rustpython-compiler/malachite-bigint"]
num-bigint = ["rustpython-capi?/num-bigint", "rustpython-pylib?/num-bigint", "rustpython-stdlib?/num-bigint", "rustpython-vm/num-bigint", "rustpython-compiler/num-bigint"]
doc = ["rustpython-vm/doc", "rustpython-stdlib?/doc"]
mimalloc = ["dep:mimalloc"]
host_env = ["rustpython-vm/host_env", "rustpython-stdlib?/host_env"]
Expand Down Expand Up @@ -183,18 +185,19 @@ repository = "https://github.com/RustPython/RustPython"
license = "MIT"

[workspace.dependencies]
rustpython-capi = { path = "crates/capi", version = "0.6.1" }
rustpython-compiler-core = { path = "crates/compiler-core", version = "0.6.1" }
rustpython-compiler = { path = "crates/compiler", version = "0.6.1" }
rustpython-codegen = { path = "crates/codegen", version = "0.6.1" }
rustpython-common = { path = "crates/common", version = "0.6.1" }
rustpython-bigint = { path = "crates/bigint", version = "0.6.1", default-features = false }
rustpython-capi = { path = "crates/capi", version = "0.6.1", default-features = false }
rustpython-compiler-core = { path = "crates/compiler-core", version = "0.6.1", default-features = false }
rustpython-compiler = { path = "crates/compiler", version = "0.6.1", default-features = false }
rustpython-codegen = { path = "crates/codegen", version = "0.6.1", default-features = false }
rustpython-common = { path = "crates/common", version = "0.6.1", default-features = false }
rustpython-host_env = { path = "crates/host_env", version = "0.6.1" }
rustpython-derive = { path = "crates/derive", version = "0.6.1" }
rustpython-derive-impl = { path = "crates/derive-impl", version = "0.6.1" }
rustpython-jit = { path = "crates/jit", version = "0.6.1" }
rustpython-literal = { path = "crates/literal", version = "0.6.1" }
rustpython-derive = { path = "crates/derive", version = "0.6.1", default-features = false }
rustpython-derive-impl = { path = "crates/derive-impl", version = "0.6.1", default-features = false }
rustpython-jit = { path = "crates/jit", version = "0.6.1", default-features = false }
rustpython-literal = { path = "crates/literal", version = "0.6.1", default-features = false }
rustpython-vm = { path = "crates/vm", default-features = false, version = "0.6.1" }
rustpython-pylib = { path = "crates/pylib", version = "0.6.1" }
rustpython-pylib = { path = "crates/pylib", version = "0.6.1", default-features = false }
rustpython-stdlib = { path = "crates/stdlib", default-features = false, version = "0.6.1" }
rustpython-sre_engine = { path = "crates/sre_engine", version = "0.6.1" }
rustpython-unicode = { path = "crates/unicode", default-features = false, version = "0.6.1" }
Expand Down Expand Up @@ -261,6 +264,7 @@ lz4_flex = "0.14"
nix = { version = "0.32", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }
mac_address = "1.2.1"
mach2 = "0.7.0"
num-bigint = "0.4"
malachite-bigint = "0.15.0"
malachite-q = "0.15.0"
malachite-base = "0.15.0"
Expand All @@ -284,7 +288,7 @@ pem-rfc7468 = "1.0"
pkcs8 = "0.11"
proc-macro2 = "1.0.105"
psm = "0.1"
pymath = { git = "https://github.com/RustPython/pymath.git", rev = "6992bbfc853707545d0fb4b91931a2f36df89abe", features = ["mul_add", "malachite-bigint", "complex"] }
pymath = { git = "https://github.com/RustPython/pymath.git", rev = "6992bbfc853707545d0fb4b91931a2f36df89abe", features = ["mul_add", "complex"] }
pyo3 = "0.30"
quote = "1.0.45"
radium = "1.1.1"
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,29 @@ Note that to use OpenSSL on Windows, you may need to install OpenSSL, or you can
which compiles OpenSSL for you but requires a C compiler, perl, and `make`.
OpenSSL version 3 is expected and tested in CI. Older versions may not work.

### Big integer backends

Only the `rustpython` executable package enables Malachite by default.
Library consumers and executable builds using `--no-default-features` must
select `malachite-bigint` or `num-bigint` explicitly. For example:

```sh
cargo build --no-default-features --features num-bigint,stdlib,stdio,host_env,threading
```

Cargo features are additive, so don't combine both backends or enable
`num-bigint` on top of the default features. Embedders that directly depend
on more than one RustPython crate should select the same backend throughout.
RustPython library defaults do not select a backend.

### WASI

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

Build

```bash
cargo build --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib --release
cargo build --target wasm32-wasip1 --no-default-features --features malachite-bigint,freeze-stdlib,stdlib --release
```

Run by wasmer
Expand Down
Loading
Loading