使用诗歌后端安装的软件包失败

问题描述

我想从 github 安装一个包。

包的设置如下:

pyproject.toml

...
build = "build.py"

[tool.poetry.dependencies]
python = "^3.7"

[build-system]
requires = ["poetry-core>=1.0.0","cython"]
build-backend = "poetry.core.masonry.api"

build.py

from Cython.Build import cythonize
from distutils.command.build_ext import build_ext

def build(setup_kwargs):
    setup_kwargs.update({
        'ext_modules': cythonize(["asyncmy/*.pyx"],language_level=3,compiler_directives={'linetrace': True}),'cmdclass': {'build_ext': build_ext}
    })

setup.cfg

[Flake8]
ignore = E501,W503,E203

我正在使用 [MSC v.1900 64 bit (AMD64)] on win32 + python3.7.7 处理 pip 21.0.1,当我安装此软件包时

python -m pip install .

我得到了类似的错误

ERROR: Could not build wheels for asyncmy which use PEP 517 and cannot be installed directly

但是如果我添加一个 setup.py

# setup.py

import setuptools;setuptools.setup()

包可以正确安装,那么配置有什么问题?

谢谢。

解决方法

pip 不能使用诗歌作为构建后端,您需要使用 poetry 构建/安装此项目。

如果您使用的是 *nix 工作站,则可以运行 curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - 来安装它(有关详细信息,请参阅 the docs)。完成后,运行 poetry install 而不是 python -m pip install . 以获得项目的开发安装(包括虚拟化)。


如果您想创建一个可以上传到包索引或直接使用 pip 安装的可分发文件,请运行 poetry build