The key to remember here is that PyPy requires it’s own instance of pip, and apt-get python-pip will only install pip for the CPython version you have installed elsewhere…
Download the latest release of PyPy to /opt from here: http://pypy.org/download.html
cd /opt sudo wget https://bitbucket.org/pypy/pypy/downloads/pypy-2.5.1-linux64.tar.bz2
Un-tar the download in /opt:
sudo tar -xvjf pypy-2.5.1-linux64.tar.bz2
Then change directory to bin of PyPy:
cd /opt/pypy-2.5.1-linux64/bin
Download pip setup from here: https://bootstrap.pypa.io/get-pip.py
sudo wget https://bootstrap.pypa.io/get-pip.py
Run pip setup:
sudo ./pypy get-pip.py
Setup symbolic links for the user account that will be running the pypy python:
cd /usr/local/bin/ sudo ln -s /opt/pypy-2.5.1-linux64/bin/pypy pypy sudo ln -s pypy python
Verify all went well (you can see both python and pypy at terminal point to pypy):
dave@wamp1:~$ pypy Python 2.7.9 (9c4588d731b7, Mar 23 2015, 16:30:30) [PyPy 2.5.1 with GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>> dave@wamp1:~$ python Python 2.7.9 (9c4588d731b7, Mar 23 2015, 16:30:30) [PyPy 2.5.1 with GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>>
Setup symbolic link for the user account that will be running the pip for pypy and loading packages:
cd /usr/local/bin/ sudo ln -s /opt/pypy-2.5.1-linux64/bin/pip pypy-pip
Then you can install python packages inside pypy so a pypy instance can use them just like if they were installed in python (though you will probably need symbolic links from /usr/local/bin if they have binaries like crossbar does…):
cd ~ sudo apt-get install gcc libssl-dev libffi-dev sudo pypy-pip install -U crossbar python-dev wsaccel setproctitle
Or optionally for nightly builds:
sudo pypy-pip install -U https://github.com/crossbario/crossbar/zipball/master python-dev wsaccel setproctitle
Then:
cd /usr/local/bin/ sudo ln -s /opt/pypy-2.5.1-linux64/bin/crossbar crossbar
Next we need to make sure that in this instance, our package is pointing to the correct python interpreter, in this case we want to use pypy:
cd /opt/pypy-2.5.1-linux64/bin/ sudo nano crossbar
And change the first line from #!/usr/bin/python to:
#!/opt/pypy-2.5.1-linux64/bin/pypy
Now we can run crossbar’s CLI “version” command to get info (Note: Stock CPython install of crossbar.io will list ujson for WAMP JSON Codec but I could not get ujson installed in pypy):
dave@wamp1:~$ crossbar version Crossbar.io package versions and platform information: Crossbar.io : 0.10.4 Autobahn|Python : 0.10.3 WebSocket UTF8 Validator : wsaccel-0.6.2 WebSocket XOR Masker : wsaccel-0.6.2 WAMP JSON Codec : stdlib WAMP MsgPack Codec : msgpack-python-0.4.6 Twisted : 15.1.0-EPollReactor Python : 2.7.9-PyPy OS : Linux-3.13.0-45-generic-x86_64-with-debian-jessie-sid Machine : x86_64
uJSON error below:
dave@wamp1:~$ sudo pypy-pip install -U ujson Collecting ujson Downloading ujson-1.33.zip (197kB) 100% |████████████████████████████████| 200kB 927kB/s Installing collected packages: ujson Running setup.py install for ujson Complete output from command /opt/pypy-2.5.1-linux64/bin/pypy -c "import setuptools, tokenize;__file__='/tmp/pip-build-JXCIjX/ujson/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-tLVOiN-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'ujson' extension creating build creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/python creating build/temp.linux-x86_64-2.7/lib cc -O2 -fPIC -Wimplicit -I./python -I./lib -I/opt/pypy-2.5.1-linux64/include -c ./python/ujson.c -o build/temp.linux-x86_64-2.7/./python/ujson.o -D_GNU_SOURCE cc -O2 -fPIC -Wimplicit -I./python -I./lib -I/opt/pypy-2.5.1-linux64/include -c ./python/objToJSON.c -o build/temp.linux-x86_64-2.7/./python/objToJSON.o -D_GNU_SOURCE ./python/objToJSON.c: In function ‘Object_beginTypeContext’: ./python/objToJSON.c:523:3: warning: implicit declaration of function ‘PyObject_Malloc’ [-Wimplicit-function-declaration] tc->prv = PyObject_Malloc(sizeof(TypeContext)); ^ ./python/objToJSON.c:523:11: warning: assignment makes pointer from integer without a cast [enabled by default] tc->prv = PyObject_Malloc(sizeof(TypeContext)); ^ ./python/objToJSON.c:663:13: warning: implicit declaration of function ‘PyAnySet_Check’ [-Wimplicit-function-declaration] if (PyAnySet_Check(obj)) ^ ./python/objToJSON.c:722:13: warning: implicit declaration of function ‘PyObject_Free’ [-Wimplicit-function-declaration] PyObject_Free(tc->prv); ^ ./python/objToJSON.c: In function ‘objToJSON’: ./python/objToJSON.c:817:3: error: ‘PyObject_Malloc’ undeclared (first use in this function) PyObject_Malloc, ^ ./python/objToJSON.c:817:3: note: each undeclared identifier is reported only once for each function it appears in ./python/objToJSON.c:818:3: error: ‘PyObject_Realloc’ undeclared (first use in this function) PyObject_Realloc, ^ ./python/objToJSON.c:819:3: error: ‘PyObject_Free’ undeclared (first use in this function) PyObject_Free, ^ error: command 'cc' failed with exit status 1 ---------------------------------------- Command "/opt/pypy-2.5.1-linux64/bin/pypy -c "import setuptools, tokenize;__file__='/tmp/pip-build-JXCIjX/ujson/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-tLVOiN-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-JXCIjX/ujson