Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python readthedocs how to satisfy the requirement sip (or pyqt)

I want to publish the documentation of my project https://bitbucket.org/oaltun/opn in readthedocs.org.

The build fails. There are different errors shown in the log https://readthedocs.org/builds/opn/2247789/ , but the first is "no module named sip".

sip is needed by pyqt, which is needed by the project.

Normally in this kind of situation, as far as I understand, you would add missing package to your setup.py, and check the readthedocs.org option to create a virtualenv. I do check the box to create a virtualenv. But I can not add sip or pyqt to setup.py.

The problem is pyqt & sip does not use setuptools, so can not be installed by pip. So you can not add them to setup.py (This fails even in my local machine).

In my local environment I install pyqt with (ana)conda. But I think readthedocs.org uses pip for calling the dependencies.

So, how can I have my virtualenv include sip?

like image 216
Zargo Avatar asked Nov 01 '22 10:11

Zargo


1 Answers

The trick is to mock these interfaces:

import mock 
MOCK_MODULES = ['sip', 'PyQt4', 'PyQt4.QtGui']
sys.modules.update((mod_name, mock.MagicMock()) for mod_name in MOCK_MODULES)

Note that you must also mock the root package 'PyQt4' or will get an ImportError.

like image 89
hoju Avatar answered Nov 15 '22 05:11

hoju