Poetry不使用systemglobal Cython从源代码编译依赖项

2024-06-07 09:21:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个依赖包hdbscan,它是从源代码编译的,需要一个Cython

现在,依赖项是通过poyment来管理的,在编译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

在^{之前,我尝试在apt中安装cython3

我在{}之前试过{}

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

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

对于我的pyproject.toml文件,它没有效果(可能只有在构建config中定义的包时才重要)

唯一有效的方法是在同一个VirtualNV或系统全局中的pip中安装cythonhdbscan,但这听起来不合理


Tags: installedtopyorgdevinfohttpget
1条回答
网友
1楼 · 发布于 2024-06-07 09:21:16

事实证明,这与我在https://github.com/python-poetry/poetry/issues/3744中描述的问题相同

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

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

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

相关问题 更多 >

    热门问题