Skip to content

Commit

Permalink
BUG: Fix python3.12 distutils dev.py build
Browse files Browse the repository at this point in the history
Fix gh-18689 gh-18922

python3.12 removes distutils and scipy dev.py uses
distutils for the meson based build in debian python.
With python3.12 debian has patched sysconfig and no
longer requires dependence on distutils.
  • Loading branch information
AnirudhDagar authored and tylerjereddy committed Sep 26, 2023
1 parent fd3b923 commit 6d09fc2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions dev.py
Expand Up @@ -111,14 +111,6 @@ def task_meta(cls, **kwargs):
import traceback
from concurrent.futures.process import _MAX_WINDOWS_WORKERS

# distutils is required to infer meson install path
# if this needs to be replaced for Python 3.12 support and there's no
# stdlib alternative, use CmdAction and the hack discussed in gh-16058
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from distutils import dist
from distutils.command.install import INSTALL_SCHEMES

from pathlib import Path
from collections import namedtuple
from types import ModuleType as new_module
Expand Down Expand Up @@ -337,14 +329,22 @@ def get_site_packages(self):
Depending on whether we have debian python or not,
return dist_packages path or site_packages path.
"""
if 'deb_system' in INSTALL_SCHEMES:
# debian patched python in use
install_cmd = dist.Distribution().get_command_obj('install')
install_cmd.select_scheme('deb_system')
install_cmd.finalize_options()
plat_path = Path(install_cmd.install_platlib)
else:
if sys.version_info >= (3, 12):
plat_path = Path(get_path('platlib'))
else:
# distutils is required to infer meson install path
# for python < 3.12 in debian patched python
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from distutils import dist
from distutils.command.install import INSTALL_SCHEMES
if 'deb_system' in INSTALL_SCHEMES:
# debian patched python in use
install_cmd = dist.Distribution().get_command_obj('install')
install_cmd.finalize_options()
plat_path = Path(install_cmd.install_platlib)
else:
plat_path = Path(get_path('platlib'))
return self.installed / plat_path.relative_to(sys.exec_prefix)


Expand Down

0 comments on commit 6d09fc2

Please sign in to comment.