Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update _distutils imports
  • Loading branch information
vstinner committed May 9, 2022
commit 8162b4ec3f0b0ad8b8146faa771a91af4ced60f8
2 changes: 1 addition & 1 deletion Lib/_distutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The main package for the Python Module Distribution Utilities. Normally
used from a setup script as

from distutils.core import setup
from _distutils.core import setup

setup (...)
"""
Expand Down
10 changes: 5 additions & 5 deletions Lib/_distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import subprocess
import winreg

from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
CompileError, LibError, LinkError
from distutils.ccompiler import CCompiler, gen_lib_options
from distutils import log
from distutils.util import get_platform
from _distutils.errors import DistutilsExecError, DistutilsPlatformError, \
CompileError, LibError, LinkError
from _distutils.ccompiler import CCompiler, gen_lib_options
from _distutils import log
from _distutils.util import get_platform

from itertools import count

Expand Down
8 changes: 4 additions & 4 deletions Lib/_distutils/archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
zipfile = None


from distutils.errors import DistutilsExecError
from distutils.spawn import spawn
from distutils.dir_util import mkpath
from distutils import log
from _distutils.errors import DistutilsExecError
from _distutils.spawn import spawn
from _distutils.dir_util import mkpath
from _distutils import log

try:
from pwd import getpwnam
Expand Down
10 changes: 5 additions & 5 deletions Lib/_distutils/bcppcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@


import os
from distutils.errors import \
from _distutils.errors import \
DistutilsExecError, \
CompileError, LibError, LinkError, UnknownFileError
from distutils.ccompiler import \
from _distutils.ccompiler import \
CCompiler, gen_preprocess_options
from distutils.file_util import write_file
from distutils.dep_util import newer
from distutils import log
from _distutils.file_util import write_file
from _distutils.dep_util import newer
from _distutils import log

class BCPPCompiler(CCompiler) :
"""Concrete class that implements an interface to the Borland C/C++
Expand Down
18 changes: 9 additions & 9 deletions Lib/_distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
for the Distutils compiler abstraction model."""

import sys, os, re
from distutils.errors import *
from distutils.spawn import spawn
from distutils.file_util import move_file
from distutils.dir_util import mkpath
from distutils.dep_util import newer_group
from distutils.util import split_quoted, execute
from distutils import log
from _distutils.errors import *
from _distutils.spawn import spawn
from _distutils.file_util import move_file
from _distutils.dir_util import mkpath
from _distutils.dep_util import newer_group
from _distutils.util import split_quoted, execute
from _distutils import log

class CCompiler:
"""Abstract base class to define the interface that must be implemented
Expand Down Expand Up @@ -896,7 +896,7 @@ def announce(self, msg, level=1):
log.debug(msg)

def debug_print(self, msg):
from distutils.debug import DEBUG
from _distutils.debug import DEBUG
if DEBUG:
print(msg)

Expand Down Expand Up @@ -977,7 +977,7 @@ def show_compilers():
# XXX this "knows" that the compiler option it's describing is
# "--compiler", which just happens to be the case for the three
# commands that use it.
from distutils.fancy_getopt import FancyGetopt
from _distutils.fancy_getopt import FancyGetopt
compilers = []
for compiler in compiler_class.keys():
compilers.append(("compiler="+compiler, None,
Expand Down
14 changes: 7 additions & 7 deletions Lib/_distutils/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"""

import sys, os, re
from distutils.errors import DistutilsOptionError
from distutils import util, dir_util, file_util, archive_util, dep_util
from distutils import log
from _distutils.errors import DistutilsOptionError
from _distutils import util, dir_util, file_util, archive_util, dep_util
from _distutils import log

class Command:
"""Abstract base class for defining command classes, the "worker bees"
Expand Down Expand Up @@ -51,7 +51,7 @@ def __init__(self, dist):
instantiated.
"""
# late import because of mutual dependence between these classes
from distutils.dist import Distribution
from _distutils.dist import Distribution

if not isinstance(dist, Distribution):
raise TypeError("dist must be a Distribution instance")
Expand Down Expand Up @@ -149,7 +149,7 @@ def finalize_options(self):


def dump_options(self, header=None, indent=""):
from distutils.fancy_getopt import longopt_xlate
from _distutils.fancy_getopt import longopt_xlate
if header is None:
header = "command options for '%s':" % self.get_command_name()
self.announce(indent + header, level=log.INFO)
Expand Down Expand Up @@ -185,7 +185,7 @@ def debug_print(self, msg):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
"""
from distutils.debug import DEBUG
from _distutils.debug import DEBUG
if DEBUG:
print(msg)
sys.stdout.flush()
Expand Down Expand Up @@ -361,7 +361,7 @@ def move_file (self, src, dst, level=1):

def spawn(self, cmd, search_path=1, level=1):
"""Spawn an external command respecting dry-run flag."""
from distutils.spawn import spawn
from _distutils.spawn import spawn
spawn(cmd, search_path, dry_run=self.dry_run)

def make_archive(self, base_name, format, root_dir=None, base_dir=None,
Expand Down
8 changes: 4 additions & 4 deletions Lib/_distutils/command/bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
distribution)."""

import os
from distutils.core import Command
from distutils.errors import *
from distutils.util import get_platform
from _distutils.core import Command
from _distutils.errors import *
from _distutils.util import get_platform


def show_formats():
"""Print list of available formats (arguments to "--format" option).
"""
from distutils.fancy_getopt import FancyGetopt
from _distutils.fancy_getopt import FancyGetopt
formats = []
for format in bdist.format_commands:
formats.append(("formats=" + format, None,
Expand Down
12 changes: 6 additions & 6 deletions Lib/_distutils/command/bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
$exec_prefix)."""

import os
from distutils.core import Command
from distutils.util import get_platform
from distutils.dir_util import remove_tree, ensure_relative
from distutils.errors import *
from distutils.sysconfig import get_python_version
from distutils import log
from _distutils.core import Command
from _distutils.util import get_platform
from _distutils.dir_util import remove_tree, ensure_relative
from _distutils.errors import *
from _distutils.sysconfig import get_python_version
from _distutils import log

class bdist_dumb(Command):

Expand Down
12 changes: 6 additions & 6 deletions Lib/_distutils/command/bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
distributions)."""

import subprocess, sys, os
from distutils.core import Command
from distutils.debug import DEBUG
from distutils.file_util import write_file
from distutils.errors import *
from distutils.sysconfig import get_python_version
from distutils import log
from _distutils.core import Command
from _distutils.debug import DEBUG
from _distutils.file_util import write_file
from _distutils.errors import *
from _distutils.sysconfig import get_python_version
from _distutils import log

class bdist_rpm(Command):

Expand Down
8 changes: 4 additions & 4 deletions Lib/_distutils/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Implements the Distutils 'build' command."""

import sys, os
from distutils.core import Command
from distutils.errors import DistutilsOptionError
from distutils.util import get_platform
from _distutils.core import Command
from _distutils.errors import DistutilsOptionError
from _distutils.util import get_platform


def show_compilers():
from distutils.ccompiler import show_compilers
from _distutils.ccompiler import show_compilers
show_compilers()


Expand Down
12 changes: 6 additions & 6 deletions Lib/_distutils/command/build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# cut 'n paste. Sigh.

import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log
from _distutils.core import Command
from _distutils.errors import *
from _distutils.sysconfig import customize_compiler
from _distutils import log

def show_compilers():
from distutils.ccompiler import show_compilers
from _distutils.ccompiler import show_compilers
show_compilers()


Expand Down Expand Up @@ -96,7 +96,7 @@ def run(self):
return

# Yech -- this is cut 'n pasted from build_ext.py!
from distutils.ccompiler import new_compiler
from _distutils.ccompiler import new_compiler
self.compiler = new_compiler(compiler=self.compiler,
dry_run=self.dry_run,
force=self.force)
Expand Down
28 changes: 14 additions & 14 deletions Lib/_distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import os
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
from distutils import log
from _distutils.core import Command
from _distutils.errors import *
from _distutils.sysconfig import customize_compiler, get_python_version
from _distutils.sysconfig import get_config_h_filename
from _distutils.dep_util import newer_group
from _distutils.extension import Extension
from _distutils.util import get_platform
from _distutils import log

from site import USER_BASE

Expand All @@ -26,7 +26,7 @@


def show_compilers ():
from distutils.ccompiler import show_compilers
from _distutils.ccompiler import show_compilers
show_compilers()


Expand Down Expand Up @@ -128,7 +128,7 @@ def initialize_options(self):
self.parallel = None

def finalize_options(self):
from distutils import sysconfig
from _distutils import sysconfig

self.set_undefined_options('build',
('build_lib', 'build_lib'),
Expand Down Expand Up @@ -276,7 +276,7 @@ def finalize_options(self):
raise DistutilsOptionError("parallel should be an integer")

def run(self):
from distutils.ccompiler import new_compiler
from _distutils.ccompiler import new_compiler

# 'self.extensions', as supplied by setup.py, is a list of
# Extension instances. See the documentation for Extension (in
Expand Down Expand Up @@ -678,7 +678,7 @@ def get_ext_filename(self, ext_name):
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
"""
from distutils.sysconfig import get_config_var
from _distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')
return os.path.join(*ext_path) + ext_suffix
Expand Down Expand Up @@ -713,7 +713,7 @@ def get_libraries(self, ext):
# to need it mentioned explicitly, though, so that's what we do.
# Append '_d' to the python import library on debug builds.
if sys.platform == "win32":
from distutils._msvccompiler import MSVCCompiler
from _distutils._msvccompiler import MSVCCompiler
if not isinstance(self.compiler, MSVCCompiler):
template = "python%d%d"
if self.debug:
Expand All @@ -732,7 +732,7 @@ def get_libraries(self, ext):
# On Cygwin (and if required, other POSIX-like platforms based on
# Windows like MinGW) it is simply necessary that all symbols in
# shared libraries are resolved at link time.
from distutils.sysconfig import get_config_var
from _distutils.sysconfig import get_config_var
link_libpython = False
if get_config_var('Py_ENABLE_SHARED'):
# A native build on an Android device or on Cygwin
Expand Down
10 changes: 5 additions & 5 deletions Lib/_distutils/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import sys
import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log
from _distutils.core import Command
from _distutils.errors import *
from _distutils.util import convert_path, Mixin2to3
from _distutils import log

class build_py (Command):

Expand Down Expand Up @@ -376,7 +376,7 @@ def byte_compile(self, files):
self.warn('byte-compiling is disabled, skipping.')
return

from distutils.util import byte_compile
from _distutils.util import byte_compile
prefix = self.build_lib
if prefix[-1] != os.sep:
prefix = prefix + os.sep
Expand Down
10 changes: 5 additions & 5 deletions Lib/_distutils/command/build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import os, re
from stat import ST_MODE
from distutils import sysconfig
from distutils.core import Command
from distutils.dep_util import newer
from distutils.util import convert_path, Mixin2to3
from distutils import log
from _distutils import sysconfig
from _distutils.core import Command
from _distutils.dep_util import newer
from _distutils.util import convert_path, Mixin2to3
from _distutils import log
import tokenize

# check if Python is called on the first line with this expression
Expand Down
4 changes: 2 additions & 2 deletions Lib/_distutils/command/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Implements the Distutils 'check' command.
"""
from distutils.core import Command
from distutils.errors import DistutilsSetupError
from _distutils.core import Command
from _distutils.errors import DistutilsSetupError

try:
# docutils is installed
Expand Down
6 changes: 3 additions & 3 deletions Lib/_distutils/command/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18

import os
from distutils.core import Command
from distutils.dir_util import remove_tree
from distutils import log
from _distutils.core import Command
from _distutils.dir_util import remove_tree
from _distutils import log

class clean(Command):

Expand Down
Loading