| Crates.io | py2pyd |
| lib.rs | py2pyd |
| version | 0.1.5 |
| created_at | 2025-06-26 18:12:15.624794+00 |
| updated_at | 2025-12-19 17:36:00.907874+00 |
| description | A Rust-based tool to compile Python modules to pyd files |
| homepage | |
| repository | https://github.com/loonghao/py2pyd |
| max_upload_size | |
| id | 1727629 |
| size | 369,891 |
🚀 A high-performance Rust-based tool to compile Python modules to extension files (.pyd on Windows, .so on Linux/macOS) with zero-dependency executables.
✨ Features Docker-powered CI/CD with 5-10x faster builds and truly portable executables that run anywhere without installation.
Note: This project is under active development. While core functionality is stable, APIs may evolve. We provide zero-dependency executables for maximum portability.
py2pyd is a high-performance, Rust-based command-line tool that compiles Python (.py) files to Python extension modules (.pyd on Windows, .so on Linux/macOS). Built with modern DevOps practices, it features Docker-powered CI/CD for lightning-fast builds and produces zero-dependency executables for maximum portability.
Compile single Python files or entire directories to Python extension modules (.pyd on Windows, .so on Linux/macOS)
Support for multiple Python interpreter discovery methods:
--uv-python 3.10)--python-path)Batch processing with recursive directory support
Optimization level control
Comprehensive logging and error reporting
Download the latest release from the Releases page.
py2pyd-x86_64-pc-windows-gnu.zip - Runs on any Windows systempy2pyd-i686-pc-windows-gnu.zip - Compatible with older systemspy2pyd-x86_64-unknown-linux-musl.tar.gz - Works on any Linux distributionpy2pyd-aarch64-unknown-linux-musl.tar.gz - For ARM64 Linux systemspy2pyd-x86_64-apple-darwin.tar.gzpy2pyd-aarch64-apple-darwin.tar.gz💡 Tip: Windows and Linux musl builds are completely self-contained with zero dependencies. Just download, extract, and run!
git clone https://github.com/loonghao/py2pyd.git
cd py2pyd
cargo build --release
The binary will be available at target/release/py2pyd (or py2pyd.exe on Windows).
This project includes enhanced cross-compilation support based on rust-actions-toolkit best practices:
x86_64-pc-windows-gnu and i686-pc-windows-gnulibmimalloc-sys build errors in cross-compilation environmentsCross.toml with proper environment variablesTo test cross-compilation locally:
# Install cross-compilation tool
cargo install cross
# Test Windows targets
cross build --target x86_64-pc-windows-gnu --release
cross build --target i686-pc-windows-gnu --release
For troubleshooting cross-compilation issues, see the rust-actions-toolkit documentation.
# Basic usage (uses Python from PATH)
py2pyd -i input.py -o output.pyd
# Using uv with specific Python version
py2pyd --uv-python 3.10 -i input.py -o output.pyd
# Using explicit Python interpreter path
py2pyd --python-path C:/Python310/python.exe -i input.py -o output.pyd
# Batch processing
py2pyd --uv-python 3.10 -i src/ -o build/ --recursive
The tool will automatically check for required build tools and provide installation instructions if they are missing.
py2pyd includes comprehensive tests, including integration tests that download and compile real Python packages from PyPI.
# Run unit tests only
cargo test
# Run all tests including integration tests (requires internet and build tools)
cargo test -- --ignored
# Test compiling a simple Python module
cargo test test_compile_simple_python_module -- --ignored
# Test downloading and compiling a real PyPI package
cargo test test_download_six_package -- --ignored
For detailed testing information, see TESTING_GUIDE.md.
This project leverages cutting-edge Docker technology for development and CI/CD:
| Metric | Before | After | Improvement |
|---|---|---|---|
| Cold Start | 3-5 minutes | 30-60 seconds | 5-10x faster |
| Warm Start | 1-2 minutes | 10-20 seconds | 3-6x faster |
| Dependencies | Downloaded each time | Pre-installed | Consistent |
ghcr.io/loonghao/rust-toolkit:base - General CI/CD operationsghcr.io/loonghao/rust-toolkit:cross-compile - Zero-dependency buildsghcr.io/loonghao/rust-toolkit:security-audit - Enhanced security scanningOur release pipeline produces truly portable executables:
This ensures maximum compatibility and ease of distribution.
This project uses Semantic Release with automated CI/CD. Releases are automatically triggered based on Conventional Commits:
| Commit Type | Version Bump | Example |
|---|---|---|
feat: |
Minor (0.1.0 → 0.2.0) | feat: add Python 3.12 support |
fix: |
Patch (0.1.0 → 0.1.1) | fix: resolve memory leak in parser |
feat!: or BREAKING CHANGE: |
Major (0.1.0 → 1.0.0) | feat!: redesign command-line interface |
docs:, chore:, etc. |
Patch (0.1.0 → 0.1.1) | docs: update installation guide |
Simply use conventional commit messages when pushing to main:
# Feature addition (minor version bump)
git commit -m "feat: add support for Python 3.12"
# Bug fix (patch version bump)
git commit -m "fix: handle edge case in file parsing"
# Breaking change (major version bump)
git commit -m "feat!: redesign command-line interface
BREAKING CHANGE: The --input flag is now required"
The CI system will automatically:
Cargo.tomlFor detailed information, see docs/VERSIONING.md.
Contributions are welcome! Please follow these guidelines:
This project uses Conventional Commits. Please format your commit messages as:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary toolsExamples:
feat(parser): add support for async functions
fix(compiler): resolve segmentation fault on Windows
docs(readme): add installation instructions
refactor(core): simplify error handling logic
Please feel free to submit a Pull Request!
This project is licensed under the MIT License - see the LICENSE file for details.