mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Compare commits
6 Commits
2025-01-06
...
update_tes
| Author | SHA1 | Date | |
|---|---|---|---|
| 68c0eb6ed1 | |||
| 5c35ef9db0 | |||
| 308b95ec13 | |||
| 5f77ce5b4f | |||
| 4da57d42de | |||
| 2777588bb4 |
23
.github/workflows/ai-review.yml
vendored
Normal file
23
.github/workflows/ai-review.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: PR Review
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: AI Code Review
|
||||
uses: gitea-actions/ai-reviewer@v0.6
|
||||
with:
|
||||
access-token: ${{ secrets.ACCESS_TOKEN }}
|
||||
full-context-model: "gpt-4o"
|
||||
full-context-api-key: ${{ secrets.OPENAI_API_KEY }}
|
||||
single-chunk-model: "claude-3-5-sonnet"
|
||||
single-chunk-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
exclude-files: "*.md,*.yaml"
|
||||
145
.github/workflows/release.yml
vendored
145
.github/workflows/release.yml
vendored
@@ -1,145 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# 9 AM UTC on every Monday
|
||||
- cron: "0 9 * * Mon"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pre-release:
|
||||
type: boolean
|
||||
description: Mark "Pre-Release"
|
||||
required: false
|
||||
default: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
CARGO_ARGS: --no-default-features --features stdlib,zlib,importlib,encodings,sqlite,ssl
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
# - runner: ubuntu-latest
|
||||
# target: i686-unknown-linux-gnu
|
||||
# - runner: ubuntu-latest
|
||||
# target: aarch64-unknown-linux-gnu
|
||||
# - runner: ubuntu-latest
|
||||
# target: armv7-unknown-linux-gnueabi
|
||||
# - runner: ubuntu-latest
|
||||
# target: s390x-unknown-linux-gnu
|
||||
# - runner: ubuntu-latest
|
||||
# target: powerpc64le-unknown-linux-gnu
|
||||
- runner: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
# - runner: macos-latest
|
||||
# target: x86_64-apple-darwin
|
||||
- runner: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
# - runner: windows-latest
|
||||
# target: i686-pc-windows-msvc
|
||||
# - runner: windows-latest
|
||||
# target: aarch64-pc-windows-msvc
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Set up Environment
|
||||
shell: bash
|
||||
run: rustup target add ${{ matrix.platform.target }}
|
||||
- name: Set up Windows Environment
|
||||
shell: bash
|
||||
run: |
|
||||
cargo install --target-dir=target -v cargo-vcpkg
|
||||
cargo vcpkg -v build
|
||||
if: runner.os == 'Windows'
|
||||
- name: Set up MacOS Environment
|
||||
run: brew install autoconf automake libtool
|
||||
if: runner.os == 'macOS'
|
||||
|
||||
- name: Build RustPython
|
||||
run: cargo build --release --target=${{ matrix.platform.target }} --verbose --features=threading ${{ env.CARGO_ARGS }}
|
||||
if: runner.os == 'macOS'
|
||||
- name: Build RustPython
|
||||
run: cargo build --release --target=${{ matrix.platform.target }} --verbose --features=threading ${{ env.CARGO_ARGS }},jit
|
||||
if: runner.os != 'macOS'
|
||||
|
||||
- name: Rename Binary
|
||||
run: cp target/${{ matrix.platform.target }}/release/rustpython target/rustpython-release-${{ runner.os }}-${{ matrix.platform.target }}
|
||||
if: runner.os != 'Windows'
|
||||
- name: Rename Binary
|
||||
run: cp target/${{ matrix.platform.target }}/release/rustpython.exe target/rustpython-release-${{ runner.os }}-${{ matrix.platform.target }}.exe
|
||||
if: runner.os == 'Windows'
|
||||
|
||||
- name: Upload Binary Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rustpython-release-${{ runner.os }}-${{ matrix.platform.target }}
|
||||
path: target/rustpython-release-${{ runner.os }}-${{ matrix.platform.target }}*
|
||||
|
||||
build-wasm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Set up Environment
|
||||
shell: bash
|
||||
run: rustup target add wasm32-wasi
|
||||
|
||||
- name: Build RustPython
|
||||
run: cargo build --target wasm32-wasi --no-default-features --features freeze-stdlib,stdlib --release
|
||||
|
||||
- name: Rename Binary
|
||||
run: cp target/wasm32-wasi/release/rustpython.wasm target/rustpython-release-wasm32-wasi.wasm
|
||||
|
||||
- name: Upload Binary Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rustpython-release-wasm32-wasi
|
||||
path: target/rustpython-release-wasm32-wasi.wasm
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, build-wasm]
|
||||
steps:
|
||||
- name: Download Binary Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: bin
|
||||
pattern: rustpython-release-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: List Binaries
|
||||
run: |
|
||||
ls -lah bin/
|
||||
file bin/*
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ github.ref_name }}
|
||||
run: ${{ github.run_number }}
|
||||
run: |
|
||||
if [[ "${{ github.event.inputs.pre-release }}" == "true" ]]; then
|
||||
RELEASE_TYPE_NAME=Pre-Release
|
||||
PRERELEASE_ARG=--prerelease
|
||||
else
|
||||
RELEASE_TYPE_NAME=Release
|
||||
PRERELEASE_ARG=
|
||||
fi
|
||||
|
||||
today=$(date '+%Y-%m-%d')
|
||||
gh release create "$today-$tag-$run" \
|
||||
--repo="$GITHUB_REPOSITORY" \
|
||||
--title="RustPython $RELEASE_TYPE_NAME $today-$tag #$run" \
|
||||
--target="$tag" \
|
||||
--generate-notes \
|
||||
$PRERELEASE_ARG \
|
||||
bin/rustpython-release-*
|
||||
22
Cargo.lock
generated
22
Cargo.lock
generated
@@ -207,10 +207,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "caseless"
|
||||
version = "0.2.2"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6fd507454086c8edfd769ca6ada439193cdb209c7681712ef6275cccbfe5d8"
|
||||
checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
@@ -1565,13 +1566,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pmutil"
|
||||
version = "0.6.1"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6"
|
||||
checksum = "3894e5d549cccbe44afecf72922f277f603cd4bb0219c8342631ef18fffbe004"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1823,23 +1824,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "result-like"
|
||||
version = "0.5.0"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abf7172fef6a7d056b5c26bf6c826570267562d51697f4982ff3ba4aec68a9df"
|
||||
checksum = "ccc7ce6435c33898517a30e85578cd204cbb696875efb93dec19a2d31294f810"
|
||||
dependencies = [
|
||||
"result-like-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "result-like-derive"
|
||||
version = "0.5.0"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8d6574c02e894d66370cfc681e5d68fedbc9a548fb55b30a96b3f0ae22d0fe5"
|
||||
checksum = "1fabf0a2e54f711c68c50d49f648a1a8a37adcb57353f518ac4df374f0788f42"
|
||||
dependencies = [
|
||||
"pmutil",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 1.0.109",
|
||||
"syn-ext",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -32,23 +32,3 @@ assert_raises(ValueError, lambda: 1 << -1)
|
||||
|
||||
# Right shift raises value error on negative
|
||||
assert_raises(ValueError, lambda: 1 >> -1)
|
||||
|
||||
# Bitwise or, and, xor raises value error on incompatible types
|
||||
assert_raises(TypeError, lambda: "abc" | True)
|
||||
assert_raises(TypeError, lambda: "abc" & True)
|
||||
assert_raises(TypeError, lambda: "abc" ^ True)
|
||||
assert_raises(TypeError, lambda: True | "abc")
|
||||
assert_raises(TypeError, lambda: True & "abc")
|
||||
assert_raises(TypeError, lambda: True ^ "abc")
|
||||
assert_raises(TypeError, lambda: "abc" | 1.5)
|
||||
assert_raises(TypeError, lambda: "abc" & 1.5)
|
||||
assert_raises(TypeError, lambda: "abc" ^ 1.5)
|
||||
assert_raises(TypeError, lambda: 1.5 | "abc")
|
||||
assert_raises(TypeError, lambda: 1.5 & "abc")
|
||||
assert_raises(TypeError, lambda: 1.5 ^ "abc")
|
||||
assert_raises(TypeError, lambda: True | 1.5)
|
||||
assert_raises(TypeError, lambda: True & 1.5)
|
||||
assert_raises(TypeError, lambda: True ^ 1.5)
|
||||
assert_raises(TypeError, lambda: 1.5 | True)
|
||||
assert_raises(TypeError, lambda: 1.5 & True)
|
||||
assert_raises(TypeError, lambda: 1.5 ^ True)
|
||||
|
||||
@@ -502,9 +502,9 @@ with TestWithTempDir() as tmpdir:
|
||||
assert set(collected_files) == set(expected_files)
|
||||
|
||||
# system()
|
||||
if os.name in ('posix', 'nt'):
|
||||
assert os.system('echo test') == 0
|
||||
assert os.system('&') != 0
|
||||
if "win" not in sys.platform:
|
||||
assert os.system('ls') == 0
|
||||
assert os.system('{') != 0
|
||||
|
||||
for arg in [None, 1, 1.0, TabError]:
|
||||
assert_raises(TypeError, os.system, arg)
|
||||
|
||||
@@ -58,7 +58,6 @@ use std::process::ExitCode;
|
||||
pub use interpreter::InterpreterConfig;
|
||||
pub use rustpython_vm as vm;
|
||||
pub use settings::{opts_with_clap, InstallPipMode, RunMode};
|
||||
pub use shell::run_shell;
|
||||
|
||||
/// The main cli of the `rustpython` interpreter. This function will return `std::process::ExitCode`
|
||||
/// based on the return code of the python code ran through the cli.
|
||||
|
||||
@@ -73,12 +73,12 @@ thiserror = { workspace = true }
|
||||
thread_local = { workspace = true }
|
||||
memchr = { workspace = true }
|
||||
|
||||
caseless = "0.2.2"
|
||||
caseless = "0.2.1"
|
||||
flamer = { version = "0.4", optional = true }
|
||||
half = "2"
|
||||
memoffset = "0.9.1"
|
||||
optional = "0.5.0"
|
||||
result-like = "0.5.0"
|
||||
result-like = "0.4.6"
|
||||
timsort = "0.1.2"
|
||||
|
||||
## unicode stuff
|
||||
|
||||
@@ -127,10 +127,8 @@ impl PyBool {
|
||||
let lhs = get_value(&lhs);
|
||||
let rhs = get_value(&rhs);
|
||||
(lhs || rhs).to_pyobject(vm)
|
||||
} else if let Some(lhs) = lhs.payload::<PyInt>() {
|
||||
lhs.or(rhs, vm).to_pyobject(vm)
|
||||
} else {
|
||||
vm.ctx.not_implemented()
|
||||
get_py_int(&lhs).or(rhs, vm).to_pyobject(vm)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +141,8 @@ impl PyBool {
|
||||
let lhs = get_value(&lhs);
|
||||
let rhs = get_value(&rhs);
|
||||
(lhs && rhs).to_pyobject(vm)
|
||||
} else if let Some(lhs) = lhs.payload::<PyInt>() {
|
||||
lhs.and(rhs, vm).to_pyobject(vm)
|
||||
} else {
|
||||
vm.ctx.not_implemented()
|
||||
get_py_int(&lhs).and(rhs, vm).to_pyobject(vm)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,10 +155,8 @@ impl PyBool {
|
||||
let lhs = get_value(&lhs);
|
||||
let rhs = get_value(&rhs);
|
||||
(lhs ^ rhs).to_pyobject(vm)
|
||||
} else if let Some(lhs) = lhs.payload::<PyInt>() {
|
||||
lhs.xor(rhs, vm).to_pyobject(vm)
|
||||
} else {
|
||||
vm.ctx.not_implemented()
|
||||
get_py_int(&lhs).xor(rhs, vm).to_pyobject(vm)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,3 +207,7 @@ pub(crate) fn init(context: &Context) {
|
||||
pub(crate) fn get_value(obj: &PyObject) -> bool {
|
||||
!obj.payload::<PyInt>().unwrap().as_bigint().is_zero()
|
||||
}
|
||||
|
||||
fn get_py_int(obj: &PyObject) -> &PyInt {
|
||||
obj.payload::<PyInt>().unwrap()
|
||||
}
|
||||
|
||||
@@ -142,7 +142,6 @@ pub(super) mod _os {
|
||||
protocol::PyIterReturn,
|
||||
recursion::ReprGuard,
|
||||
types::{IterNext, Iterable, PyStructSequence, Representable, SelfIter},
|
||||
utils::ToCString,
|
||||
vm::VirtualMachine,
|
||||
AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObject,
|
||||
};
|
||||
@@ -1029,14 +1028,6 @@ pub(super) mod _os {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(any(unix, windows))]
|
||||
#[pyfunction]
|
||||
fn system(command: PyStrRef, vm: &VirtualMachine) -> PyResult<i32> {
|
||||
let cstr = command.to_cstring(vm)?;
|
||||
let x = unsafe { libc::system(cstr.as_ptr()) };
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
struct UtimeArgs {
|
||||
path: OsPath,
|
||||
|
||||
@@ -901,6 +901,13 @@ pub mod module {
|
||||
nix::unistd::pipe2(oflags).map_err(|err| err.into_pyexception(vm))
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn system(command: PyStrRef, vm: &VirtualMachine) -> PyResult<i32> {
|
||||
let cstr = command.to_cstring(vm)?;
|
||||
let x = unsafe { libc::system(cstr.as_ptr()) };
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
fn _chmod(
|
||||
path: OsPath,
|
||||
dir_fd: DirFd<0>,
|
||||
|
||||
Reference in New Issue
Block a user