def install_deps(self, args): deps = [] for mod in self.manager.find_mods(): try: deps += mod.info.dependencies except AttributeError: pass deps_to_install = [] deps_ok = True for dep in deps: depreq = parse_requirement(dep) if depreq.name == 'base': continue # ignore it since it's not like we can install it if depreq.name.startswith('?'): continue # ignore optional dependency if depreq.name.startswith('(?)'): continue # ignore optional dependency if depreq.name.startswith('!'): continue # ignore incompatible dependency if self.manager.resolve_local_requirement( depreq, ignore_game_ver=args.ignore_game_ver): continue try: # FIXME: we only try the first release here release = next( self.manager.resolve_remote_requirement( depreq, ignore_game_ver=args.ignore_game_ver)) except ModNotFoundError: print("Dependency not found: %s" % depreq.name) deps_ok = False break if not release: print("Dependency can not be met: %s" % depreq) deps_ok = False break if (depreq.name, release) not in deps_to_install: print("Adding dependency: %s %s" % (depreq.name, release.version)) deps_to_install.append((depreq.name, release)) if not deps_ok: return if deps_to_install: print("Installing missing dependencies...") for name, release in deps_to_install: self.install(args, name, release) # we may have added new sub-dependencies self.install_deps(args)
def run(self, args): for req in args.requirements: name, spec = parse_requirement(req) try: name = self.manager.resolve_mod_name(name, remote=True) req = Requirement(name, spec) release = next( self.manager.resolve_remote_requirement( req, ignore_game_ver=True)) except ModNotFoundError as ex: print("Error: %s" % ex) continue except StopIteration: print("No match found for %s" % (req, )) continue file_name = release.file_name self.manager.validate_mod_file_name(file_name) file_path = os.path.join(args.dest, file_name) if os.path.exists(file_path) and not args.replace: print("File %s already exists. " "Use -R to replace it." % file_path) continue if not os.path.isdir(args.dest): os.makedirs(args.dest) print("Saving to: %s" % file_path) mod = self.manager.download_mod(release, file_path) if args.unpack: mod.unpack(replace=args.replace, keep=args.keep)
def run(self, args): to_install = [] for req in args.requirements: name, spec = parse_requirement(req) try: name = self.manager.resolve_mod_name(name, remote=True) req = Requirement(name, spec) releases = start_iter( self.manager.resolve_remote_requirement( req, ignore_game_ver=args.ignore_game_ver)) except StopIteration: releases = [] except ModNotFoundError as ex: print("Error: %s" % ex) continue if not args.held and req.name in self.config.hold: print("%s is held. " "Use -H to install it anyway." % (req.name)) continue local_mod = self.manager.get_mod(req.name) for release in releases: if local_mod: local_ver = local_mod.version release_ver = Version(release.version) if not args.reinstall and release_ver == local_ver: print("%s==%s is already installed. " "Use -R to reinstall it." % (local_mod.name, local_ver)) break elif not args.downgrade and release_ver < local_ver: print( "%s is already installed in a more recent version." " Use -D to downgrade it." % (local_mod.name)) break to_install.append((name, release)) break else: print("No match found for %s" % (req, )) continue for name, release in to_install: self.install(args, name, release) if not args.no_deps: self.install_deps(args)
def run(self, args): for req in args.requirements: name, spec = parse_requirement(req) name = self.manager.resolve_mod_name(name, remote=True) req = Requirement(name, spec) try: releases = self.manager.resolve_remote_requirement( req, ignore_game_ver=True ) except ModNotFoundError as ex: print("Error: %s" % ex) continue if not releases: print('No match found for %s' % (req,)) continue release = releases[0] file_name = release.file_name self.manager.validate_mod_file_name(file_name) file_path = os.path.join(args.dest, file_name) if os.path.exists(file_path) and not args.replace: print( 'File %s already exists. ' 'Use -R to replace it.' % file_path ) continue if not os.path.isdir(args.dest): os.makedirs(args.dest) print('Saving to: %s' % file_path) mod = self.manager.download_mod(release, file_path) if args.unpack: mod.unpack(replace=args.replace, keep=args.keep)
def run(self, args): # TODO: handle optional dependencies to_install = [] for req in args.requirements: name, spec = parse_requirement(req) name = self.manager.resolve_mod_name(name, remote=True) req = Requirement(name, spec) try: releases = self.manager.resolve_remote_requirement( req, ignore_game_ver=args.ignore_game_ver ) except ModNotFoundError as ex: print("Error: %s" % ex) continue if not args.held and req.name in self.config.hold: print('%s is held. ' 'Use -H to install it anyway.' % (req.name)) continue if not releases: print('No match found for %s' % (req,)) continue local_mod = self.manager.get_mod(req.name) for release in releases: if local_mod: local_ver = parse_version(local_mod.version) release_ver = parse_version(release.version) if not args.reinstall and release_ver == local_ver: print('%s==%s is already installed. ' 'Use -R to reinstall it.' % ( local_mod.name, local_ver)) break elif not args.downgrade and release_ver < local_ver: print( '%s is already installed in a more recent version.' ' Use -D to downgrade it.' % ( local_mod.name ) ) break if args.no_deps: deps = [] else: deps = release.info_json.dependencies deps_to_install = [] deps_ok = True for dep in deps: depreq = parse_requirement(dep) if depreq.name.startswith('?'): continue # ignore optional dependency if depreq.name == 'base': if self.config.game_version in depreq.specifier: continue else: print('%s is incompatible with game version %s' % ( depreq, self.config.game_version, )) deps_ok = False break if self.manager.resolve_local_requirement( depreq, ignore_game_ver=args.ignore_game_ver): continue try: rels = self.manager.resolve_remote_requirement( depreq, ignore_game_ver=args.ignore_game_ver ) except ModNotFoundError: print('Dependency not found: %s' % depreq.name) deps_ok = False break if not rels: print('Dependency can not be met: %s' % depreq) deps_ok = False break # FIXME: we only try the first release here deprel = rels[0] print('Adding dependency: %s %s' % ( depreq.name, deprel.version )) deps_to_install.append(deprel) if deps_ok: to_install += deps_to_install to_install.append(release) break for release in to_install: print('Installing: %s %s...' % ( release.info_json.name, release.version )) self.manager.install_mod(release, unpack=args.unpack)
def install_deps(self, args): deps = [] for mod in self.manager.find_mods(): try: deps += mod.info.dependencies self.log.debug("Dependencies needed for %s %s : %s" % (mod.name, mod.version, mod.info.dependencies)) except AttributeError: pass deps_to_install = [] deps_ok = True for dep in deps: depreq = parse_requirement(dep) if depreq.name == 'base': continue # ignore it since it's not like we can install it if depreq.name.startswith('?'): continue # ignore optional dependency if depreq.name.startswith('(?)'): continue # ignore optional dependency if depreq.name.startswith('!'): continue # ignore incompatible dependency print("Resolving needed dependency: %s" % dep) if self.manager.resolve_local_requirement( depreq, ignore_game_ver=args.ignore_game_ver): print("Dependency locally met : %s" % depreq.name) continue try: # FIXME: we only try the first release here releases = self.manager.resolve_remote_requirement( depreq, ignore_game_ver=args.ignore_game_ver) release = next(releases) except ModNotFoundError: print("Dependency not found: %s" % depreq.name) deps_ok = False break except StopIteration: print("Dependency release not found: %s" % depreq.name) print( "Make sure the %s mod is available on mods.factorio.com and compatible with your game version : %s" % (dep, self.config.game_version_major)) deps_ok = False break if not release: print("Dependency can not be met: %s" % depreq) deps_ok = False break if (depreq.name, release) not in deps_to_install: mod = self.manager.get_mod(depreq.name) spec = depreq.specifier if mod.version in spec: print("Dependency already installed : %s %s" % (mod.name, mod.version)) continue print("Installing dependency: %s version %s" % (depreq.name, release.version)) deps_to_install.append((depreq.name, release)) if not deps_ok: return if deps_to_install: print("Installing missing dependencies...") for name, release in deps_to_install: self.install(args, name, release) # we may have added new sub-dependencies self.install_deps(args)