用户可用来运行 Python 脚本及管理 Python 包,无需系统 Python 环境。该项目集成 RustPython 运行时,支持模块导入和自动镜像检测的 Pip 包管理,零外部依赖。【此简介由AI生成】
| Files | Last commit | Last update |
|---|---|---|
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago |
RUX
A cross-platform runtime for JavaScript, TypeScript, and Python scripts with zero external dependencies.
跨平台脚本运行时,支持 JavaScript、TypeScript 和 Python,无需外部依赖。
Features / 特性
- ✅ Python Runtime: Based on RustPython, fully embedded, no system Python required
- 基于 RustPython 的 Python 运行时,完全嵌入,无需系统 Python
- ✅ Pip Package Manager: Install Python packages with auto mirror detection
- Pip 包管理器,支持自动镜像检测
- ✅ Module Import: Support user modules and standard library
- 模块导入支持,包括用户模块和标准库
- 🚧 JavaScript/TypeScript Runtime: Planned
- JavaScript/TypeScript 运行时(计划中)
- 🚧 npx/uvx Package Runners: Planned
- npx/uvx 包运行器(计划中)
- 🔒 Zero External Dependencies: Except npm/pip packages
- 零外部依赖(除 npm/pip 包外)
Quick Start / 快速开始
Build / 构建
git clone --recursive https://gitcode.com/socialman/rux.git
cd rux
cargo build --release
The executable will be at target/release/rux.exe (Windows) or target/release/rux (Linux/macOS).
Run Python Scripts / 运行 Python 脚本
# Run a Python script
rux python script.py
# Auto-detect by file extension
rux run script.py
# Pass arguments
rux python script.py arg1 arg2
Package Management / 包管理
# Install a package (auto-detect best mirror)
rux pip install requests
# Install with upgrade
rux pip install numpy -U
# Specify mirror
rux pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
# List installed packages
rux pip list
# Show package info
rux pip show requests
# Uninstall a package
rux pip uninstall requests
Examples / 示例
# Hello World
rux python examples/python/hello.py
# Fibonacci sequence
rux python examples/python/fibonacci.py 15
# Comprehensive feature test
rux python examples/python/test_all.py
# Multi-file import test
rux python examples/python/test_import.py
Supported Python Modules / 支持的 Python 模块
Fully Supported / 完全支持 (25+ native modules)
- Math: math, cmath, _statistics
- Crypto: _hashlib, _sha1, _sha3, _sha256, _sha512, _md5, _blake2
- Data: array, _bisect, collections, itertools
- Serialization: _json, _struct, pickle (partial)
- Compression: zlib
- Network: _socket, _multiprocessing
- Others: sys, time, binascii, _csv, faulthandler, gc, pyexpat, _random, unicodedata, functools, operator, datetime, base64
Partially Supported / 部分支持
- os, io, pathlib, json, re (limited by SRE regex engine)
User Modules / 用户模块
- ✓ Import .py files from filesystem
- ✓ Multi-file projects
- ✓ Relative and absolute imports
Pip Mirror Support / Pip 镜像支持
RUX automatically detects and uses the fastest PyPI mirror:
- Official PyPI (https://pypi.org/simple/)
- Tsinghua University / 清华大学 (https://pypi.tuna.tsinghua.edu.cn/simple)
- Aliyun / 阿里云 (https://mirrors.aliyun.com/pypi/simple/)
- Tencent Cloud / 腾讯云 (https://mirrors.cloud.tencent.com/pypi/simple)
- Huawei Cloud / 华为云 (https://repo.huaweicloud.com/repository/pypi/simple)
- Douban / 豆瓣 (https://pypi.douban.com/simple/)
Project Structure / 项目结构
rux/
├── src/
│ ├── main.rs # CLI entry point
│ └── runtime/
│ ├── mod.rs # Runtime module
│ ├── python.rs # Python runtime
│ └── pip.rs # Pip package manager
├── examples/
│ └── python/ # Python examples
│ ├── hello.py # Hello World
│ ├── fibonacci.py # Fibonacci sequence
│ ├── test_all.py # Comprehensive test
│ ├── test_import.py # Multi-file import test
│ └── utils.py # Utility module
├── vendor/
│ └── RustPython/ # RustPython submodule
└── Cargo.toml
Technical Stack / 技术栈
- RustPython 0.4: Pure Rust Python interpreter with importlib support
- Clap 4.5: Command-line argument parsing
- Anyhow 1.0: Error handling
- ureq 2.10: HTTP client for mirror detection
Known Limitations / 已知限制
RustPython has the following limitations:
- Not all Python standard library modules are supported
- No C extension modules (numpy, pandas, etc.)
- Slower performance than CPython
- Some advanced features may not be fully compatible
- SRE regex engine not fully compatible
Best for:
- Simple script automation
- Configuration file processing
- Data transformation
- Pure Python code without C extensions
Roadmap / 开发路线图
License / 许可证
MIT
Introduction
用户可用来运行 Python 脚本及管理 Python 包,无需系统 Python 环境。该项目集成 RustPython 运行时,支持模块导入和自动镜像检测的 Pip 包管理,零外部依赖。【此简介由AI生成】
Customize your domain