无法在gitlab-ci上设置“ sphinx”

时间:2018-08-19 13:05:39

标签: python continuous-integration gitlab sphinx gitlab-ci

无法在gitlab-ci上设置狮身人面像

我正在尝试在gitlab-ci上设置并运行sphnix。它已安装在我的本地计算机上,并且服务器工作正常。但不是在gitlab-ci

这是我的gitlab-ci的一部分:

  before_script:
    - apt-get update -qq && apt-get install -yqq [......] python-pip
    - pip install sphinx

    # ..........
    - bundle exec rake ts:index
    - bundle exec rake ts:start

安装狮身人面像的输出:

$ pip install sphinx
Downloading/unpacking sphinx
[................]
Installing collected packages: sphinx, babel, [.............]
Compiling /tmp/pip-build-V2Tzes/Jinja2/jinja2/asyncfilters.py ...
  File "/tmp/pip-build-V2Tzes/Jinja2/jinja2/asyncfilters.py", line 7
    async def auto_to_seq(value):
            ^
SyntaxError: invalid syntax

Compiling /tmp/pip-build-V2Tzes/Jinja2/jinja2/asyncsupport.py ...
  File "/tmp/pip-build-V2Tzes/Jinja2/jinja2/asyncsupport.py", line 22
    async def concat_async(async_gen):
            ^
SyntaxError: invalid syntax

  Running setup.py install for MarkupSafe

    building 'markupsafe._speedups' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o
    markupsafe/_speedups.c:12:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.


    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python installation succeeded.
    ==========================================================================
Successfully installed sphinx babel sphinxcontrib-websupport Jinja2 alabaster imagesize Pygments snowballstemmer docutils packaging typing pytz MarkupSafe pyparsing
Cleaning up...

如您所见,它已经成功。

但是,到了这一点,它就会失败:

  $ bundle exec rake ts:index
  Generating configuration to /builds/my_user/my_ap123/config/test.sphinx.conf
  sh: 1: indexer: not found

  The Sphinx indexing command failed:
    Command: indexer --config "/builds/my_user/my_ap123/config/test.sphinx.conf" --all
    Status:  127
    Output:  See above

那是为什么?如何解决?

1 个答案:

答案 0 :(得分:1)

pip install sphinx并未完全成功。在安装过程中,它抱怨缺少Python.h

  

严重错误:Python.h:没有这样的文件或目录

您还需要安装python开发包。 对于python3x使用

sudo apt-get install python3-dev

对于python2x使用

sudo apt-get install python-dev

您可以将其添加到before_script

before_script:
    - apt-get update -qq && apt-get install -yqq [......] python-pip python3-dev
    - pip install sphinx

更新

要使用gitlab ci安装sphinx搜索引擎,请按照以下说明更新before_script

before_script:
    - add-apt-repository ppa:builds/sphinxsearch-rel22 sphinxsearch
    - apt-get update -qq && apt-get install -yqq [......] python-pip python3-dev mysql-client unixodbc libpq5 
    - pip install sphinxsearch