Skip to content

[C++] Arrow fails to build with python 3.12 #40566

@MagicalTux

Description

@MagicalTux

Describe the bug, including details regarding any error messages, version, and platform.

Specifically, I am trying to build pyarrow but hit the following error:

  -- Found Python3: /pkg/main/dev-lang.python.core.3.12.2/bin/python3 (found version "3.12.2") found components: Interpreter Development.Module NumPy
  CMake Error at cmake_modules/FindPython3Alt.cmake:77 (message):
    Python 3 config failure:

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

    ModuleNotFoundError: No module named 'distutils'

  Call Stack (most recent call first):
    CMakeLists.txt:262 (find_package)


  -- Configuring incomplete, errors occurred!

This is due to the code at https://github.com/apache/arrow/blob/main/cpp/cmake_modules/FindPython3Alt.cmake#L70 which uses distutils to obtain EXT_SUFFIX which is not valid on python 3.12.

I would suggest using this code instead:

  "import importlib.util; sysconfig = importlib.import_module('distutils.sysconfig') if importlib.util.find_spec('distutils') else importlib.import_module('sysconfig'); print(sysconfig.get_config_var('EXT_SUFFIX'))"

This will automatically import the right package depending on the availability of distutils and return the right value.

Component(s)

C++, Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions