Skip to content

[BUG] v76.1.0 broke pywin32 builds #4968

@Avasam

Description

@Avasam

setuptools version

setuptools>=76.1.0

Python version

All

OS

Windows (x86, x64 and cross-compiled arm64)

Additional environment information

I'd love to provide a proper MRE, but this only happens on GitHub's CI... building works fine on any recent setuptools version locally... Which also makes it quite the puzzle to bissect.

I made sure to clear pip's cache, and delete any build, dist or pywin32.egg-info folder I had in my local repo.

As additional information, @mhammond mentioned that: mhammond/pywin32#2493 (comment)

[...] this is generated from the .mc file - iirc, distutils etc handled this, although there is an ominous comment here

    # Work around bpo-36302/bpo-42009 - it sorts sources but this breaks
    # support for building .mc files etc :(
    def compile(self, sources, **kwargs):
        # re-sort the list of source files but ensure all .mc files come first.
        def key_reverse_mc(a):
            b, e = os.path.splitext(a)
            e = "" if e == ".mc" else e
            return (e, b)

        sources = sorted(sources, key=key_reverse_mc)
        return MSVCCompiler.compile(self, sources, **kwargs)

(as a sidenote, if whatever hack pywin32 has to do here was handled by setuptools, that'd get it much closer to stop using distutils and MSVCCompiler directly)

Description

Since setuptools v76.1, pywin32's CI builds fail.

I tried specifically with v76.1, v77.0.3 and v88. All the same error.

Expected behavior

A successful build.

How to Reproduce

  1. Clone https://github.com/mhammond/pywin32 or start from this PR: Fix setuptools 76.1 issue (and bump to >=77.0.3) mhammond/pywin32#2587
  2. Make sure to set setuptools>=76.1 in pyproject.toml:
    [build-system]
    # setuptools==75.4 dropped support for Python 3.8
    # setuptools==76.1 breaks building of .mc files
    # win32/src/PythonService.cpp(49): fatal error C1083: Cannot open include file: 'PythonServiceMessages.h': No such file or directory
    requires = [
      "setuptools >=77.0.3; python_version >='3.9'", 
      "setuptools <76.1; python_version <'3.9'",
    ]
    build-backend = "setuptools.build_meta"
    or (and ignore Python 3.8 failures)
    [build-system]
    # setuptools==76.1 breaks building of .mc files
    # win32/src/PythonService.cpp(49): fatal error C1083: Cannot open include file: 'PythonServiceMessages.h': No such file or directory
    requires = ["setuptools >=77.0.3"]
    build-backend = "setuptools.build_meta"
  3. See the CI fail.

Output

https://github.com/mhammond/pywin32/actions/runs/14719773942/job/41311171599?pr=2587#step:5:799

  win32/src/PythonService.cpp(49): fatal error C1083: Cannot open include file: 'PythonServiceMessages.h': No such file or directory
  -- distutils hack to expose all include & lib dirs
  -- orig compiler.include_dirs: ['C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\include', 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\Include']
  -- orig compiler.library_dirs: ['C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\libs', 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64', 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\PCbuild\\amd64', 'build\\temp.win-amd64-cpython-39\\Release']
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  error: subprocess-exited-with-error
  
  Building wheel for pywin32 (pyproject.toml) did not run successfully.
  exit code: 1
  
  See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\hostedtoolcache\windows\Python\3.9.13\x64\python.exe' 'C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py' build_wheel 'C:\Users\RUNNER~1\AppData\Local\Temp\tmp7gl02_fu'
  cwd: D:\a\pywin32\pywin32
  Building wheel for pywin32 (pyproject.toml): finished with status 'error'
  ERROR: Failed building wheel for pywin32
Failed to build pywin32

Notice:  A new release of pip is available: 25.0.1 -> 25.1
Notice:  To update, run: python.exe -m pip install --upgrade pip
ERROR: Failed to build installable wheels for some pyproject.toml based projects (pywin32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions