Skip to content

Python 3.14 compatibility: replace deprecated distutils.sysconfig with sysconfig #8109

@HavenCTO

Description

@HavenCTO

Tested libtorrent 2.0.11 against Python 3.14.2. The core library and bindings work perfectly—all 94 tests pass—but the build fails because distutils is gone.

We need to swap distutils.sysconfig for sysconfig in two places:

  1. bindings/python/CMakeLists.txt

diff

- import distutils.sysconfig
- print(distutils.sysconfig.get_python_lib(prefix='', plat_specific=True))
+ import sysconfig
+ print(sysconfig.get_path('platlib', vars={'platbase': '', 'base': ''}))
  1. bindings/python/Jamfile

diff

- python-path = [ SHELL "$(python-interpreter) -c \"import distutils.sysconfig; import sys; sys.stdout.write(distutils.sysconfig.get_python_lib())\"" ] ;
+ python-path = [ SHELL "$(python-interpreter) -c \"import sysconfig; import sys; sys.stdout.write(sysconfig.get_path('platlib'))\"" ] ;

With these applied, Python 3.14 support is fully functional. We should also update cibuildwheel to include 3.14 in the CI matrix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions