Skip to content

[BUG] cygwin C compiler fails to respect source file extension casing #5130

@Morilli

Description

@Morilli

setuptools version

setuptools==80.9.0

Python version

Python 3.12.12

OS

Windows

Additional environment information

I'm using mingw-w64-ucrt-x86_64-python from msys2/ucrt64.

Description

Trying to compile source files with custom/non-default extensions after appending them to src_extensions does not work when the extension is uppercase due to the unconditional usage of os.path.normcase in _make_out_path:

def _make_out_path(self, output_dir, strip_dir, src_name):
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
norm_src_name = os.path.normcase(src_name)
return super()._make_out_path(output_dir, strip_dir, norm_src_name)

For example, trying to compile .S files after running src_extensions.append(".S") will throw an exception, only `src_extensions.append(".s") will work.

Expected behavior

I expect compilation of files with extensions specified in src_extensions to work without having to transform them to lowercase, similar to how behavior is on unix.

How to Reproduce

I encountered this problem when trying to compile backports.zstd, so I'll use it as an example.

  1. Clone backports.zstd: git clone --recursive https://github.com/Rogdham/backports.zstd
  2. Checkout a revision with this issue: git checkout v1.2.0
  3. Try to build/install the package: pip install .

Output

warning: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    $MINGW_PACKAGE_PREFIX-python-xyz', where xyz is the package you
    are trying to install.

    If you wish to install a non-MSYS2-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-MSYS2 packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have $MINGW_PACKAGE_PREFIX-python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Processing d:\github\backports.zstd
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: backports.zstd
  Building wheel for backports.zstd (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for backports.zstd (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [44 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports
      copying src\python\backports\__init__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports
      creating build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\tarfile.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\_shutil.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\_streams.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\_zstd.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\_zstdfile.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\__init__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      creating build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile
      copying src\python\backports\zstd\zipfile\__init__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile
      copying src\python\backports\zstd\zipfile\__main__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile
      creating build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\buffer.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\compressor.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\decompressor.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\zstddict.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\_blocks_output_buffer.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\_common.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      copying src\python\backports\zstd\_cffi\__init__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\_cffi
      creating build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile\_path
      copying src\python\backports\zstd\zipfile\_path\glob.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile\_path
      copying src\python\backports\zstd\zipfile\_path\__init__.py -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile\_path
      running egg_info
      writing src/python\backports.zstd.egg-info\PKG-INFO
      writing dependency_links to src/python\backports.zstd.egg-info\dependency_links.txt
      writing top-level names to src/python\backports.zstd.egg-info\top_level.txt
      reading manifest file 'src/python\backports.zstd.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE.txt'
      adding license file 'LICENSE_zstd.txt'
      writing manifest file 'src/python\backports.zstd.egg-info\SOURCES.txt'
      copying src\python\backports\zstd\__init__.pyi -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\py.typed -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\tarfile.pyi -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd
      copying src\python\backports\zstd\zipfile\__init__.pyi -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile
      copying src\python\backports\zstd\zipfile\_path\__init__.pyi -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile\_path
      copying src\python\backports\zstd\zipfile\_path\glob.pyi -> build\lib.mingw_x86_64_ucrt_gnu-cpython-312\backports\zstd\zipfile\_path
      running build_ext
      building 'backports.zstd._zstd' extension
      error: unknown file type '.s' (from 'src\c\zstd\lib\decompress\huf_decompress_amd64.s')
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for backports.zstd
Failed to build backports.zstd
warning: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    $MINGW_PACKAGE_PREFIX-python-xyz', where xyz is the package you
    are trying to install.

    If you wish to install a non-MSYS2-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-MSYS2 packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have $MINGW_PACKAGE_PREFIX-python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> backports.zstd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions