Compiling using translate [a small tutorial]

I thought I would post a small tutorial on using translate.py to compile pypy RPython scripts This tutorial is about how to compile python standalone executables using RPYTHON. RPython is a restricted subset of of python RPython (Restricted Python) is statically typed What will we cover in this tutorial is setting up an environment for building src code in RPython First you will need to download PyPy and MinGW (the pypy translator is only available in the source of PyPy we will need translate.py later to compile the executable. So get the latest source using Mercurial) Download Mercurial here *http://mercurial.selenic.com* and install it. Using Mercurial run this command from your cmd prompt *hg clone* *https://bitbucket.org/pypy/pypy* Now you will have PyPy downloaded. I just moved it to the directory C:\pypy for easy reference. Next we will add an Environment Variable to the directory containing translate.py it should be in C:\pypy\pypy\translator\goal\ the file translate.py will be in this goal directory Now you will need to install MinGW * http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mi... * Installing the C++ compiler and the MSYS tools also Add the bin directory of MinGW to your path as well as \msys\1.0\bin; So if you installed MinGW to to C:\MinGW it would be C:\MinGW\bin and C:\MinGW\msys\1.0\bin; You will need to use MinGW to compile a dll before we can start. This is so we can use CTYPES as well MinGW will be our compiler for RPython Now download the libffi source *http://sourceware.org/libffi/* once again this will allow for CTYPES in PyPy and MingW cd to the libffi source directory (you just downloaded) extract it and type * sh ./configure make* this will create a dll in .libs in the directory where you extracted the libffi srcs. The dll will be called: *libffi-5.dll * Next add this to a folder on your C drive and add it to your Environment Variable/Path Now you should be able to compile source using *translate.py --cc=mingw32 --output test.exe test.py * Obviously changing directories to where your script is. This was really only to be a reference for me. I wrote this originally as a reference for myself last year but I imagine some one can use it *cheers Andrew
participants (1)
-
Andrew Evans