Building PyPy on Windows

  1. Install Microsoft Visual Studio 2010
  2. Install Python for Windows
  3. Download PyPy sources
  4. tar jxf pypy-1.4.1-src.tar.bz2
  5. cd pypy-1.4.1-src/pypy/translate/goals
  6. C:Python27python translate.py

Some errors:

[platform:ERROR] platcheck_1.c
[platform:ERROR] c:userschuitoyapppypy-1.4.1-srcpypytranslatorgoalusession-1platcheck_1.c(21) : fatal error C10
83: Cannot open include file: 'expat.h': No such file or directory
  :
  :
[translation:ERROR]    File "C:Python27libctypes__init__.py", line 353, in __init__
[translation:ERROR]     self._handle = _dlopen(self._name, mode)
[translation:ERROR]  WindowsError: [Error 193] %1 is not a valid Win32 application
[translation] start debugger...
> c:python27libctypes__init__.py(353)__init__()
-> self._handle = _dlopen(self._name, mode)
(Pdb+)
(Pdb+) p self._name
'C:\Users\Chui\toyapp\pypy-1.4.1-src\pypy\translator\c\src\libffi_msvc\externmod.dll'

This is probably because I’m running 64-bit python, but the DLL built is 32 bit.

The easiest option seems to be download 32-bit python and build instead.

C:Python27-32python translate.py

So far, I’m getting some platcheck errors, mainly due to missing third party files.

  • expat
  • openssl
  • zlib
  • bzlib
  • gettimeofday
  • bind_textdomain_codeset

After an hour or so, two little executables appeared.

  13M 2010-12-23 10:51 libpypy-c.dll
 6.0K 2010-12-23 10:51 pypy-c.exe
$ ./pypy-c.exe
Python 2.5.2 (, Dec 23 2010, 00:10:05)
[PyPy 1.4.1] on win32
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: `` : w  [sigh]
 -s''
>>>> import sys
>>>> sys.path
['', 'C:\Users\Chui\toyapp\pypy-1.4.1-src\lib_pypy', 'C:\Users\Chui\toyapp\pypy-1.4.1-src\lib-python\modified
-2.5.2', 'C:\Users\Chui\toyapp\pypy-1.4.1-src\lib-python\2.5.2', 'C:\Users\Chui\toyapp\pypy-1.4.1-src\site-pa
ckages']

For this effort, I end up with a fast python interpreter that was built from python sources. Now to find the bytecode intepreter…

The opcodes are in src/pypy/interpreter/pyopcode.py.

This looks reasonably easy to modify:

    def ROT_TWO(self, oparg, next_instr):
        w_1 = self.popvalue()
        w_2 = self.popvalue()
        self.pushvalue(w_1)
        self.pushvalue(w_2)

Any ideas what experiments I could run with PyPy?


About this entry