Skip to content

capstone 5.0.1 fails to install from pip on Windows ARM64 #2397

@mscottford

Description

@mscottford

Work environment

Questions Answers
OS/arch/bits Windows arm64
Architecture arm64
Source of Capstone pip
Version/git commit v5.0.1

Expected behavior

Running pip install capstone==5.0.1 on a Windows ARM workstation will run setup.py which will then delegate to cmake to create a capstone.dll correctly.

Actual behavior

Running pip install capstone==5.0.1 on Windows ARM results in a compilation error with the following output:

❯ pip install capstone==5.0.1
Collecting capstone
  Using cached capstone-5.0.1.tar.gz (2.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: capstone
  Building wheel for capstone (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for capstone (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      running bdist_wheel
      running build
      Building C extensions
      -- The C compiler identification is MSVC 19.40.33812.0
      -- The CXX compiler identification is MSVC 19.40.33812.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/arm64/cl.exe - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/arm64/cl.exe - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      Enabling CAPSTONE_ARM_SUPPORT
      Enabling CAPSTONE_ARM64_SUPPORT
      Enabling CAPSTONE_M68K_SUPPORT
      Enabling CAPSTONE_MIPS_SUPPORT
      Enabling CAPSTONE_PPC_SUPPORT
      Enabling CAPSTONE_SPARC_SUPPORT
      Enabling CAPSTONE_SYSZ_SUPPORT
      Enabling CAPSTONE_XCORE_SUPPORT
      Enabling CAPSTONE_X86_SUPPORT
      Enabling CAPSTONE_TMS320C64X_SUPPORT
      Enabling CAPSTONE_M680X_SUPPORT
      Enabling CAPSTONE_EVM_SUPPORT
      Enabling CAPSTONE_MOS65XX_SUPPORT
      Enabling CAPSTONE_WASM_SUPPORT
      Enabling CAPSTONE_BPF_SUPPORT
      Enabling CAPSTONE_RISCV_SUPPORT
      Enabling CAPSTONE_SH_SUPPORT
      Enabling CAPSTONE_TRICORE_SUPPORT
      CMake Error: File C:/Users/ScottFord/AppData/Local/Temp/pip-install-q4517k2w/capstone_d3c8687c49ad46db95ec0b37608615d5/src/capstone.pc.in does not exist.
      CMake Error at CMakeLists.txt:700 (configure_file):
        configure_file Problem configuring file


      CMake Error: File C:/Users/ScottFord/AppData/Local/Temp/pip-install-q4517k2w/capstone_d3c8687c49ad46db95ec0b37608615d5/src/capstone-config.cmake.in does not exist.
      CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/CMakePackageConfigHelpers.cmake:344 (configure_file):
        configure_file Problem configuring file
      Call Stack (most recent call first):
        CMakeLists.txt:705 (configure_package_config_file)


      CMake Error: File C:/Users/ScottFord/AppData/Local/Temp/pip-install-q4517k2w/capstone_d3c8687c49ad46db95ec0b37608615d5/src/cmake_uninstall.cmake.in does not exist.
      CMake Error at CMakeLists.txt:737 (configure_file):
        configure_file Problem configuring file


      -- Configuring incomplete, errors occurred!
      NMAKE : fatal error U1052: file 'Makefile' not found
      Stop.
      error: [Errno 2] No such file or directory: 'capstone.dll'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for capstone
Failed to build capstone
ERROR: Could not build wheels for capstone, which is required to install pyproject.toml-based projects

This appears to be because the following files required to build capstone on Windows ARM are not included as part of the source Python package (not version with a pre-built binary included). This is not an issue for Windows on x32/x64, because a platform specific package has been uploaded to PyPI for those OS/Architecture combinations.

Specifically, the call to cmake, as performed by setup.py, is failing to run because the capstone.pc.in, capstone-config.cmake.in, and cmake_uninstall.cmake.in files are not present in the source PyPI package. After experimenting with running cmake from the installation cache, after running pip install capstone==5.0.1 --no-clean, I experimented with copying those files from the GitHub repository, and I was able to get past that error, however others did appear.

To work around the problem, I did the following:

  • Cloned the repository with git
  • cd bindings\python
  • python setup.py bdist_wheel
  • cd dist
  • pip install .\capstone-5.0.1-py3-none-win_arm64.whi

Suggested fixes are to either release a binary PyPI package for Windows ARM and/or ensure that the files needed to build for Windows ARM are included in the source PyPI package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions