diff --git a/spacy/cli/_util.py b/spacy/cli/_util.py index 228bd21f6..12aec8267 100644 --- a/spacy/cli/_util.py +++ b/spacy/cli/_util.py @@ -1,3 +1,4 @@ +from tempfile import TemporaryDirectory from typing import Dict, Any, Union, List, Optional, Tuple, Iterable from typing import TYPE_CHECKING, overload import sys @@ -405,13 +406,14 @@ def git_checkout( f"temporarily. To only download the files needed, make sure " f"you're using Git v2.22 or above." ) - with make_tempdir() as tmp_dir: - cmd = f"git -C {tmp_dir} clone {repo} . -b {branch}" + with TemporaryDirectory() as tmp_dir: + tmp_path = Path(tmp_dir) + cmd = f"git -C {tmp_path} clone {repo} . -b {branch}" run_command(cmd, capture=True) # We need Path(name) to make sure we also support subdirectories try: - source_path = tmp_dir / Path(subpath) - if not is_subpath_of(tmp_dir, source_path): + source_path = tmp_path / Path(subpath) + if not is_subpath_of(tmp_path, source_path): err = f"'{subpath}' is a path outside of the cloned repository." msg.fail(err, repo, exits=1) if os.path.isdir(source_path):