Optimize/revisit determine_setup
This commit is contained in:
parent
ed91d5f086
commit
ba457f5feb
|
@ -121,28 +121,34 @@ def determine_setup(inifile, args, rootdir_cmd_arg=None, config=None):
|
||||||
break
|
break
|
||||||
except KeyError:
|
except KeyError:
|
||||||
inicfg = None
|
inicfg = None
|
||||||
rootdir = get_common_ancestor(dirs)
|
if rootdir_cmd_arg is None:
|
||||||
|
rootdir = get_common_ancestor(dirs)
|
||||||
else:
|
else:
|
||||||
ancestor = get_common_ancestor(dirs)
|
ancestor = get_common_ancestor(dirs)
|
||||||
rootdir, inifile, inicfg = getcfg([ancestor], config=config)
|
rootdir, inifile, inicfg = getcfg([ancestor], config=config)
|
||||||
if rootdir is None:
|
if rootdir is None and rootdir_cmd_arg is None:
|
||||||
for rootdir in ancestor.parts(reverse=True):
|
for possible_rootdir in ancestor.parts(reverse=True):
|
||||||
if rootdir.join("setup.py").exists():
|
if possible_rootdir.join("setup.py").exists():
|
||||||
|
rootdir = possible_rootdir
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
rootdir, inifile, inicfg = getcfg(dirs, config=config)
|
if dirs != [ancestor]:
|
||||||
|
rootdir, inifile, inicfg = getcfg(dirs, config=config)
|
||||||
if rootdir is None:
|
if rootdir is None:
|
||||||
rootdir = get_common_ancestor([py.path.local(), ancestor])
|
if config is not None:
|
||||||
|
cwd = config.invocation_dir
|
||||||
|
else:
|
||||||
|
cwd = py.path.local()
|
||||||
|
rootdir = get_common_ancestor([cwd, ancestor])
|
||||||
is_fs_root = os.path.splitdrive(str(rootdir))[1] == "/"
|
is_fs_root = os.path.splitdrive(str(rootdir))[1] == "/"
|
||||||
if is_fs_root:
|
if is_fs_root:
|
||||||
rootdir = ancestor
|
rootdir = ancestor
|
||||||
if rootdir_cmd_arg:
|
if rootdir_cmd_arg:
|
||||||
rootdir_abs_path = py.path.local(os.path.expandvars(rootdir_cmd_arg))
|
rootdir = py.path.local(os.path.expandvars(rootdir_cmd_arg))
|
||||||
if not os.path.isdir(str(rootdir_abs_path)):
|
if not rootdir.isdir():
|
||||||
raise UsageError(
|
raise UsageError(
|
||||||
"Directory '{}' not found. Check your '--rootdir' option.".format(
|
"Directory '{}' not found. Check your '--rootdir' option.".format(
|
||||||
rootdir_abs_path
|
rootdir
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
rootdir = rootdir_abs_path
|
|
||||||
return rootdir, inifile, inicfg or {}
|
return rootdir, inifile, inicfg or {}
|
||||||
|
|
Loading…
Reference in New Issue