If you read this, perhaps you already tried once to switch to from CPython to PyPy and you realized that matplotlib is not working. Or someone else sent you here to don’t waste your time :D.
In this post I will guide you, step by step to compile yourself matplotlib for CPython 2.7 and PyPy with all necessary dependencies.
1. Install all necessary system packages:
sudo apt-get install gstreamer-1.0 libgstreamer-plugins-base1.0 doxygen gtk+2.0 freeglut3-dev
2. Install PyPy 5.8 from https://pypy.org/download.html and activate
pip for it by running
pypy -m ensurepip
pypy -m pip install numpy
4. Download latest sources of matplotlib from GitHub (it will take a while for all ~300 MB):
git clone https://github.com/matplotlib/matplotlib.git
hg clone https://bitbucket.org/amauryfa/wxpython-cffi
wxWidgets sources and extract it:
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 tar -xjf wxWidgets-3.0.3.tar.bz2
7. Set some paths:
export WXWIN=/your/path/wxWidgets-3.0.3 which doxygen (usually /usr/bin/doxygen) export DOXYGEN=/your/path/doxygen
cd wxpython-cffi pypy build.py dox (this should finish with success) pypy build.py build_wx
pypy build.py etg --generator=cffi --nodoc (you should get some errors)
open file wx/core.pi and comment all lines from 27712 to 27720(inclusive) and save
run the build conmand again:
pypy build.py etg --generator=cffi --nodoc pypy build.py cffi_gen
10. Prepare to build matplotlib
ln -s /your/path/wxpython-cffi/cffi/ /your/path/pypy/site-packages/wx-2.8 from folder wxpython-cffi/cffi copy folders wx, wrapper_lib to/your/path/pypy/site-packages/ from folder wxpython-cffi/cffi copy files *.so to pypy/site-packages/wx/
wx module with this command:
pypy -c "import wx"
it will print out some warnings but is OK
cd ../matplotlib cp setup.cfg.template setup.cfg Open to edit setup.cfg and go near the end of file Uncomment tkagg and set it to False (tkagg = False) Uncomment wxagg and set it to True (wxagg = True) Uncomment backend and set it to WXAgg (backend = WXAgg) Save and exit Open to edit lib/matplotlib/backends/backend_wx.py and, from line 1803 remove the inheritance wx.Printout to look like this: `class PrintoutWx():` Also comment line 1805 Add below 1805: self.title = title Save and exit Download file https://raw.githubusercontent.com/wxWidgets/wxPython/master/wxversion/wxversion.py and copy in your pypy/site-packages/
The step with
wx.Printout is needed because it seems that this version of
wxPython doesn’t have this class implemented yet.
pypy setup.py build pypy setup.py install
remove the symbolic link
And you are ready to go! OK, there will be some warning and errors but at least is a starting point for improvement.
Everything in one script:
By Gabriel Munteanu, gabriel.munteanu [at] rinftech [dot] com