If you’re interested in Rust and Python like I am, then you may reach a point where the two combine. In this instance I wanted to see if anyone was attempting to implement the Python language interpreter in Rust, and after a quick search, I found the project RustPython on Github ( https://github.com/RustPython/RustPython ).
I cloned a local copy of the source to my Windows 10 Pro itty bitty computer (a Minis Forum UM250 with an AMD Ryzen 5 quad-core CPU, 16GiB, 512GiB SSD). I also have Rust 1.55.0, the current latest release, installed. I followed the directions on the README and it compiled without errors. Unfortunately when it tried to execute it crashed out complaining it couldn’t find ‘encodings,’ and did I have RUSTPYTHONPATH defined. The RUSTPYTHONPATH message stopped me for a moment, as there was nothing in the readme about it. A quick search on Google found the solution.
So, here’s what I’ve discovered so far on Windows 10:
- You need to set $RUSTPYTHONPATH to the full path to the project’s Lib directory. On my machine I do all my work in C:\Develop, and I have cloned Rust Python into C:\Develop\Rust\RustPython. The Lib folder is thus C:\Develop\Rust\RustPython\Lib, and I execute
$env:RUSTPYTHONPATH=C:\Develop\Rust\RustPython\Lib
. A quick alternative is to cd into the Lib folder and execute$env:RUSTPYTHONPATH=$PWD
from the command line if all you want to do is test within that window. - The README says to execute cargo with the release flag to avoid crashing out due to stack overflow. You don’t need to do that anymore. I accidentally forgot to include the release flag in one run, and Rust dutifully built the debug version and ran it without incident.
I’m very impressed with this Rust implementation of Python. I’m no Python expert, but it has so far run a number of my scripts correctly. I am trying to determine how I might meaningfully contribute to the project. I doubt I could write decent Rust source for them, so I may just be on the sidelines watching. I just hope that this project continues on and doesn’t die a slow death like many other past open source projects that showed promise.
You must be logged in to post a comment.