Exemple #1
0
    def _get_conda_pip_package_details(self, env_export, conda_path):
        dependencies = env_export.get("dependencies", [])

        # If there are pip dependencies, they'll be listed under a
        # {"pip": [...]} entry.
        pip_pkgs = set()
        for dep in dependencies:
            if isinstance(dep, dict) and "pip" in dep:
                # Pip packages are recorded in conda exports as "name (loc)",
                # "name==version" or "name (loc)==version".
                pip_pkgs = {p.split("=")[0].split(" ")[0] for p in dep["pip"]}
                break

        pip = conda_path + "/bin/pip"
        if not self._session.exists(pip):
            return {}, {}

        pkgs_editable = set(
            piputils.get_pip_packages(self._session,
                                      pip,
                                      restriction="editable"))
        pip_pkgs.update(pkgs_editable)

        if not pip_pkgs:
            return {}, {}

        packages, file_to_package_map = piputils.get_package_details(
            self._session, pip, pip_pkgs, editable_packages=pkgs_editable)
        for entry in packages.values():
            entry["installer"] = "pip"
        return packages, file_to_package_map
Exemple #2
0
 def _get_package_details(self, venv_path):
     pip = venv_path + "/bin/pip"
     try:
         packages, file_to_pkg = piputils.get_package_details(
             self._session, pip)
     except Exception as exc:
         lgr.warning("Could not determine pip package details for %s: %s",
                     venv_path, exc_str(exc))
         return {}, {}
     return packages, file_to_pkg
Exemple #3
0
    def _get_conda_pip_package_details(self, env_export, conda_path):
        dependencies = env_export.get("dependencies", [])

        # If there are pip dependencies, they'll be listed under a
        # {"pip": [...]} entry.
        pip_pkgs = []
        for dep in dependencies:
            if isinstance(dep, dict) and "pip" in dep:
                # Pip packages are recorded in conda exports as "name (loc)",
                # "name==version" or "name (loc)==version".
                pip_pkgs = [p.split("=")[0].split(" ")[0] for p in dep["pip"]]
                break

        if not pip_pkgs:
            return {}, {}

        pip = conda_path + "/bin/pip"
        packages, file_to_package_map = piputils.get_package_details(
            self._session, pip, pip_pkgs)
        for entry in packages.values():
            entry["installer"] = "pip"
        return packages, file_to_package_map