summaryrefslogtreecommitdiff
path: root/tools/vendored.py
diff options
context:
space:
mode:
authorMaciej Pasternacki <52241383+maciejp-ro@users.noreply.github.com>2022-02-08 23:24:15 +0100
committerMaciej Pasternacki <maciejp@ro.co>2022-02-08 23:29:05 +0100
commit44b39e0df56b553aed045049ec30839fcb06cdd3 (patch)
treef3cdfebda490814fe24aece202aa1ea72a1e3a8a /tools/vendored.py
parentcbac6933012c963ddbf9d3da1358005b4dcf1d79 (diff)
downloadpython-setuptools-git-44b39e0df56b553aed045049ec30839fcb06cdd3.tar.gz
Restore more_itertools.more, make importing `concurrent.futures` lazy
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'tools/vendored.py')
-rw-r--r--tools/vendored.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/vendored.py b/tools/vendored.py
index 9428e752..ee978e5c 100644
--- a/tools/vendored.py
+++ b/tools/vendored.py
@@ -66,13 +66,17 @@ def rewrite_importlib_resources(pkg_files, new_root):
def rewrite_more_itertools(pkg_files: Path):
"""
- Rewrite more_itertools to remove unused more_itertools.more
+ Defer import of concurrent.futures. Workaround for #3090.
"""
- for more_file in pkg_files.glob("more.py*"):
- more_file.remove()
- for init_file in pkg_files.glob("__init__.py*"):
- text = "".join(ln for ln in init_file.lines() if "from .more " not in ln)
- init_file.write_text(text)
+ more_file = pkg_files.joinpath('more.py')
+ text = more_file.read_text()
+ text = re.sub(r'^.*concurrent.futures.*?\n', '', text, flags=re.MULTILINE)
+ text = re.sub(
+ 'ThreadPoolExecutor',
+ '__import__("concurrent.futures").futures.ThreadPoolExecutor',
+ text,
+ )
+ more_file.write_text(text)
def clean(vendor):