Esempio n. 1
0
 def _refresh_frozen(self):
     output = self._run_pip("freeze", fatal=False)
     versions = {}
     if output:
         for line in output.split("\n"):
             name, version = system.despecced(line)
             versions[name] = version
     if versions:
         runez.save_json(versions, self.frozen_path)
     return versions
Esempio n. 2
0
    def resolved(self, package_name, default=None):
        """
        :param str package_name: Name of pypi package
        :param default: Optional default value (takes precendence over system.SETTINGS.defaults only)
        :return: Corresponding implementation to use
        """
        pypi_name, _ = system.despecced(package_name)
        name = self.resolved_name(pypi_name, default=default)
        name, version = system.despecced(name)
        if not name:
            runez.abort("No %s type configured for %s", self.key, pypi_name)

        implementation = self.get(name)
        if not implementation:
            runez.abort("Unknown %s type '%s'", self.key, name)

        imp = implementation(package_name)
        imp.implementation_version = version
        return imp
Esempio n. 3
0
    def _refresh_frozen(self):
        result = self._run_builtin_module("pip",
                                          "freeze",
                                          "--all",
                                          fatal=False)
        self._frozen = {}
        if result.output:
            for line in result.output.split("\n"):
                name, version = system.despecced(line)
                self._frozen[name] = version

        if self._frozen:
            runez.save_json(self._frozen, self.frozen_path)
Esempio n. 4
0
    def _run_from_venv(self, package_name, *args, **kwargs):
        """
        Should be called while holding the soft file lock in context only

        :param str package_name: Pypi package to which command being ran belongs to
        :param args: Args to invoke program with
        :param kwargs: Additional args, use program= if entry point differs from 'package_name'
        """
        if package_name == "pip":
            return self._run_pip(*args, **kwargs)
        args = runez.flattened(args, split=runez.SHELL)
        program = kwargs.pop("program", package_name)
        program, version = system.despecced(program)
        full_path = self._installed_module(program, version=version)
        return runez.run(full_path, *args, **kwargs)
Esempio n. 5
0
    def __init__(self, name):
        """
        :param str name: Name of pypi package
        """
        self.name, self.version = system.despecced(name)
        self._entry_points = None
        self.current = VersionMeta(self.name, "current")
        self.latest = VersionMeta(self.name,
                                  system.LATEST_CHANNEL,
                                  base=self.current)
        self.desired = VersionMeta(self.name, base=self.current)

        self.current.load(fatal=False)
        if not self.current.valid:
            self.current.invalidate("is not installed")

        self.dist_folder = system.SETTINGS.meta.full_path(self.name, ".tmp")
        self.build_folder = os.path.join(self.dist_folder, "build")
        self.relocatable = False
        self.source_folder = None
        self.packaged = [
        ]  # Paths to what was packaged (populated by self.effective_package())
        self.executables = [
        ]  # Paths to delivered exes (populated by perform_delivery())