pdm-project / pdm-backend

The build backend used by PDM that supports latest packaging standards.
https://backend.pdm-project.org
MIT License
70 stars 39 forks source link

SyntaxError when using Cython #261

Closed nokados closed 2 months ago

nokados commented 2 months ago

Since PDM-backend 2.4.0, installing my package causes the following error:

File "/home/nokados/myproject/setup.py", line 5
<Requirement('gensim')>,
SyntaxError: invalid syntax

The project includes a pdm_build.py:

"""Compiling the entire code with Cython."""
from setuptools import Extension, setup
from Cython.Build import cythonize

def pdm_build_update_setup_kwargs(context, setup_kwargs):
    extensions = cythonize(
        [
            Extension("*", sources=["src/**/*.py"]),
        ],
        language_level="3",
        nthreads=1
    )

    setup_kwargs['ext_modules'] = extensions

It works without errors on pdm-backend==2.3.3.

The build section of Pyproject.toml:

[build-system]
requires = ["setuptools>=61", "wheel", "Cython", "pdm-backend"]
build-backend = "pdm.backend"
More logs: ``` STATUS: Resolving packages from lockfile... unearth.preparer: The file . is a local directory, use it directly pdm.termui: Running PEP 517 backend to get metadata for pdm.termui: Preparing environment(Isolated mode) for PEP 517 build... pdm.termui: ======== Start resolving requirements ======== pdm.termui: Adding requirement Cython pdm.termui: Adding requirement setuptools>=61 pdm.termui: Adding requirement pdm-backend pdm.termui: Adding requirement wheel pdm.termui: Adding requirement python==3.9.19 pdm.termui: Adding requirement importlib-metadata>=3.6; python_version < "3.10"(from pdm-backend 2.4.0) pdm.termui: Adding requirement zipp>=3.20(from importlib-metadata 8.5.0) pdm.termui: ======== Resolution Result ======== pdm.termui: python None pdm.termui: setuptools 75.1.0 pdm.termui: cython 3.0.11 pdm.termui: pdm-backend 2.4.0 pdm.termui: wheel 0.44.0 pdm.termui: importlib-metadata 8.5.0 pdm.termui: zipp 3.20.2 pdm.termui: Installing cython@3.0.11... ... pdm.termui: Synchronization complete. All packages are synced to date, nothing to do. Installing the project as an editable package... pdm.termui: Overwriting distribution myproject pdm.termui: Preparing environment(Isolated mode) for PEP 517 build... pdm.termui: Running PEP 517 backend to build a wheel for pdm.termui: File "/home/nokados/myproject/setup.py", line 5 pdm.termui: , pdm.termui: ^ pdm.termui: SyntaxError: invalid syntax pdm.termui: Traceback (most recent call last): pdm.termui: File "/tmp/pdm-build-env-ndx2p18v-shared/lib/python3.9/site-packages/pdm/backend/hooks/setuptools.py", line 103, in _build_inplace pdm.termui: subprocess.check_call(build_args) pdm.termui: File "/home/nokados/.pyenv/versions/3.9.19/lib/python3.9/subprocess.py", line 373, in check_call pdm.termui: raise CalledProcessError(retcode, cmd) pdm.termui: subprocess.CalledProcessError: Command '['/home/nokados/.pyenv/versions/3.9.19/envs/myproject39-pdm/bin/python', '/home/nokados/myproject/setup.py', 'build_ext', '--inplace']' returned non-zero exit status 1. pdm.termui: pdm.termui: During handling of the above exception, another exception occurred: ... ```
frostming commented 2 months ago

Thanks, 2.4.0 has been yanked for now and it will be fixed in the next release.

frostming commented 2 months ago

Fixed by https://github.com/pdm-project/pdm-backend/commit/856d8499aa4acdf603b895fdcb6a31cbc8bda357