A robust tool to transpile Python source code into V(vlang) code.
This guide covers the requirements and installation process for the Python to Vlang Transpiler.
pip install py2v-transpiler
git clone https://github.com/yaskhan/pythontovlang.git
cd pythontovlang
pip install .
pip install -e ".[dev]"
You can compile the transpiler itself into a high-performance C-extension using mypyc. This significantly speeds up the transpilation process for large projects.
gcc or clang).USE_MYPYC environment variable:
USE_MYPYC=1 pip install .
Note: This will compile the core module files but will leave main.py as a standard Python CLI script.
The transpiler has minimal dependencies:
| Package | Version | Purpose |
|---|---|---|
mypy |
Latest | Static type inference |
pytest |
Latest | Testing (dev only) |
After installation, verify the transpiler is working:
# Check if the command is available
py2v --help
# Transpile a simple test
echo 'print("Hello, World!")' > test.py
py2v test.py
cat test.v
To compile the generated V code:
git clone https://github.com/vlang/v.git
cd v
make
# Linux/macOS
export VROOT=/path/to/v
export PATH=$VROOT:$PATH
# Windows (PowerShell)
$env:VROOT = "C:\path\to\v"
$env:PATH = "$env:VROOT;$env:PATH"
py2v script.py
v run script.v
pip install mypy
Ensure you’re using Python 3.10+. Check with:
python --version
The generated V code may require specific V versions. Check the V version compatibility in the project README.