首页 > 解决方案 > 诗歌后端安装包失败

问题描述

我想从 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()

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

谢谢。

标签: pythoncythonsetuptoolssetup.pypython-poetry

解决方案


pip不能使用诗歌作为构建后端,您需要使用poetry.

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


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


推荐阅读