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?

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.