Commit 322472e4 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract staticmethod for resolving setup path

parent 997b4351
...@@ -79,15 +79,28 @@ class develop(namespaces.DevelopInstaller, easy_install): ...@@ -79,15 +79,28 @@ class develop(namespaces.DevelopInstaller, easy_install):
project_name=ei.egg_name project_name=ei.egg_name
) )
p = self.egg_base.replace(os.sep, '/') self.setup_path = self._resolve_setup_path(
if p != os.curdir: self.egg_base,
p = '../' * (p.count('/') + 1) self.install_dir,
self.setup_path = p self.egg_path,
p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) )
if p != normalize_path(os.curdir):
@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( raise DistutilsOptionError(
"Can't get a consistent path to setup script from" "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): def install_for_development(self):
if six.PY3 and getattr(self.distribution, 'use_2to3', False): if six.PY3 and getattr(self.distribution, 'use_2to3', False):
......
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