Skip to content

Commit

Permalink
Prefer relative imports for better portability.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 4, 2022
1 parent bf3e726 commit 74090e3
Show file tree
Hide file tree
Showing 40 changed files with 153 additions and 153 deletions.
8 changes: 4 additions & 4 deletions distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
with contextlib.suppress(ImportError):
import winreg

from distutils.errors import (
from .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 .ccompiler import CCompiler, gen_lib_options
from . import log
from .util import get_platform

from itertools import count

Expand Down
8 changes: 4 additions & 4 deletions 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 .errors import DistutilsExecError
from .spawn import spawn
from .dir_util import mkpath
from . import log

try:
from pwd import getpwnam
Expand Down
10 changes: 5 additions & 5 deletions distutils/bcppcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
import os
import warnings

from distutils.errors import (
from .errors import (
DistutilsExecError,
CompileError,
LibError,
LinkError,
UnknownFileError,
)
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 .ccompiler import CCompiler, gen_preprocess_options
from .file_util import write_file
from .dep_util import newer
from . import log


warnings.warn(
Expand Down
14 changes: 7 additions & 7 deletions distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import os
import re

from distutils.errors import (
from .errors import (
CompileError,
LinkError,
UnknownFileError,
DistutilsPlatformError,
DistutilsModuleError,
)
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 .spawn import spawn
from .file_util import move_file
from .dir_util import mkpath
from .dep_util import newer_group
from .util import split_quoted, execute
from . import log


class CCompiler:
Expand Down
6 changes: 3 additions & 3 deletions distutils/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import sys
import os
import re
from distutils.errors import DistutilsOptionError
from distutils import util, dir_util, file_util, archive_util, dep_util
from distutils import log

from .errors import DistutilsOptionError
from . import util, dir_util, file_util, archive_util, dep_util, log


class Command:
Expand Down
8 changes: 4 additions & 4 deletions distutils/command/bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import os
import warnings

from distutils.core import Command
from distutils.errors import DistutilsPlatformError, DistutilsOptionError
from distutils.util import get_platform
from ..core import Command
from ..errors import DistutilsPlatformError, DistutilsOptionError
from ..util import get_platform


def show_formats():
"""Print list of available formats (arguments to "--format" option)."""
from distutils.fancy_getopt import FancyGetopt
from ..fancy_getopt import FancyGetopt

formats = []
for format in bdist.format_commands:
Expand Down
10 changes: 5 additions & 5 deletions distutils/command/bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
$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 DistutilsPlatformError
from distutils.sysconfig import get_python_version
from ..core import Command
from ..util import get_platform
from ..dir_util import remove_tree, ensure_relative
from ..errors import DistutilsPlatformError
from ..sysconfig import get_python_version
from distutils import log


Expand Down
10 changes: 5 additions & 5 deletions distutils/command/bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import sys
import os

from distutils.core import Command
from distutils.debug import DEBUG
from distutils.file_util import write_file
from distutils.errors import (
from ..core import Command
from ..debug import DEBUG
from ..file_util import write_file
from ..errors import (
DistutilsOptionError,
DistutilsPlatformError,
DistutilsFileError,
DistutilsExecError,
)
from distutils.sysconfig import get_python_version
from ..sysconfig import get_python_version
from distutils import log


Expand Down
8 changes: 4 additions & 4 deletions distutils/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

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


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

show_compilers()

Expand Down
10 changes: 5 additions & 5 deletions distutils/command/build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# cut 'n paste. Sigh.

import os
from distutils.core import Command
from distutils.errors import DistutilsSetupError
from distutils.sysconfig import customize_compiler
from ..core import Command
from ..errors import DistutilsSetupError
from ..sysconfig import customize_compiler
from distutils import log


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

show_compilers()

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

# Yech -- this is cut 'n pasted from build_ext.py!
from distutils.ccompiler import new_compiler
from ..ccompiler import new_compiler

self.compiler = new_compiler(
compiler=self.compiler, dry_run=self.dry_run, force=self.force
Expand Down
24 changes: 12 additions & 12 deletions distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
import os
import re
import sys
from distutils.core import Command
from distutils.errors import (
from ..core import Command
from ..errors import (
DistutilsOptionError,
DistutilsSetupError,
CCompilerError,
DistutilsError,
CompileError,
DistutilsPlatformError,
)
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 ..sysconfig import customize_compiler, get_python_version
from ..sysconfig import get_config_h_filename
from ..dep_util import newer_group
from ..extension import Extension
from ..util import get_platform
from distutils import log
from . import py37compat

Expand All @@ -33,7 +33,7 @@


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

show_compilers()

Expand Down Expand Up @@ -280,7 +280,7 @@ def finalize_options(self): # noqa: C901
raise DistutilsOptionError("parallel should be an integer")

def run(self): # noqa: C901
from distutils.ccompiler import new_compiler
from ..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 @@ -704,7 +704,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 ..sysconfig import get_config_var

ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')
Expand Down Expand Up @@ -742,7 +742,7 @@ def get_libraries(self, ext): # noqa: C901
# 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 .._msvccompiler import MSVCCompiler

if not isinstance(self.compiler, MSVCCompiler):
template = "python%d%d"
Expand All @@ -764,7 +764,7 @@ def get_libraries(self, ext): # noqa: C901
# 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 ..sysconfig import get_config_var

link_libpython = False
if get_config_var('Py_ENABLE_SHARED'):
Expand Down
8 changes: 4 additions & 4 deletions distutils/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import sys
import glob

from distutils.core import Command
from distutils.errors import DistutilsOptionError, DistutilsFileError
from distutils.util import convert_path
from ..core import Command
from ..errors import DistutilsOptionError, DistutilsFileError
from ..util import convert_path
from distutils import log


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

from distutils.util import byte_compile
from ..util import byte_compile

prefix = self.build_lib
if prefix[-1] != os.sep:
Expand Down
6 changes: 3 additions & 3 deletions distutils/command/build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import 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
from ..core import Command
from ..dep_util import newer
from ..util import convert_path
from distutils import log
import tokenize

Expand Down
4 changes: 2 additions & 2 deletions distutils/command/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"""
import contextlib

from distutils.core import Command
from distutils.errors import DistutilsSetupError
from ..core import Command
from ..errors import DistutilsSetupError

with contextlib.suppress(ImportError):
import docutils.utils
Expand Down
4 changes: 2 additions & 2 deletions distutils/command/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# 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 ..core import Command
from ..dir_util import remove_tree
from distutils import log


Expand Down
16 changes: 8 additions & 8 deletions distutils/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import os
import re

from distutils.core import Command
from distutils.errors import DistutilsExecError
from distutils.sysconfig import customize_compiler
from ..core import Command
from ..errors import DistutilsExecError
from ..sysconfig import customize_compiler
from distutils import log

LANG_EXT = {"c": ".c", "c++": ".cxx"}
Expand Down Expand Up @@ -87,7 +87,7 @@ def _check_compiler(self):
"""
# We do this late, and only on-demand, because this is an expensive
# import.
from distutils.ccompiler import CCompiler, new_compiler
from ..ccompiler import CCompiler, new_compiler

if not isinstance(self.compiler, CCompiler):
self.compiler = new_compiler(
Expand Down Expand Up @@ -174,7 +174,7 @@ def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
preprocessor succeeded, false if there were any errors.
('body' probably isn't of much use, but what the heck.)
"""
from distutils.ccompiler import CompileError
from ..ccompiler import CompileError

self._check_compiler()
ok = True
Expand Down Expand Up @@ -217,7 +217,7 @@ def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
"""Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
"""
from distutils.ccompiler import CompileError
from ..ccompiler import CompileError

self._check_compiler()
try:
Expand All @@ -243,7 +243,7 @@ def try_link(
'headers', to executable form. Return true on success, false
otherwise.
"""
from distutils.ccompiler import CompileError, LinkError
from ..ccompiler import CompileError, LinkError

self._check_compiler()
try:
Expand All @@ -269,7 +269,7 @@ def try_run(
built from 'body' and 'headers'. Return true on success, false
otherwise.
"""
from distutils.ccompiler import CompileError, LinkError
from ..ccompiler import CompileError, LinkError

self._check_compiler()
try:
Expand Down

0 comments on commit 74090e3

Please sign in to comment.