pypa / cibuildwheel

🎡 Build Python wheels for all the platforms with minimal configuration.
https://cibuildwheel.pypa.io
Other
1.83k stars 233 forks source link

CIBW crashes when after running abi3audit on windows-latest (Windows Server 2022) in Github Actions #1934

Open sdimovv opened 1 month ago

sdimovv commented 1 month ago

Description

I am running this as part of a cibuildwheel workflow.

As stated in the docs, abi3audit can be added as a step to the build workflow.

Linux and macos builds pass but on windows it fails, when abi3audit is added as a step through the CIBW_REPAIR_WHEEL_COMMAND_WINDOWS env.

I originally raised this as an abi3audit issue (https://github.com/trailofbits/abi3audit/issues/97) but was correctly pointed out that the issue is in the CIBW source, so I am rasing this here.

Build log

pip install abi3audit && abi3audit --strict --report C:\Users\runneradmin\AppData\Local\Temp\cibw-run-578cu8cj\cp38-win_amd64\built_wheel\myproject-0.1.0-cp38-abi3-win_amd64.whl
  Collecting abi3audit
    Downloading abi3audit-0.0.11-py3-none-any.whl.metadata (10 kB)
  ...
  Installing collected packages: pyelftools, urllib3, typing-extensions, six, pygments, pefile, mdurl, kaitaistruct, idna, exceptiongroup, charset-normalizer, certifi, attrs, abi3info, url-normalize, requests, markdown-it-py, cattrs, rich, requests-cache, abi3audit
  Successfully installed abi3audit-0.0.11 abi3info-2024.6.25 attrs-23.2.0 cattrs-23.2.3 certifi-2024.7.4 charset-normalizer-3.3.2 exceptiongroup-1.2.2 idna-3.7 kaitaistruct-0.10 markdown-it-py-3.0.0 mdurl-0.1.2 pefile-2023.2.7 pyelftools-0.31 pygments-2.18.0 requests-2.32.3 requests-cache-1.2.1 rich-13.7.1 six-1.16.0 typing-extensions-4.12.2 url-normalize-1.4.3 urllib3-2.2.2
  [01:17:48] \U0001f481 myproject-0.1.0-cp38-abi3-win_amd64.whl: 1 extensions scanned; 0 ABI 
             version mismatches and 0 ABI violations found                       
  {"specs": {"C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-578cu8cj\\cp38-win_amd64\\built_wheel\\myproject-0.1.0-cp38-abi3-win_amd64.whl": {"kind": "wheel", "wheel": [{"name": "_myproject.pyd", "result": {"is_abi3": true, "is_abi3_baseline_compatible": true, "baseline": "3.8", "computed": "3.8", "non_abi3_symbols": [], "future_abi3_objects": {}}}]}}}
  Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "D:\a\_temp\cibw\Scripts\cibuildwheel.exe\__main__.py", line 7, in <module>
    File "D:\a\_temp\cibw\Lib\site-packages\cibuildwheel\__main__.py", line 49, in main
      main_inner(global_options)
    File "D:\a\_temp\cibw\Lib\site-packages\cibuildwheel\__main__.py", line 184, in main_inner
      build_in_directory(args)
    File "D:\a\_temp\cibw\Lib\site-packages\cibuildwheel\__main__.py", line 352, in build_in_directory
      platform_module.build(options, tmp_path)
    File "D:\a\_temp\cibw\Lib\site-packages\cibuildwheel\windows.py", line 478, in build
      repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  StopIteration
  Error: Process completed with exit code 1.

CI config

- uses: pypa/cibuildwheel@v2.19.1
  env:
    CIBW_BUILD: |
      *cp38*
      *cp39*
      *cp310*
      *cp311*
      *cp312*
    CIBW_BUILD_FRONTEND: build
    # Build ABI3 (limited API) wheels
    CIBW_CONFIG_SETTINGS: setup-args="-Dpython.allow_limited_api=true"
    CIBW_BUILD_VERBOSITY: 1
    CIBW_TEST_COMMAND: pytest {project}
    CIBW_TEST_REQUIRES: pytest
    CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} && pip install abi3audit && abi3audit --strict --report {wheel}
    CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel} && pip install abi3audit && abi3audit --strict --report {wheel}
    CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: pip install abi3audit && abi3audit --strict --report {wheel}
    CIBW_ARCHS_WINDOWS: AMD64
  with:
    output-dir: dist
joerick commented 1 month ago

Apologies. This is a mistake in the example config in the docs, and a poor error message. The issue is that repair commands will copy the wheel into {dest_dir} when finished. The docs example misses that step. Could you try:

    CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: pip install abi3audit && abi3audit --strict --report {wheel} && copy {wheel} {dest_dir}
sdimovv commented 1 month ago

Looks like that did the trick!

I'll leave this open in case you want to update the docs, otherwise it can be closed.