Search code examples
pythoncythonsetuptoolssetup.pypython-poetry

Package installed failed with poetry backend


I'm want to install a package from github.

The settings of package are as below:

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

I'm working on [MSC v.1900 64 bit (AMD64)] on win32 with python3.7.7 + pip 21.0.1 and when I install this package with

python -m pip install .

I got error like

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

But if I add a setup.py

# setup.py

import setuptools;setuptools.setup()

the package can be installed correctly, so what's wrong with the config?

Thanks.


Solution

  • pip can't use poetry as a build backend, you need to build/install this project with poetry.

    If you are on a *nix workstation, you can run curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - to install it (see the docs for details). Once that is done, run poetry install instead of python -m pip install . to get a dev-installation (including virtualization) of the project.


    If you want to create a distributable that you can upload to a package index or install directly with pip, run poetry build.