0

I created a python library which depends on pypiwin32 package. For some functionality, they use _winreg package. It works on Windows, however RTD virtualenv is not running on Windows and this package is not available. Since it is part of python itself and not on pypi, there is no way I could make it a dependency.

Each time i build docs from source code, it fails on missing the _winreg package.

I tried to remove dependency on pypiwin32 only for RTD with something like this in setup.py:

if os.environ.get('READTHEDOCS') == 'True': REQUIRED = [] else: REQUIRED = [ "pypiwin32" ] 

It works for all .rst Sphinx files. On the other hand, no documentation for functions is generated. On local machine (Windows) everything is properly documented.

Note: Read the docs documentation is generated from rtd branch of my github project.

Is there any workaround for this?

Thank you.

1 Answer 1

0

I might have found working solution. Since Read The Docs does not support _winreg, I disabled whole dependency on pypiwin32 for Read The Docs.

# ... part of setup.py if os.environ.get('READTHEDOCS') == 'True': REQUIRED = [] else: REQUIRED = [ "pypiwin32" ] 

READTHEDOCS is environmental variable available only on RTD, see more.

This broke all calls from my library. Thus I created another file with mockup functions just for Read The Docs:

# ... part of __init__.py if os.environ.get('READTHEDOCS') != 'True': from win32api import GetModuleHandle # ... import rest of win32api functions else: from .read_the_docs import * 

And content of read_the_docs.py:

def GetMOduleHandle(*args, **kwargs): pass # ... rest of file 

This way, local build use full pypiwin32 with _winreg, but on Read The Docs, Sphinx uses this kind of "mockup" utility.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.