def run(self): deps = self.get_finalized_command('dependencies') build = self.get_finalized_command('build') level_list = [deps.sublevel, build.sublevel, self.sublevel] ## detect malformed usage if len(set([l for l in level_list if l])) > 1: raise Exception("Multiple sublevels specified.") self.sublevel = build.sublevel = deps.sublevel = max(*level_list) ## before anything else (runs in case build hasn't run) if self.sublevel == 0 and not deps.ran: self.run_command('dependencies') options.set_top_level(self.sublevel) if self.distribution.subpackages != None: try: os.makedirs(build.build_base) except OSError: pass idx = 0 for i in range(len(sys.argv)): idx = i if 'setup.py' in sys.argv[idx]: break argv = list(sys.argv[idx+1:]) for arg in sys.argv: if arg == 'build' or \ arg == 'clean' or \ '--sublevel' in arg: argv.remove(arg) argv += ['--sublevel=' + str(self.sublevel + 1)] process_subpackages(build.distribution.parallel_build, 'install', build.build_base, self.distribution.subpackages, argv, build.distribution.quit_on_error) if build.has_pure_modules() or build.has_c_libraries() or \ build.has_ext_modules() or build.has_shared_libraries() or \ build.has_pypp_extensions() or \ build.has_web_extensions() or \ build.has_documents() or build.has_executables() or \ build.has_scripts() or build.has_data(): old_install.run(self) else: old_install.run(self) self.ran = True
def run(self): deps = self.get_finalized_command('dependencies') install = self.get_finalized_command('install') level_list = [deps.sublevel, self.sublevel, install.sublevel] ## detect malformed usage if len(set([l for l in level_list if l])) > 1: raise Exception("Multiple sublevels specified.") level = max(self.sublevel, install.sublevel, deps.sublevel) self.sublevel = install.sublevel = deps.sublevel = max(*level_list) ## before anything else if self.sublevel == 0 and not deps.ran: self.run_command('dependencies') options.set_top_level(self.sublevel) if self.distribution.subpackages != None: install = self.get_finalized_command('install') if install.ran: return ## avoid build after install for cmd in install.get_sub_commands(): if getattr(cmd, 'ran', False): return ## TODO avoid build after any install_* cmd try: os.makedirs(self.build_base) except OSError: pass idx = 0 for i in range(len(sys.argv)): idx = i if 'setup.py' in sys.argv[idx]: break argv = list(sys.argv[idx+1:]) for arg in sys.argv: if arg == 'clean' or '--sublevel' in arg: argv.remove(arg) argv += ['--sublevel=' + str(self.sublevel + 1)] process_subpackages(self.distribution.parallel_build, 'build', self.build_base, self.distribution.subpackages, argv, self.distribution.quit_on_error) old_build.run(self) self.ran = True
def run(self): save_cache(self.distribution.environment) build = self.get_finalized_command("build") install = self.get_finalized_command("install") level_list = [self.sublevel, build.sublevel, install.sublevel] ## detect malformed usage if len(set([l for l in level_list if l])) > 1: raise Exception("Multiple sublevels specified.") self.sublevel = build.sublevel = install.sublevel = max(*level_list) dep_graph = get_dep_dag(os.getcwd()) ## assumes cwd is setup dir if self.show: print dep_graph sys.exit(0) prereq_graph = get_dep_dag(os.getcwd(), True) ts = dep_graph.topological_sort()[:-1] pre_ts = prereq_graph.topological_sort()[:-1] if self.distribution.subpackages != None: for pkg_name, _ in self.distribution.subpackages: for dep in dep_graph.adjacency_list().keys(): if pkg_name == dep or (isinstance(dep, tuple) and pkg_name == dep[0]): ts.remove(dep) pre_ts.remove(dep) self.requirements += ts ## differentiate between python and other prereqs non_py_reqs = [] sys_cfg_dir = os.path.dirname(configure.__file__) usr_cfg_dir = options.user_config_dir non_py_configs = glob.glob(os.path.join(sys_cfg_dir, "*.py")) + glob.glob(os.path.join(usr_cfg_dir, "*.py")) non_py_configs = [os.path.basename(cfg) for cfg in non_py_configs] for cfg in list(non_py_configs): if "_py.py" in cfg: non_py_configs.remove(cfg) for dep in self.requirements: if isinstance(dep, tuple): dep = dep[0] for cfg in non_py_configs: if cfg.startswith(dep): non_py_reqs.append(dep) break py_reqs = [] for dep in pre_ts: if isinstance(dep, tuple): dep = dep[0] seen = False for cfg in non_py_configs: if cfg.startswith(dep): seen = True break if not seen: try: __import__(dep) except ImportError: py_reqs.append(dep) self.distribution.extra_install_modules += py_reqs env_old = self.distribution.environment options.set_top_level(self.sublevel) env = configure.configure_system( self.requirements, self.distribution.version, install=(not self.download), locally=(not self.system_install), download=self.download, ) self.distribution.environment = dict(list(env_old.items()) + list(env.items())) self.ran = True
def configure_system( prerequisite_list, version, required_python_version="2.4", install=None, quiet=False, sublevel=None, out=sys.stdout, err=sys.stderr, locally=None, download=None, options=dict(), ): """ Given a list of required software and optionally a Python version, verify that python is the proper version and that other required software is installed. Install missing prerequisites that have an installer defined. """ if locally is None: ## parameter value overrides if "locally" in options.keys(): locally = options["locally"] else: locally = True ## default value if install is None: ## parameter value overrides if "install" in options.keys(): install = options["install"] else: install = True ## default value if download is None: ## parameter value overrides if "download" in options.keys(): download = options["download"] else: download = False ## default value if sublevel is None: ## parameter value overrides if "sublevel" in options.keys(): opts.set_top_level(options["sublevel"]) environment = dict() try: environment = read_cache() skip = False for arg in sys.argv: if arg.startswith("clean"): skip = True quiet = True pyver = simplify_version(platform.python_version()) reqver = simplify_version(required_python_version) if pyver < reqver: raise FatalError("Python version >= " + reqver + " is required. " + "You are running version " + pyver) if not quiet: out.write("CONFIGURE ") if len(environment): out.write("(from cache)") out.write("\n") environment["PACKAGE_VERSION"] = version prerequisite_list.insert(0, "httpsproxy_urllib2") if ( "windows" in platform.system().lower() and in_prerequisites("mingw", prerequisite_list) and in_prerequisites("boost", prerequisite_list) and not in_prerequisites("msvcrt", prerequisite_list) ): err.write("WARNING: if you're using the boost-python DLL, " + "also add 'msvcrt' as a prerequisite.\n") if ( "darwin" in platform.system().lower() and not in_prerequisites("macports", prerequisite_list) and not in_prerequisites("homebrew", prerequisite_list) ): if system_uses_macports(): prerequisite_list.insert(0, "macports") elif system_uses_homebrew(): prerequisite_list.insert(0, "homebrew") else: err.write( "WARNING: neither MacPorts nor Homebrew " + "detected. All required libraries will be " + "built locally.\n" ) for help_name in prerequisite_list: if len(help_name) > 0: environment = find_package_config( help_name, __run_helper__, environment, skip, install, quiet, out, err, locally, download ) save_cache(environment) except Exception: # pylint: disable=W0703 logfile = os.path.join(opts.target_build_dir, "config.log") if not os.path.exists(opts.target_build_dir): mkdir(opts.target_build_dir) log = open(logfile, "a") log.write("** Configuration error. **\n" + traceback.format_exc()) log.close() err.write( "Configuration error; see " + logfile + " for details.\n" + "If the build fails, run 'python setup.py dependencies " + "--show'\nand install the listed packages by hand.\n" ) raise return environment