Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock import of ctypes fails with unsupported operand #1342

Closed
maphew opened this issue Jun 14, 2015 · 1 comment
Closed

Mock import of ctypes fails with unsupported operand #1342

maphew opened this issue Jun 14, 2015 · 1 comment

Comments

@maphew
Copy link

maphew commented Jun 14, 2015

I have small Windows module that relies on the ctypes core module. On the project RTD site the page for the module comes up empty. Looking at the latest almost successful build log https://readthedocs.org/builds/apt/2900858/ there is a failure during make html stage.

  File "/var/build/user_builds/apt/checkouts/latest/knownpaths.py", line 5, in <module>
    from ctypes import windll, wintypes
  File "/usr/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
    class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported

Following the FAQ entry https://read-the-docs.readthedocs.org/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules I tried to fake import ctypes using mock, but doing so cause the build to fail completely. From what I can tell, but I'm no means an expert in this area, it's because mock itself is missing some math functions:

  File "/var/build/user_builds/apt/checkouts/latest/knownpaths.py", line 13, in GUID
    ("Data4", wintypes.BYTE * 8)
TypeError: unsupported operand type(s) for *: 'Mock' and 'int'

Full details of the trouble and steps taken so far at maphew/apt#48

Am I following the right path? Can ctypes be used in a project on RTD and I just need to persevere?

@maphew
Copy link
Author

maphew commented Jun 21, 2015

Initially I thought it was ctypes itself that needed to be mocked, but
it turns out I needed to work closer to home and mock the module which
calls ctypes, not ctypes itself
.

- MOCK_MODULES = ['ctypes']
+ MOCK_MODULES = ['knownpaths']

Thank you to @Dunes on stack Overflow for guiding me in the right direction
http://stackoverflow.com/questions/30950870/mock-import-of-ctypes-fails-with-unsupported-operand-on-read-the-docs/

@maphew maphew closed this as completed Jun 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant