File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ def create_from_pep_508(
330330 """
331331 from poetry .core .packages .url_dependency import URLDependency
332332 from poetry .core .packages .utils .link import Link
333+ from poetry .core .packages .utils .utils import cached_is_dir
333334 from poetry .core .packages .utils .utils import is_archive_file
334335 from poetry .core .packages .utils .utils import is_python_project
335336 from poetry .core .packages .utils .utils import is_url
@@ -361,7 +362,7 @@ def create_from_pep_508(
361362 else :
362363 path_str = os .path .normpath (os .path .abspath (name )) # noqa: PTH100
363364 p , extras = strip_extras (path_str )
364- if p . is_dir ( ) and (os .path .sep in name or name .startswith ("." )):
365+ if cached_is_dir ( p ) and (os .path .sep in name or name .startswith ("." )):
365366 if not is_python_project (Path (name )):
366367 raise ValueError (
367368 f"Directory { name !r} is not installable. Not a Python project."
Original file line number Diff line number Diff line change @@ -117,10 +117,16 @@ def strip_extras(path: str) -> tuple[Path, str | None]:
117117 return Path (path_no_extras ), extras
118118
119119
120+ @functools .lru_cache (maxsize = None )
121+ def cached_is_dir (path : Path ) -> bool :
122+ """A cached version of `Path.is_dir`."""
123+ return path .is_dir ()
124+
125+
120126@functools .lru_cache (maxsize = None )
121127def is_python_project (path : Path ) -> bool :
122128 """Return true if the directory is a Python project"""
123- if not path . is_dir ( ):
129+ if not cached_is_dir ( path ):
124130 return False
125131
126132 setup_py = path / "setup.py"
You can’t perform that action at this time.
0 commit comments