How to use the pipupgrade._pip function in pipupgrade

To help you get started, we’ve selected a few pipupgrade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achillesrasquinha / pipupgrade / tests / pipupgrade / test__pip.py View on Github external
else:
                    assert not rout
            else:
                assert rout == output

        _assert_outerr(rout, output)
        _assert_outerr(rerr, err)

    directory = tmpdir.mkdir("tmp")
    tempfile  = directory.join("tmp.log")
    path      = str(tempfile)

    _pip.call("install", "pipupgrade")
    assert_pip_call(_pip.call("install", "pipupgrade", quiet = True))
    
    _pip.call("install", "pipupgrade", log = path)
    assert tempfile.read()
github achillesrasquinha / pipupgrade / tests / pipupgrade / test__pip.py View on Github external
if isinstance(output, bool):
                if output:
                    assert rout
                else:
                    assert not rout
            else:
                assert rout == output

        _assert_outerr(rout, output)
        _assert_outerr(rerr, err)

    directory = tmpdir.mkdir("tmp")
    tempfile  = directory.join("tmp.log")
    path      = str(tempfile)

    _pip.call("install", "pipupgrade")
    assert_pip_call(_pip.call("install", "pipupgrade", quiet = True))
    
    _pip.call("install", "pipupgrade", log = path)
    assert tempfile.read()
github achillesrasquinha / pipupgrade / src / pipupgrade / model / package.py View on Github external
def _get_pip_info(*args, **kwargs):
	packages	= args
	pip_exec	= kwargs.get("pip_exec", None)
	
	_, out, _	= _pip.call("show", *packages, pip_exec = pip_exec,
		output = True)
	results		= [strip(o) for o in out.split("---")]
	
	info		= dict()
	
	for i, package in enumerate(packages):
		result = results[i]

		detail = dict((kebab_case(k), v) \
			for k, v in \
				iteritems(
					dict([(s + [""]) if len(s) == 1 else s \
						for s in [re.split(r":\s?", o, maxsplit = 1) \
							for o in result.split("\n")]]
					)
				)
github achillesrasquinha / pipupgrade / src / pipupgrade / helper.py View on Github external
def get_registry_from_pip(pip_path, sync = False, verbose = False):
    _, output, _ = _pip.call("list", outdated = True, \
        format = "json", pip_exec = pip_path)
    packages     = json.loads(output)
    registry     = Registry(source = pip_path, packages = packages, installed = True, sync = sync)
    
    logger.info("Packages within `pip` %s found: %s..." % (pip_path, registry.packages))
    # _pip.get_installed_distributions() # https://github.com/achillesrasquinha/pipupgrade/issues/13

    return registry
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
if update:
						cli.echo(cli_format(
							"Updating %s of %s %s: %s" % (
								i + 1,
								npackages,
								spackages,
								cli_format(package.name, cli.GREEN)
							)
						, cli.BOLD), file = file)

						if not package.installed:
							_update_requirements(package.source, package)
						else:
							try:
								_pip.call("install", package.name,
									pip_exec = package.source, user = user,
									quiet = not verbose, no_cache_dir = True,
									upgrade = True
								)
							except PopenError as e:
								if raise_err:
									raise
	else:
		cli.echo("%s upto date." % cli_format(stitle, cli.CYAN),
			file = file)
github achillesrasquinha / pipupgrade / src / pipupgrade / config.py View on Github external
def environment():
    environ = dict()
    
    environ["version"]          = __version__
    environ["python_version"]   = platform.python_version()
    environ["os"]               = platform.platform()
    environ["config"]           = dict(
        path = dict(PATH)
    )
    environ["pip_executables"]  = [dict(
        executable = executable,
        version    = _pip.call("--version", pip_exec = executable,
            output = True)[1]
    ) for executable in _pip._PIP_EXECUTABLES]

    from pipupgrade import settings
    environ["settings"]         = settings.to_dict()

    return environ
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / __init__.py View on Github external
if not verbose:
		logger.setLevel(log.NOTSET)
		
	logger.info("Environment: %s" % environment())
	logger.info("Arguments Passed: %s" % locals())

	file_ = output

	if file_:
		logger.info("Writing to output file %s..." % file_)
		touch(file_)

	cli.echo(cli_format("Checking...", cli.YELLOW), file = file_)

	pip_path    = pip_path or [ ]
	pip_path    = [which(p) for p in pip_path] or _pip._PIP_EXECUTABLES

	logger.info("`pip` executables found: %s" % pip_path)
	
	logger.info("Using %s jobs..." % jobs)

	registries  = [ ]

	if pip:
		logger.info("Updating pip executables: %s" % " ".join(pip_path))

		with parallel.no_daemon_pool(processes = jobs) as pool:
			pool.imap_unordered(
				partial(
					update_pip, **{ "user": user, "quiet": not verbose,
						"file": file_ }
				),
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
def pip_upgrade(package, pip_exec = None, user = None, quiet = None):
	return _pip.call("install", package, pip_exec = pip_exec, 
		user = user, quiet = quiet, no_cache_dir = True, upgrade = True)
github achillesrasquinha / pipupgrade / src / pipupgrade / config.py View on Github external
def environment():
    environ = dict()
    
    environ["version"]          = __version__
    environ["python_version"]   = platform.python_version()
    environ["os"]               = platform.platform()
    environ["config"]           = dict(
        path = dict(PATH)
    )
    environ["pip_executables"]  = [dict(
        executable = executable,
        version    = _pip.call("--version", pip_exec = executable,
            output = True)[1]
    ) for executable in _pip._PIP_EXECUTABLES]

    from pipupgrade import settings
    environ["settings"]         = settings.to_dict()

    return environ
github achillesrasquinha / pipupgrade / src / pipupgrade / model / package.py View on Github external
def __init__(self, package, sync = False, pip_exec = None):
		logger.info("Initializing Package %s of type %s..." % (package, type(package)))

		self.current_version 	= None

		if   isinstance(package, (_pip.Distribution, _pip.DistInfoDistribution,
			_pip.EggInfoDistribution)):
			self.name            = package.project_name
			self.current_version = package.version
		elif isinstance(package, _pip.InstallRequirement):
			self.name            = package.name

			if hasattr(package, "req"):
				if hasattr(package.req, "specifier"):
					self.current_version = str(package.req.specifier)
			else:
				self.current_version = package.installed_version
		elif isinstance(package, dict):
			self.name            = package["name"]
			self.current_version = package["version"]
			self.latest_version  = package.get("latest_version")
		elif isinstance(package, str):
			self.name			 = package