3

我在 github 上有一个小型应用程序项目,它在 Windows 上运行并且需要pythonnet.

我的requirement.txt包含:

beautifulsoup4==4.6
pythonnet==2.3

现在我想我会为它建立一个文档并将它放在readthedocs.org. 将我的文档推送到 github,在 上导入我的项目后readthedocs.org,我尝试构建文档,但此操作失败,原因如下:

Collecting pythonnet==2.3 (from -r /home/docs/checkouts/readthedocs.org/user_builds/trelloradar/checkouts/latest/requirements.txt (line 2))
Using cached pythonnet-2.3.0.tar.gz
Building wheels for collected packages: pythonnet
Running setup.py bdist_wheel for pythonnet: started
Running setup.py bdist_wheel for pythonnet: finished with status 'error'
Complete output from command /home/docs/checkouts/readthedocs.org/user_builds/trelloradar/envs/latest/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-iU2ADR/pythonnet/setup.py';  f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpnPH_1rpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
/bin/sh: 1: mono: not found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-iU2ADR/pythonnet/setup.py", line 405, in <module>
  zip_safe=False,
  ...
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
  raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'mono tools/nuget/nuget.exe update -self' returned non-zero exit status 127 

我知道构建失败是因为它试图安装 .Net 材料,即pythonnet在 Unix 环境中,但我只想用 Sphinx 构建文档!

我禁用了 venv 选项:

使用 setup.py install 在 vi​​rtualenv 中安装您的项目

但是我如何告诉 readthedocs 的构建过程忽略我的requirement.txt

4

1 回答 1

7

我通过创建一个requirements.readthedocs.txt空文件并在“管理”选项卡下的高级设置中将构建过程指向它来解决这个问题。

另外,要autodoc导入.Net模块而不抱怨,我将以下内容放入docs/conf.py

class Mock(MagicMock):
    @classmethod
    def __getattr__(cls, name):
        return MagicMock()

MOCK_MODULES = ['clr', 'System', 'System.Windows.Forms', 'System.Threading']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
于 2018-01-12T14:47:02.647 回答