diff --git a/src/requirementslib/requirements.py b/src/requirementslib/requirements.py index 59331d78..93f3b9c4 100644 --- a/src/requirementslib/requirements.py +++ b/src/requirementslib/requirements.py @@ -286,6 +286,7 @@ class FileRequirement(BaseRequirement): req = attrib() _has_hashed_name = False _uri_scheme = None + _setup_path = attrib(default=None) @uri.default def get_uri(self): @@ -299,11 +300,10 @@ def get_name(self): if loc: self._uri_scheme = "path" if self.path else "uri" name = None - setup_path = Path(self.path) / 'setup.py' - if self._uri_scheme != "uri" and self.path and setup_path.exists(): + if self._uri_scheme != "uri" and self.path and self.setup_path: from distutils.core import run_setup try: - dist = run_setup(setup_path.as_posix(), stop_after='init') + dist = run_setup(self.setup_path.as_posix(), stop_after='init') except FileNotFoundError: dist = None else: @@ -348,6 +348,16 @@ def is_remote_artifact(self): self.link.is_artifact or self.link.is_wheel ) and not self.req.editable + @property + def setup_path(self): + if not self._setup_path: + if not self.path: + return + setup_path = Path(self.path) / 'setup.py' + if setup_path.exists(): + self._setup_path = setup_path + return self._setup_path + @classmethod def from_line(cls, line): link = None