Poetry 不使用系统全局 Cython 从源代码编译依赖项

Poetry doesn`t use system-global Cython for compiling dependencies from source

我有一个从源代码编译的依赖包 hdbscan,需要 Cython 存在。

现在,依赖项是通过 Poetry 管理的,似乎在编译时 hdbscan 它使用了专用的 virtualenv,其中没有可用的 Cython。

  The following additional packages will be installed:
    dh-python libpython3-dev libpython3.7 libpython3.7-dev python3-dev
    python3.7-dev
  Suggested packages:
    cython-doc
  The following NEW packages will be installed:
    cython3 dh-python libpython3-dev libpython3.7 libpython3.7-dev python3-dev
    python3.7-dev
  0 upgraded, 7 newly installed, 0 to remove and 8 not upgraded.
  Need to get 51.9 MB of archives.
  After this operation, 96.1 MB of additional disk space will be used.
  Get:1 http://deb.debian.org/debian buster/main amd64 cython3 amd64 0.29.2-2 [1392 kB]
  Get:2 http://deb.debian.org/debian buster/main amd64 dh-python all 3.20190308 [99.3 kB]
  Get:3 http://deb.debian.org/debian buster/main amd64 libpython3.7 amd64 3.7.3-2+deb10u2 [1498 kB]
  Get:4 http://deb.debian.org/debian buster/main amd64 libpython3.7-dev amd64 3.7.3-2+deb10u2 [48.4 MB]
  Get:5 http://deb.debian.org/debian buster/main amd64 libpython3-dev amd64 3.7.3-1 [20.1 kB]
  Get:6 http://deb.debian.org/debian buster/main amd64 python3.7-dev amd64 3.7.3-2+deb10u2 [510 kB]
  Get:7 http://deb.debian.org/debian buster/main amd64 python3-dev amd64 3.7.3-1 [1264 B]
  debconf: delaying package configuration, since apt-utils is not installed
  Fetched 51.9 MB in 3s (18.8 MB/s)
.......
  Installing dependencies from lock file
  
    PackageInfoError
  
    Unable to determine package info for path: /opt/teamcity-agent/temp/buildTmp/pypoetry-git-hdbscank82kqn8_
  
    Fallback egg_info generation failed.
  
    Command ['/opt/teamcity-agent/temp/buildTmp/tmpov_cp376/.venv/bin/python', 'setup.py', 'egg_info'] errored with the following return code 1, and output:
    setup.py:8: UserWarning: No module named 'Cython'
      warnings.warn(e.args[0])
    setup.py:92: UserWarning: Due to incompatibilities with Python 3.7 hdbscan nowrequires Cython to be installed in order to build it
      warnings.warn('Due to incompatibilities with Python 3.7 hdbscan now'
    Traceback (most recent call last):
      File "setup.py", line 94, in <module>
        raise ImportError('Cython not found! Please install cython and try again')
    ImportError: Cython not found! Please install cython and try again
  
    at /opt/venv/lib/python3.7/site-packages/poetry/inspection/info.py:503 in _pep517_metadata
        499│                     venv.run("python", "setup.py", "egg_info")
        500│                     return cls.from_metadata(path)
        501│                 except EnvCommandError as fbe:
        502│                     raise PackageInfoError(
      → 503│                         path, "Fallback egg_info generation failed.", fbe
        504│                     )
        505│                 finally:
        506│                     os.chdir(cwd.as_posix())
        507│
  Process exited with code 1

我在 poetry install 之前尝试在 apt 中安装 cython3。

我在 poetry install

之前尝试过 pip install cython

我通读了一些 SO 问题并尝试添加

[build-system]
requires = ["poetry>=1.0.9", "Cython"]

到我的 pyproject.toml 文件,但它没有效果(也许它只在构建配置中定义的包时才重要)

唯一可行的是在同一个 virtualenv 或 system-global 中的 pip 中安装 cythonhdbscan,但这听起来不太合理

原来是我在https://github.com/python-poetry/poetry/issues/3744中描述的问题。

我们使用一个私有的pypi镜像并且没有显式设置

 pip config set global.index-url ${PYPI_URL} 

即使存在系统范围的 Cython,poetry 也无法在构建 virualenv 中安装 Cython