|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Build RustPython on Windows" |
| 4 | +date: 2020-04-03 01:11:01 -0400 |
| 5 | +categories: featured |
| 6 | +--- |
| 7 | + |
| 8 | +Building RustPython on windows is an issue for people new to the project. |
| 9 | +This articles seeks to make it easy for you. |
| 10 | + |
| 11 | +## Let's get to work. |
| 12 | +- First [Download Rust](https://www.google.com "Rust download page") and follow the installation guide. |
| 13 | + |
| 14 | +- Make sure you have a C/C++ compiler installed. I'd advice using Microsoft Visual Studio compilers for the job. [Download Visual Studio](https://visualstudio.microsoft.com/downloads/ "Visual Studio Download Page") and follow the installation guide. A community version is all we need. Be sure to check `Desktop Development with C++`. |
| 15 | + |
| 16 | +- [Download and setup git](https://git-scm.com/download/win "Git download page") if you haven't already. |
| 17 | + |
| 18 | +- Next we need to install openssl since RustPython depends on it. However the build process for openssl is not very straight forward. We employ [Vcpkg](https://github.com/Microsoft/vcpkg) to help us. [Clone Vcpkg](https://github.com/Microsoft/vcpkg "Vcpkg github repository") into a folder of your choosing. I will use ```C:\vcpkg\``` in this example. Following vcpkg's installation guide, in the cloned directory |
| 19 | + |
| 20 | +From your Powershell run the scripts. |
| 21 | + ```Powershell |
| 22 | + PS C:\vcpkg> .\bootstrap-vcpkg.bat |
| 23 | + PS C:\vcpkg> .\vcpkg integrate install |
| 24 | + ``` |
| 25 | + |
| 26 | +Finally we install openssl by running |
| 27 | + ```Powershell |
| 28 | + PS C:\vcpkg> .\vcpkg install openssl:x64-windows |
| 29 | + ``` |
| 30 | +Get some coffee for this one. |
| 31 | +After the installation is done, there will be a created path |
| 32 | + ``` |
| 33 | + C:\vcpkg\installed\x64-windows\ |
| 34 | + ``` |
| 35 | +Edit your User environment Variables or System Variables, whichever you prefer and set `OPENSSL_DIR` to this path |
| 36 | + |
| 37 | +## Now for the real deal: Building Rustpython. |
| 38 | + |
| 39 | +- Clone Rustpython from [https://github.com/rustpython/rustpython](https://github.com/rustpython/rustpython). |
| 40 | +- Change directory into the clone directory. Suppose this directory is `C:\rustpython`, |
| 41 | + ```Powershell |
| 42 | + PS C:\> cd rustpython |
| 43 | + ``` |
| 44 | +- Run the script ```symlinks-to-hardlinks.ps1``` in windows powershell to copy some python files into the vm project (There was no need to type the same code twice, lol) |
| 45 | + ```powershell |
| 46 | + PS C:\rustpython> .\scripts\symlinks-to-hardlinks.ps1 |
| 47 | + ``` |
| 48 | +
|
| 49 | +- When all is done, build RustPython with cargo from the project's parent directory |
| 50 | + ```Powershell |
| 51 | + PS C:\rustpython> Cargo build --release |
| 52 | + ``` |
| 53 | +After cargo does its magic, you should see a ```targets/release``` folder created |
| 54 | +
|
| 55 | +copy the `.dll` files `libcrypto-1_1-x64.dll` and `libssl-1_1-x64.dll` from |
| 56 | + ``` |
| 57 | + C:\vcpkg\installed\x64-windows\bin |
| 58 | + ``` |
| 59 | +or the `bin` folder of wherever you installed openssl to into the ```targets/release``` directory. |
| 60 | +
|
| 61 | +## Now run *`ruspython.exe`* and enjoy it's beauty. |
0 commit comments