コード例 #1
0
ファイル: pipmanager.py プロジェクト: wel51x/fades
    def install(self, dependency):
        """Install a new dependency."""
        if not self.pip_installed:
            logger.info("Need to install a dependency with pip, but no builtin, "
                        "doing it manually (just wait a little, all should go well)")
            self._brute_force_install_pip()

        # split to pass several tokens on multiword dependency (this is very specific for '-e' on
        # external requirements, but implemented generically; note that this does not apply for
        # normal reqs, because even if it originally is 'foo > 1.2', after parsing it loses the
        # internal spaces)
        str_dep = str(dependency)
        args = [self.pip_exe, "install"] + str_dep.split()

        if self.options:
            for option in self.options:
                args.extend(option.split())
        logger.info("Installing dependency: %r", str_dep)
        try:
            helpers.logged_exec(args)
        except helpers.ExecutionError as error:
            error.dump_to_log(logger)
            raise error
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            raise error
コード例 #2
0
ファイル: pipmanager.py プロジェクト: xavierxross/fades
    def install(self, dependency):
        """Install a new dependency."""
        if not self.pip_installed:
            logger.info("Need to install a dependency with pip, but no builtin, "
                        "doing it manually (just wait a little, all should go well)")
            self._brute_force_install_pip()

        # Always update pip to get latest behaviours (specially regarding security); this has
        # the nice side effect of getting logged the pip version that is used.
        if not self.avoid_pip_upgrade:
            python_exe = os.path.join(self.env_bin_path, "python")
            helpers.logged_exec([python_exe, '-m', 'pip', 'install', 'pip', '--upgrade'])

        # split to pass several tokens on multiword dependency (this is very specific for '-e' on
        # external requirements, but implemented generically; note that this does not apply for
        # normal reqs, because even if it originally is 'foo > 1.2', after parsing it loses the
        # internal spaces)
        str_dep = str(dependency)
        args = [self.pip_exe, "install"] + str_dep.split()

        if self.options:
            for option in self.options:
                args.extend(option.split())
        logger.info("Installing dependency: %r", str_dep)
        try:
            helpers.logged_exec(args)
        except helpers.ExecutionError as error:
            error.dump_to_log(logger)
            raise error
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            raise error
コード例 #3
0
    def install(self, dependency):
        """Install a new dependency."""
        if not self.said_hi:
            logger.info(
                "Hi! This is fades %s, automatically managing your dependencies",
                __version__)
            self.said_hi = True

        if not self.pip_installed:
            logger.info(
                "Need to install a dependency with pip, but no builtin, "
                "doing it manually (just wait a little, all should go well)")
            self._brute_force_install_pip()

        str_dep = str(dependency)
        args = [self.pip_exe, "install", str_dep]
        if self.options:
            for option in self.options:
                args.extend(option.split())
        logger.info("Installing dependency: %s", str_dep)
        try:
            helpers.logged_exec(args)
        except helpers.ExecutionError as error:
            error.dump_to_log(logger)
            raise error
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            raise error
コード例 #4
0
ファイル: pipmanager.py プロジェクト: wel51x/fades
    def _brute_force_install_pip(self):
        """A brute force install of pip itself."""
        if os.path.exists(self.pip_installer_fname):
            logger.debug("Using pip installer from %r", self.pip_installer_fname)
        else:
            logger.debug(
                "Installer for pip not found in %r, downloading it", self.pip_installer_fname)
            self._download_pip_installer()

        logger.debug("Installing PIP manually in the virtualenv")
        python_exe = os.path.join(self.env_bin_path, "python")
        helpers.logged_exec([python_exe, self.pip_installer_fname, '-I'])
        self.pip_installed = True
コード例 #5
0
ファイル: pipmanager.py プロジェクト: gamba47/fades
    def _brute_force_install_pip(self):
        """A brute force install of pip itself."""
        if os.path.exists(self.pip_installer_fname):
            logger.debug("Using pip installer from %r", self.pip_installer_fname)
        else:
            logger.debug(
                "Installer for pip not found in %r, downloading it", self.pip_installer_fname)
            u = request.urlopen(PIP_INSTALLER)
            with open(self.pip_installer_fname, 'wb') as fh:
                fh.write(u.read())

        logger.debug("Installing PIP manually in the virtualenv")
        python_exe = os.path.join(self.env_bin_path, "python")
        helpers.logged_exec([python_exe, self.pip_installer_fname])
コード例 #6
0
ファイル: pipmanager.py プロジェクト: gamba47/fades
    def install(self, dependency):
        """Install a new dependency."""
        if not self.pip_installed:
            logger.info("Need to install a dependency with pip, but no builtin, do it manually")
            self._brute_force_install_pip()

        str_dep = str(dependency)
        args = [self.pip_exe, "install", str_dep]
        logger.info("Installing dependency: %s", str_dep)
        try:
            helpers.logged_exec(args)
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            exit()
コード例 #7
0
    def _brute_force_install_pip(self):
        """A brute force install of pip itself."""
        if os.path.exists(self.pip_installer_fname):
            logger.debug("Using pip installer from %r", self.pip_installer_fname)
        else:
            logger.debug(
                "Installer for pip not found in %r, downloading it", self.pip_installer_fname)
            u = request.urlopen(PIP_INSTALLER)
            with open(self.pip_installer_fname, 'wb') as fh:
                fh.write(u.read())

        logger.debug("Installing PIP manually in the virtualenv")
        python_exe = os.path.join(self.env_bin_path, "python")
        helpers.logged_exec([python_exe, self.pip_installer_fname])
コード例 #8
0
ファイル: pipmanager.py プロジェクト: jmansilla/fades
    def install(self, dependency):
        """Install a new dependency."""
        if not self.pip_installed:
            logger.info("Need to install a dependency with pip, but no builtin, "
                        "doing it manually (just wait a little, all should go well)")
            self._brute_force_install_pip()

        str_dep = str(dependency)
        args = [self.pip_exe, "install", str_dep]
        logger.info("Installing dependency: %s", str_dep)
        try:
            helpers.logged_exec(args)
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            exit()
コード例 #9
0
ファイル: envbuilder.py プロジェクト: luciotorre/fades
 def create_with_virtualenv(self, interpreter):
     """Create a virtualenv using the virtualenv lib."""
     if virtualenv is None:
         logger.error('Virtualenv is not installed. It is needed to create a virtualenv with '
                      'a different python version than fades')
         exit()
     args = ['virtualenv', '--python', interpreter, self.env_path]
     if not self.with_pip:
         args.insert(3, '--no-pip')
     try:
         helpers.logged_exec(args)
         self.env_bin_path = os.path.join(self.env_path, 'bin')
     except Exception as error:
         logger.exception("Error creating virtualenv:  %s", error)
         exit()
コード例 #10
0
ファイル: envbuilder.py プロジェクト: edvm/fades
 def create_with_virtualenv(self, interpreter, virtualenv_options):
     """Create a virtualenv using the virtualenv lib."""
     args = ['virtualenv', '--python', interpreter, self.env_path]
     args.extend(virtualenv_options)
     if not self.pip_installed:
         args.insert(3, '--no-pip')
     try:
         helpers.logged_exec(args)
         self.env_bin_path = os.path.join(self.env_path, 'bin')
     except FileNotFoundError as error:
         logger.error('Virtualenv is not installed. It is needed to create a virtualenv with '
                      'a different python version than fades (got {})'.format(error))
         exit()
     except Exception as error:
         logger.exception("Error creating virtualenv:  %s", error)
         exit()
コード例 #11
0
ファイル: pipmanager.py プロジェクト: edvm/fades
    def install(self, dependency):
        """Install a new dependency."""
        if not self.pip_installed:
            logger.info("Need to install a dependency with pip, but no builtin, "
                        "doing it manually (just wait a little, all should go well)")
            self._brute_force_install_pip()

        str_dep = str(dependency)
        args = [self.pip_exe, "install", str_dep]
        if self.options:
            for option in self.options:
                args.extend(option.split())
        logger.info("Installing dependency: %s", str_dep)
        try:
            helpers.logged_exec(args)
        except Exception as error:
            logger.exception("Error installing %s: %s", str_dep, error)
            exit()
コード例 #12
0
 def create_with_virtualenv(self, interpreter, virtualenv_options):
     """Create a virtualenv using the virtualenv lib."""
     args = ['virtualenv', '--python', interpreter, self.env_path]
     args.extend(virtualenv_options)
     if not self.pip_installed:
         args.insert(3, '--no-pip')
     try:
         helpers.logged_exec(args)
         self.env_bin_path = os.path.join(self.env_path, 'bin')
     except FileNotFoundError as error:
         logger.error(
             'Virtualenv is not installed. It is needed to create a virtualenv with '
             'a different python version than fades (got {})'.format(error))
         raise FadesError('virtualenv not found')
     except helpers.ExecutionError as error:
         error.dump_to_log(logger)
         raise FadesError('virtualenv could not be run')
     except Exception as error:
         logger.exception("Error creating virtualenv:  %s", error)
         raise FadesError('General error while running virtualenv')
コード例 #13
0
ファイル: pipmanager.py プロジェクト: jmansilla/fades
 def get_version(self, dependency):
     """Returns the installed version parsing the output of 'pip show'."""
     logger.debug("getting installed version for %s", dependency)
     stdout = helpers.logged_exec([self.pip_exe, "show", dependency])
     version = [line for line in stdout if line.startswith('Version:')]
     if len(version) == 1:
         version = version[0].strip().split()[1]
         logger.debug("Installed version of %s is: %s", dependency, version)
         return version
     else:
         logger.error('Fades is having problems getting the installed version. '
                      'Run with -v or check the logs for details')
         return ''
コード例 #14
0
ファイル: pipmanager.py プロジェクト: dlitvakb/fades
 def get_version(self, dependency):
     """Return the installed version parsing the output of 'pip show'."""
     logger.debug("getting installed version for %s", dependency)
     stdout = helpers.logged_exec([self.pip_exe, "show", dependency])
     version = [line for line in stdout if line.startswith('Version:')]
     if len(version) == 1:
         version = version[0].strip().split()[1]
         logger.debug("Installed version of %s is: %s", dependency, version)
         return version
     else:
         logger.error('Fades is having problems getting the installed version. '
                      'Run with -v or check the logs for details')
         return ''
コード例 #15
0
ファイル: pipmanager.py プロジェクト: xavierxross/fades
 def freeze(self, filepath):
     """Dump venv contents to the indicated filepath."""
     logger.debug("running freeze to store in %r", filepath)
     stdout = helpers.logged_exec([self.pip_exe, "freeze", "--all", "--local"])
     with open(filepath, "wt", encoding='utf8') as fh:
         fh.writelines(line + '\n' for line in sorted(stdout))