summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Dettmers <TimDettmers@users.noreply.github.com>2022-10-09 16:47:11 -0700
committerGitHub <noreply@github.com>2022-10-09 16:47:11 -0700
commited2e3b9db4039272af9e3ef13f73f92f811c8a81 (patch)
tree265cccb27760035f4fb3ff25a25c421499c9d056
parent76699b4a8d8dd55ab7da8bcf68a849c723a0c0ab (diff)
parent7d771d1d6d4c3df83c1b82d4d5df2b4dc95c1759 (diff)
Merge pull request #36 from tomaarsen/hotfix/os_error_name_too_long
Fixes `OSError: File name too long` when environment variable is too long
-rw-r--r--bitsandbytes/cuda_setup/paths.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/bitsandbytes/cuda_setup/paths.py b/bitsandbytes/cuda_setup/paths.py
index 6f6425f..ba3f97f 100644
--- a/bitsandbytes/cuda_setup/paths.py
+++ b/bitsandbytes/cuda_setup/paths.py
@@ -1,3 +1,4 @@
+import errno
from pathlib import Path
from typing import Set, Union
from warnings import warn
@@ -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]:
- non_existent_directories: Set[Path] = {
- path for path in candidate_paths if not path.exists()
- }
-
+ existent_directories: Set[Path] = set()
+ 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:
warn(
"WARNING: The following directories listed in your path were found to "
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]: