mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update compileall from 3.13.5 (#5914)
This commit is contained in:
23
Lib/compileall.py
vendored
23
Lib/compileall.py
vendored
@@ -97,9 +97,15 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
|
||||
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
|
||||
success = True
|
||||
if workers != 1 and ProcessPoolExecutor is not None:
|
||||
import multiprocessing
|
||||
if multiprocessing.get_start_method() == 'fork':
|
||||
mp_context = multiprocessing.get_context('forkserver')
|
||||
else:
|
||||
mp_context = None
|
||||
# If workers == 0, let ProcessPoolExecutor choose
|
||||
workers = workers or None
|
||||
with ProcessPoolExecutor(max_workers=workers) as executor:
|
||||
with ProcessPoolExecutor(max_workers=workers,
|
||||
mp_context=mp_context) as executor:
|
||||
results = executor.map(partial(compile_file,
|
||||
ddir=ddir, force=force,
|
||||
rx=rx, quiet=quiet,
|
||||
@@ -110,7 +116,8 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
|
||||
prependdir=prependdir,
|
||||
limit_sl_dest=limit_sl_dest,
|
||||
hardlink_dupes=hardlink_dupes),
|
||||
files)
|
||||
files,
|
||||
chunksize=4)
|
||||
success = min(results, default=True)
|
||||
else:
|
||||
for file in files:
|
||||
@@ -166,13 +173,13 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
|
||||
if stripdir is not None:
|
||||
fullname_parts = fullname.split(os.path.sep)
|
||||
stripdir_parts = stripdir.split(os.path.sep)
|
||||
ddir_parts = list(fullname_parts)
|
||||
|
||||
for spart, opart in zip(stripdir_parts, fullname_parts):
|
||||
if spart == opart:
|
||||
ddir_parts.remove(spart)
|
||||
|
||||
dfile = os.path.join(*ddir_parts)
|
||||
if stripdir_parts != fullname_parts[:len(stripdir_parts)]:
|
||||
if quiet < 2:
|
||||
print("The stripdir path {!r} is not a valid prefix for "
|
||||
"source path {!r}; ignoring".format(stripdir, fullname))
|
||||
else:
|
||||
dfile = os.path.join(*fullname_parts[len(stripdir_parts):])
|
||||
|
||||
if prependdir is not None:
|
||||
if dfile is None:
|
||||
|
||||
24
Lib/test/support/__init__.py
vendored
24
Lib/test/support/__init__.py
vendored
@@ -2601,6 +2601,30 @@ skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == '
|
||||
'skipped on s390x')
|
||||
HAVE_ASAN_FORK_BUG = check_sanitizer(address=True)
|
||||
|
||||
# From Cpython 3.13.5
|
||||
@contextlib.contextmanager
|
||||
def no_color():
|
||||
import _colorize
|
||||
from .os_helper import EnvironmentVarGuard
|
||||
|
||||
with (
|
||||
swap_attr(_colorize, "can_colorize", lambda file=None: False),
|
||||
EnvironmentVarGuard() as env,
|
||||
):
|
||||
env.unset("FORCE_COLOR", "NO_COLOR", "PYTHON_COLORS")
|
||||
env.set("NO_COLOR", "1")
|
||||
yield
|
||||
|
||||
# From Cpython 3.13.5
|
||||
def force_not_colorized(func):
|
||||
"""Force the terminal not to be colorized."""
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
with no_color():
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
# From python 3.12.8
|
||||
class BrokenIter:
|
||||
def __init__(self, init_raises=False, next_raises=False, iter_raises=False):
|
||||
|
||||
30
Lib/test/support/os_helper.py
vendored
30
Lib/test/support/os_helper.py
vendored
@@ -10,6 +10,9 @@ import time
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
# From CPython 3.13.5
|
||||
from test import support
|
||||
|
||||
|
||||
# Filename used for testing
|
||||
TESTFN_ASCII = '@test'
|
||||
@@ -196,6 +199,26 @@ def skip_unless_symlink(test):
|
||||
return test if ok else unittest.skip(msg)(test)
|
||||
|
||||
|
||||
# From CPython 3.13.5
|
||||
_can_hardlink = None
|
||||
|
||||
# From CPython 3.13.5
|
||||
def can_hardlink():
|
||||
global _can_hardlink
|
||||
if _can_hardlink is None:
|
||||
# Android blocks hard links using SELinux
|
||||
# (https://stackoverflow.com/q/32365690).
|
||||
_can_hardlink = hasattr(os, "link") and not support.is_android
|
||||
return _can_hardlink
|
||||
|
||||
|
||||
# From CPython 3.13.5
|
||||
def skip_unless_hardlink(test):
|
||||
ok = can_hardlink()
|
||||
msg = "requires hardlink support"
|
||||
return test if ok else unittest.skip(msg)(test)
|
||||
|
||||
|
||||
_can_xattr = None
|
||||
|
||||
|
||||
@@ -699,8 +722,11 @@ class EnvironmentVarGuard(collections.abc.MutableMapping):
|
||||
def set(self, envvar, value):
|
||||
self[envvar] = value
|
||||
|
||||
def unset(self, envvar):
|
||||
del self[envvar]
|
||||
# From CPython 3.13.5
|
||||
def unset(self, envvar, /, *envvars):
|
||||
"""Unset one or more environment variables."""
|
||||
for ev in (envvar, *envvars):
|
||||
del self[ev]
|
||||
|
||||
def copy(self):
|
||||
# We do what os.environ.copy() does.
|
||||
|
||||
1177
Lib/test/test_compileall.py
vendored
Normal file
1177
Lib/test/test_compileall.py
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user