python - 我怎样才能让 readthedocs.org build 忽略我的 requirement.txt?

标签 python windows read-the-docs requirements.txt pythonnet

我在 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 

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

我禁用了 venv 选项:

Install your project inside a virtualenv using setup.py install

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

最佳答案

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

此外,为了让 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)

关于python - 我怎样才能让 readthedocs.org build 忽略我的 requirement.txt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48224674/

相关文章:

github - 如何在 ReadTheDocs 中的一个项目中设置多个 Sphinx 文档?

python - 使用条件删除列表列表中的重复项

python - 如何在我的 Pig Latin Translator (Python) 上添加退出选项

windows - 如何在 Windows 上的 powershell 上执行 sudo

c# - 如何通过变量查找分配的内存?

jupyter-notebook - nbsphinx 在构建 Jupyter Notebook 时导致构建失败

Python:根据 boolean 条件消除 Pandas DataFrame 中的行

python - 使用反向范围变量的嵌套循环

windows - 从 Windows 中的\文件夹中删除非 native 计划任务

restructuredtext - 使用 nbsphinx 阅读文档