Skip to content

Commit

Permalink
Merge https://github.com/pypa/distutils into feature/distutils-8c160a…
Browse files Browse the repository at this point in the history
…9693
  • Loading branch information
jaraco committed Dec 29, 2021
2 parents 104f8b4 + 2def21c commit c06e115
Show file tree
Hide file tree
Showing 44 changed files with 76 additions and 85 deletions.
6 changes: 6 additions & 0 deletions setuptools/_distutils/cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,9 @@ def is_cygwincc(cc):
out_string = check_output(shlex.split(cc) + ['-dumpmachine'])
return out_string.strip().endswith(b'cygwin')


get_versions = None
"""
A stand-in for the previous get_versions() function to prevent failures
when monkeypatched. See pypa/setuptools#2969.
"""
6 changes: 5 additions & 1 deletion setuptools/_distutils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
# The class here is styled after PEP 282 so that it could later be
# replaced with a standard Python logging implementation.

import sys

DEBUG = 1
INFO = 2
WARN = 3
ERROR = 4
FATAL = 5

import sys

class Log:

Expand Down Expand Up @@ -54,6 +55,7 @@ def error(self, msg, *args):
def fatal(self, msg, *args):
self._log(FATAL, msg, args)


_global_log = Log()
log = _global_log.log
debug = _global_log.debug
Expand All @@ -62,12 +64,14 @@ def fatal(self, msg, *args):
error = _global_log.error
fatal = _global_log.fatal


def set_threshold(level):
# return the old threshold for use from tests
old = _global_log.threshold
_global_log.threshold = level
return old


def set_verbosity(v):
if v <= 0:
set_threshold(WARN)
Expand Down
44 changes: 5 additions & 39 deletions setuptools/_distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import re
import sys
import sysconfig

from .errors import DistutilsPlatformError

Expand Down Expand Up @@ -274,31 +275,15 @@ def get_config_h_filename():
inc_dir = os.path.join(_sys_home or project_base, "PC")
else:
inc_dir = _sys_home or project_base
return os.path.join(inc_dir, 'pyconfig.h')
else:
inc_dir = get_python_inc(plat_specific=1)
return sysconfig.get_config_h_filename()

return os.path.join(inc_dir, 'pyconfig.h')


# Allow this value to be patched by pkgsrc. Ref pypa/distutils#16.
_makefile_tmpl = 'config-{python_ver}{build_flags}{multiarch}'


def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build."""
if python_build:
return os.path.join(_sys_home or project_base, "Makefile")
lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
multiarch = (
'-%s' % sys.implementation._multiarch
if hasattr(sys.implementation, '_multiarch') else ''
)
config_file = _makefile_tmpl.format(
python_ver=get_python_version(),
build_flags=build_flags,
multiarch=multiarch,
)
return os.path.join(lib_dir, config_file, 'Makefile')
return sysconfig.get_makefile_filename()


def parse_config_h(fp, g=None):
Expand All @@ -308,26 +293,7 @@ def parse_config_h(fp, g=None):
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
if g is None:
g = {}
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
#
while True:
line = fp.readline()
if not line:
break
m = define_rx.match(line)
if m:
n, v = m.group(1, 2)
try: v = int(v)
except ValueError: pass
g[n] = v
else:
m = undef_rx.match(line)
if m:
g[m.group(1)] = 0
return g
return sysconfig.parse_config_h(fp, vars=g)


# Regexes needed for parsing Makefile (and similar syntaxes,
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test_tarfile_root_owner(self):
archive.close()

def test_suite():
return unittest.makeSuite(ArchiveUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ArchiveUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_skip_build(self):


def test_suite():
return unittest.makeSuite(BuildTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_simple_built(self):
self.assertEqual(contents, sorted(wanted))

def test_suite():
return unittest.makeSuite(BuildDumbTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildDumbTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_minimal(self):


def test_suite():
return unittest.makeSuite(BDistMSITestCase)
return unittest.TestLoader().loadTestsFromTestCase(BDistMSITestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_no_optimize_flag(self):
os.remove(os.path.join(pkg_dir, 'dist', 'foo-0.1-1.noarch.rpm'))

def test_suite():
return unittest.makeSuite(BuildRpmTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildRpmTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_bdist_wininst.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_get_exe_bytes(self):
self.assertGreater(len(exe_file), 10)

def test_suite():
return unittest.makeSuite(BuildWinInstTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildWinInstTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_finalize_options(self):
self.assertEqual(cmd.executable, os.path.normpath(sys.executable))

def test_suite():
return unittest.makeSuite(BuildTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_run(self):
self.assertIn('libfoo.a', os.listdir(build_temp))

def test_suite():
return unittest.makeSuite(BuildCLibTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildCLibTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions setuptools/_distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ def build_ext(self, *args, **kwargs):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(BuildExtTestCase))
suite.addTest(unittest.makeSuite(ParallelBuildExtTestCase))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(BuildExtTestCase))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ParallelBuildExtTestCase))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_dont_write_bytecode(self):


def test_suite():
return unittest.makeSuite(BuildPyTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildPyTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_version_int(self):
self.assertIn(name, built)

def test_suite():
return unittest.makeSuite(BuildScriptsTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildScriptsTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_check_all(self):
'restructuredtext': 1})

def test_suite():
return unittest.makeSuite(CheckTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CheckTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_simple_run(self):
cmd.run()

def test_suite():
return unittest.makeSuite(cleanTestCase)
return unittest.TestLoader().loadTestsFromTestCase(cleanTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_debug_print(self):
debug.DEBUG = False

def test_suite():
return unittest.makeSuite(CommandTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CommandTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_config_interpolation(self):


def test_suite():
return unittest.makeSuite(PyPIRCCommandTestCase)
return unittest.TestLoader().loadTestsFromTestCase(PyPIRCCommandTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_config_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_clean(self):
self.assertFalse(os.path.exists(f))

def test_suite():
return unittest.makeSuite(ConfigTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ConfigTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_debug_mode(self):
self.assertEqual(stdout.readlines()[0], wanted)

def test_suite():
return unittest.makeSuite(CoreTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CoreTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_get_msvcr(self):
self.assertRaises(ValueError, get_msvcr)

def test_suite():
return unittest.makeSuite(CygwinCCompilerTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CygwinCCompilerTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_dep_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_newer_group(self):


def test_suite():
return unittest.makeSuite(DepUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(DepUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_dir_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_copy_tree_exception_in_listdir(self):


def test_suite():
return unittest.makeSuite(DirUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(DirUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions setuptools/_distutils/tests/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ def test_read_metadata(self):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(DistributionTestCase))
suite.addTest(unittest.makeSuite(MetadataTestCase))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(DistributionTestCase))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(MetadataTestCase))
return suite

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_extension_init(self):
"Unknown Extension options: 'chic'")

def test_suite():
return unittest.makeSuite(ExtensionTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ExtensionTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_copy_file_hard_link_failure(self):


def test_suite():
return unittest.makeSuite(FileUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(FileUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions setuptools/_distutils/tests/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def test_symlink_loop(self):

def test_suite():
return unittest.TestSuite([
unittest.makeSuite(FileListTestCase),
unittest.makeSuite(FindAllTestCase),
unittest.TestLoader().loadTestsFromTestCase(FileListTestCase),
unittest.TestLoader().loadTestsFromTestCase(FindAllTestCase),
])


Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_debug_mode(self):


def test_suite():
return unittest.makeSuite(InstallTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_install_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_simple_run(self):
self.assertTrue(os.path.exists(os.path.join(inst, rone)))

def test_suite():
return unittest.makeSuite(InstallDataTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallDataTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_install_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_simple_run(self):
self.assertEqual(len(cmd.get_outputs()), 2)

def test_suite():
return unittest.makeSuite(InstallHeadersTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallHeadersTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_install_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_dont_write_bytecode(self):


def test_suite():
return unittest.makeSuite(InstallLibTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallLibTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_install_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def write_script(name, text):


def test_suite():
return unittest.makeSuite(InstallScriptsTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallScriptsTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion setuptools/_distutils/tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_non_ascii(self):
'Fαtal\t\\xc8rr\\u014dr')

def test_suite():
return unittest.makeSuite(TestLog)
return unittest.TestLoader().loadTestsFromTestCase(TestLog)

if __name__ == "__main__":
run_unittest(test_suite())
Loading

0 comments on commit c06e115

Please sign in to comment.