def test_en_requirements_6(self): upgrade_req = get_upgrade_str('cython', '0.9.8.1.1num0001') update_req = get_upgrade_str('cython', '0.9.8.1.1num0001', upgrade=False) self.assertEqual(upgrade_req, "cython>=0.10") self.assertEqual(update_req, "cython>0.9.8.1.1num0001, <0.10")
def test_en_requirements_4(self): upgrade_req = get_upgrade_str('zope.proxy', '3.4.2num0001') update_req = get_upgrade_str('zope.proxy', '3.4.2num0001', upgrade=False) self.assertEqual(upgrade_req, "zope.proxy>=4") self.assertEqual(update_req, "zope.proxy>3.4.2num0001, <4")
def test_en_requirements_5(self): upgrade_req = get_upgrade_str('wxpython', '2.8.7.1num0001') update_req = get_upgrade_str('wxpython', '2.8.7.1num0001', upgrade=False) self.assertEqual(upgrade_req, "wxpython>=2.9") self.assertEqual(update_req, "wxpython>2.8.7.1num0001, <2.9")
def test_en_requirements_2(self): upgrade_req = get_upgrade_str('pytz', '2008cnum0001') update_req = get_upgrade_str('pytz', '2008cnum0001', upgrade=False) self.assertEqual(upgrade_req, "pytz>=2009") self.assertEqual(update_req, "pytz>2008cnum0001, <2009")
def test_en_requirements_3(self): upgrade_req = get_upgrade_str('docutils', '0.5num0001') update_req = get_upgrade_str('docutils', '0.5num0001', upgrade=False) self.assertEqual(upgrade_req, "docutils>=1") self.assertEqual(update_req, "docutils>0.5num0001, <1")
def test_en_requirements_1(self): upgrade_req = get_upgrade_str('pywin32', '210num0001') update_req = get_upgrade_str('pywin32', '210num0001', upgrade=False) self.assertEqual(upgrade_req, "pywin32>=211") self.assertEqual(update_req, "pywin32>210num0001, <211")
def test_requirements_7(self): upgrade_req = get_upgrade_str('pycdf', '0.6_3b') update_req = get_upgrade_str('pycdf', '0.6_3b', upgrade=False) self.assertEqual(upgrade_req, "pycdf>=1") self.assertEqual(update_req, "pycdf>0.6_3b, <1")
def test_requirements_1(self): upgrade_req = get_upgrade_str('pywin32', '210') update_req = get_upgrade_str('pywin32', '210', upgrade=False) self.assertEqual(upgrade_req, "pywin32>210") self.assertEqual(update_req, "pywin32==210")
def upgrade_project(keys, local_repos=None, remote_repos=None, interactive=True, dry_run=False, term_width=0, verbose=False): """ Upgrade a project, if possible. """ # Before we do anything, save the current working state of the # environment to a rollback point. # TODO: If the upgrade fails, we need to rollback to this save point. save_state(verbose=verbose) if local_repos == None: local_repos = get_local_repos() local = RepositoryUnion(get_local_repos()) requirements = [] # If no explicit project(s) were specified to upgrade, try to upgrade # all of the local projects installed. if len(keys) == 0: for project in local.projects: pkg = local.projects[project].active_package if pkg: keys.append(project) for key in keys: # All of the keys in the local.projects dictionary are lowercase, so # convert all of the user-specified keys to lowercase. key = key.lower() # If the user specified a project which isn't installed, just skip it. try: active_local_projects = [project for project in local.projects[key].projects if project.active] except KeyError: print("Skipping %s because it is not installed on your system." % key) continue if active_local_projects: pkg = active_local_projects[0].active_package # Retrieve an upgrade string based on the package name/version. req_str = get_upgrade_str(key, pkg.version) # Create a requirement object from our requirement string. requirement = Requirement.parse(req_str) else: max_pkg = None for pkg in local.projects[key].packages: if max_pkg is None or pkg > max_pkg: max_pkg = pkg if max_pkg is not None: req_str = get_upgrade_str(key, max_pkg.version) requirement = Requirement.parse(req_str) else: requirement = Requirement.parse(project) requirements.append(requirement) # Try to install all of the generated requirements. install_requirement(requirements, local_repos=local_repos, remote_repos=remote_repos, interactive=interactive, dry_run=dry_run, term_width=term_width) # After we have finished the upgrade, we save the new state. # TODO: If the upgrade failed, we should instead revert to the # previous state. save_state(verbose=verbose)
def update_project(projects, local_repos=None, remote_repos=None, interactive=True, dry_run=False, term_width=0, verbose=False): """\ Update a project, if possible. """ # Before we do anything, save the current working state of the environment # to a rollback point. # TODO: If the upgrade fails, we need to rollback to this save point. save_state(verbose=verbose) # Ensure we know what our local repository consists of. if local_repos == None: local_repos = get_local_repos() local = RepositoryUnion(local_repos) # If no explicit project(s) were specified to update, add all locally # installed projects to those we'll try to update. if len(projects) == 0: for project in sorted(local.projects): pkg = local.projects[project].active_package if pkg: projects.append(project) # Otherwise, since all of the name in the local.projects dictionary # are lowercase, we might as well make them all that way for consistency # sake. else: projects = [name.lower() for name in projects] # Determine the requirement specification needed for each project. requirements = [] for name in projects: # If the user specified a project which isn't installed, just skip it. try: active_local_projects = [project for project in local.projects[name].projects if project.active] except KeyError: if verbose: print ("Skipping %s because it is not installed on your " "system.") % name continue # If we have a current version active, then we use it's version to # to determine what a valid update would be. if active_local_projects: pkg = active_local_projects[0].active_package req_str = get_upgrade_str(name, pkg.version, upgrade=False) requirement = Requirement.parse(req_str) # Otherwise, we try to build an upgrade requirement from the largest # version number of all inactive versions. else: max_pkg = None for pkg in local.projects[name].packages: if max_pkg is None or pkg > max_pkg: max_pkg = pkg if max_pkg is not None: req_str = get_upgrade_str(name, max_pkg.version, upgrade=False) requirement = Requirement.parse(req_str) else: requirement = Requirement.parse(project) requirements.append(requirement) if not requirements: return if verbose: print 'Generated requirements for updates:' for r in requirements: print '\t%s' % r # Try to install all of the generated requirements. # FIXME: This takes WAY to long. install_requirement(requirements, local_repos=local_repos, remote_repos=remote_repos, interactive=interactive, dry_run=dry_run, term_width=term_width, verbose=verbose) # After we have finished the update, we save the new state. # TODO: If the update failed, we should instead revert to the # previous state. save_state(verbose=verbose)