Skip to content

[BUG] Building Cython extension on Windows triggers TypeError #268

@daniel-larraz

Description

@daniel-larraz

setuptools version

setuptools==70.2.0

Python version

Python 3.12

OS

Windows

Additional environment information

MSYS2 MINGW64

Description

Version 70.2.0 triggers a TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' when building a Cython extension on Windows using MSYS2 MINGW64. Previous versions of setuptools work fine.

Expected behavior

The Cython extension should build successfully without any errors.

How to Reproduce

  1. Create a directory with three files helloworld.pyx, setup.py, and setup.cfg:
# helloworld.pyx
print("Hello World")
# setup.py
from setuptools import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)
# setup.cfg
[build]
compiler = mingw32
  1. Launch a MINGW64 environment and go to the directory above.
  2. Run: C:\path\to\python.exe setup.py build_ext --inplace

Output

running build_ext
Traceback (most recent call last):
  File "C:\Users\Daniel\Desktop\reproducer\setup.py", line 4, in <module>
    setup(
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\core.py", line 184, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\core.py", line 200, in run_commands
    dist.run_commands()
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 970, in run_commands
    self.run_command(cmd)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py", line 974, in run_command
    super().run_command(command)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 989, in run_command
    cmd_obj.run()
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\command\build_ext.py", line 93, in run
    _build_ext.run(self)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 329, in run
    customize_compiler(self.compiler)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\_distutils\sysconfig.py", line 333, in customize_compiler
    cpp = cc + " -E"  # not always
          ~~~^~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions