diff --git a/spacy/util.py b/spacy/util.py index 7f70a131a..4b0bdbae5 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -434,11 +434,24 @@ def get_package_path(name): return Path(pkg.__file__).parent -def run_command(command: List[str]) -> None: - """Run a command on the command line as a subprocess. +def split_command(command: str) -> List[str]: + """Split a string command using shlex. Handles platform compatibility. - command (list): The split command. + command (str) : The command to split + RETURNS (List[str]): The split command. """ + return shlex.split(command, posix=not is_windows) + + +def run_command(command: Union[str, List[str]]) -> None: + """Run a command on the command line as a subprocess. If the subprocess + returns a non-zero exit code, a system exit is performed. + + command (str / List[str]): The command. If provided as a string, the + string will be split using shlex.split. + """ + if isinstance(command, str): + command = split_command(command) status = subprocess.call(command, env=os.environ.copy()) if status != 0: sys.exit(status) @@ -928,10 +941,6 @@ def from_disk(path, readers, exclude): return path -def split_command(command): - return shlex.split(command, posix=not is_windows) - - def import_file(name, loc): """Import module from a file. Used to load models from a directory.