0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-04 18:45:52 +00:00

125 lines
5.0 KiB
Diff

From 5970ff3d5eb26e35cf08397f55c2d11311f4f7bd Mon Sep 17 00:00:00 2001
From: arvidn <arvid@libtorrent.org>
Date: Mon, 11 Mar 2024 14:45:52 +0100
Subject: [PATCH] fix setup.py to not use distutils (as it has been removed in
python 3.12)
---
bindings/python/setup.py | 47 +++++++++---------------------------
2 files changed, 13 insertions(+), 36 deletions(-)
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 0eb07c2b5c6..d720c475beb 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -1,14 +1,9 @@
#!/usr/bin/env python3
import contextlib
-from distutils import log
-import distutils.cmd
-import distutils.command.install_data as install_data_lib
-import distutils.debug
-import distutils.errors
-import distutils.sysconfig
import functools
import itertools
+import logging as log
import os
import pathlib
import re
@@ -75,11 +70,11 @@ def b2_version() -> Tuple[int, ...]:
class B2Distribution(setuptools.Distribution):
def reinitialize_command(
self, command: str, reinit_subcommands: int = 0
- ) -> distutils.cmd.Command:
+ ) -> setuptools.Command:
if command == "build_ext":
- return cast(distutils.cmd.Command, self.get_command_obj("build_ext"))
+ return cast(setuptools.Command, self.get_command_obj("build_ext"))
return cast(
- distutils.cmd.Command,
+ setuptools.Command,
super().reinitialize_command(
command, reinit_subcommands=reinit_subcommands
),
@@ -155,13 +150,11 @@ def write_b2_python_config(
# other words we apply debian's override everywhere, and hope no other
# overrides ever disagree with us.
- # Note that sysconfig and distutils.sysconfig disagree here, especially on
- # windows.
- ext_suffix = distutils.sysconfig.get_config_var("EXT_SUFFIX")
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
ext_suffix = str(ext_suffix or "")
# python.jam appends the platform-specific final suffix on its own. I can't
- # find a consistent value from sysconfig or distutils.sysconfig for this.
+ # find a consistent value from sysconfig for this.
for plat_suffix in (".pyd", ".dll", ".so", ".sl"):
if ext_suffix.endswith(plat_suffix):
ext_suffix = ext_suffix[: -len(plat_suffix)]
@@ -271,7 +264,7 @@ def finalize_options(self) -> None:
super().finalize_options()
if self.config_mode not in self.CONFIG_MODES:
- raise distutils.errors.DistutilsOptionError(
+ raise setuptools.errors.DistutilsOptionError(
f"--config-mode must be one of {self.CONFIG_MODES}"
)
@@ -382,10 +375,10 @@ def _configure_b2_with_distutils(self) -> Iterator[None]:
if os.name == "nt":
self._maybe_add_arg("--abbreviate-paths")
- if distutils.debug.DEBUG:
- self._maybe_add_arg("--debug-configuration")
- self._maybe_add_arg("--debug-building")
- self._maybe_add_arg("--debug-generators")
+ # if distutils.debug.DEBUG:
+ # self._maybe_add_arg("--debug-configuration")
+ # self._maybe_add_arg("--debug-building")
+ # self._maybe_add_arg("--debug-generators")
if sys.platform == "darwin":
# boost.build defaults to toolset=clang on mac. However python.jam
@@ -411,7 +404,7 @@ def _configure_b2_with_distutils(self) -> Iterator[None]:
# macOS uses multi-arch binaries. Attempt to match the
# configuration of the running python by translating distutils
# platform modes to b2 architecture modes
- machine = distutils.util.get_platform().split("-")[-1]
+ machine = sysconfig.get_platform().split("-")[-1]
if machine == "arm64":
self._maybe_add_arg("architecture=arm")
elif machine in ("ppc", "ppc64"):
@@ -500,21 +493,6 @@ def _find_project_config(self) -> Optional[pathlib.Path]:
return None
-class InstallDataToLibDir(install_data_lib.install_data):
- def finalize_options(self) -> None:
- # install_data installs to the *base* directory, which is useless.
- # Nothing ever gets installed there, no tools search there. You could
- # only make use of it by manually picking the right install paths.
- # This instead defaults the "install_dir" option to be "install_lib",
- # which is "where packages are normally installed".
- self.set_undefined_options(
- "install",
- ("install_lib", "install_dir"), # note "install_lib"
- ("root", "root"),
- ("force", "force"),
- )
-
-
def find_all_files(path: str) -> Iterator[str]:
for dirpath, _, filenames in os.walk(path):
for filename in filenames:
@@ -532,7 +510,6 @@ def find_all_files(path: str) -> Iterator[str]:
ext_modules=[StubExtension("libtorrent.__init__")],
cmdclass={
"build_ext": LibtorrentBuildExt,
- "install_data": InstallDataToLibDir,
},
distclass=B2Distribution,
data_files=[