Unverified Commit ed2e3b9d authored by Tim Dettmers's avatar Tim Dettmers Committed by GitHub
Browse files

Merge pull request #36 from tomaarsen/hotfix/os_error_name_too_long

Fixes `OSError: File name too long` when environment variable is too long
parents 76699b4a 7d771d1d
import errno
from pathlib import Path from pathlib import Path
from typing import Set, Union from typing import Set, Union
from warnings import warn from warnings import warn
...@@ -12,17 +13,23 @@ def extract_candidate_paths(paths_list_candidate: str) -> Set[Path]: ...@@ -12,17 +13,23 @@ def extract_candidate_paths(paths_list_candidate: str) -> Set[Path]:
def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]: def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]:
non_existent_directories: Set[Path] = { existent_directories: Set[Path] = set()
path for path in candidate_paths if not path.exists() for path in candidate_paths:
} try:
if path.exists():
existent_directories.add(path)
except OSError as exc:
if exc.errno != errno.ENAMETOOLONG:
raise exc
non_existent_directories: Set[Path] = candidate_paths - existent_directories
if non_existent_directories: if non_existent_directories:
warn( warn(
"WARNING: The following directories listed in your path were found to " "WARNING: The following directories listed in your path were found to "
f"be non-existent: {non_existent_directories}" f"be non-existent: {non_existent_directories}"
) )
return candidate_paths - non_existent_directories return existent_directories
def get_cuda_runtime_lib_paths(candidate_paths: Set[Path]) -> Set[Path]: def get_cuda_runtime_lib_paths(candidate_paths: Set[Path]) -> Set[Path]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment