diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-24 10:13:24 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-24 10:13:24 -0500 |
commit | 322472e4ffdc03901be1f584a548b00f1372037d (patch) | |
tree | 8c461328bb8c6b58d6d2351dd791a91d3474159b /setuptools/command/develop.py | |
parent | 997b4351f8459622c203eb1b274fee7a73980ce6 (diff) | |
download | external_python_setuptools-322472e4ffdc03901be1f584a548b00f1372037d.tar.gz external_python_setuptools-322472e4ffdc03901be1f584a548b00f1372037d.tar.bz2 external_python_setuptools-322472e4ffdc03901be1f584a548b00f1372037d.zip |
Extract staticmethod for resolving setup path
Diffstat (limited to 'setuptools/command/develop.py')
-rwxr-xr-x | setuptools/command/develop.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 1489de9e..97708ba3 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -79,15 +79,28 @@ class develop(namespaces.DevelopInstaller, easy_install): project_name=ei.egg_name ) - p = self.egg_base.replace(os.sep, '/') - if p != os.curdir: - p = '../' * (p.count('/') + 1) - self.setup_path = p - p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) - if p != normalize_path(os.curdir): + self.setup_path = self._resolve_setup_path( + self.egg_base, + self.install_dir, + self.egg_path, + ) + + @staticmethod + def _resolve_setup_path(egg_base, install_dir, egg_path): + """ + Generate a path from egg_base back to '.' where the + setup script resides and ensure that path points to the + setup path from $install_dir/$egg_path. + """ + path_to_setup = egg_base.replace(os.sep, '/') + if path_to_setup != os.curdir: + path_to_setup = '../' * (path_to_setup.count('/') + 1) + resolved = normalize_path(os.path.join(install_dir, egg_path, path_to_setup)) + if resolved != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" - " installation directory", p, normalize_path(os.curdir)) + " installation directory", resolved, normalize_path(os.curdir)) + return path_to_setup def install_for_development(self): if six.PY3 and getattr(self.distribution, 'use_2to3', False): |