def _install_wagon(self, source, prefix): pip_freeze_output = self._pip_freeze() file_descriptor, constraint_path = tempfile.mkstemp( prefix='constraint-', suffix='.txt') os.close(file_descriptor) try: with open(constraint_path, 'wb') as constraint: constraint.write(pip_freeze_output) # Install the provided wagon. # * The --prefix install_arg will cause the plugin to be installed under # plugins_dir/{package_name}-{package_version}, So different plugins don't step on # each other and don't interfere with the current virtualenv # * The --constraint flag points a file containing the output of ``pip freeze``. # It is required, to handle cases where plugins depend on some python package with # a different version than the one installed in the current virtualenv. Without this # flag, the existing package will be **removed** from the parent virtualenv and the # new package will be installed under prefix. With the flag, the existing version will # remain, and the version requested by the plugin will be ignored. wagon.install( source=source, install_args='--prefix="{prefix}" --constraint="{constraint}"'. format(prefix=prefix, constraint=constraint.name), virtualenv=os.environ.get('VIRTUAL_ENV')) finally: os.remove(constraint_path)
def _wagon_install(plugin, venv, args): client = get_rest_client() wagon_dir = tempfile.mkdtemp(prefix='{0}-'.format(plugin.id)) wagon_path = os.path.join(wagon_dir, 'wagon.tar.gz') try: ctx.logger.debug('Downloading plugin %s from manager into %s', plugin.id, wagon_path) client.plugins.download(plugin_id=plugin.id, output_file=wagon_path) ctx.logger.debug('Installing plugin %s using wagon', plugin.id) wagon.install(wagon_path, ignore_platform=True, install_args=args, venv=venv) finally: ctx.logger.debug('Removing directory: %s', wagon_dir) shutil.rmtree(wagon_dir, ignore_errors=True)
def _wagon_install(self, plugin, args): client = get_rest_client() wagon_dir = tempfile.mkdtemp(prefix='{0}-'.format(plugin.id)) wagon_path = os.path.join(wagon_dir, 'wagon.tar.gz') try: self.logger.debug( 'Downloading plugin {0} from manager into {1}'.format( plugin.id, wagon_path)) client.plugins.download(plugin_id=plugin.id, output_file=wagon_path) self.logger.debug('Installing plugin {0} using wagon'.format( plugin.id)) wagon.install(wagon_path, ignore_platform=True, install_args=args, venv=VIRTUALENV) finally: self.logger.debug('Removing directory: {0}'.format(wagon_dir)) self._rmtree(wagon_dir)
def _wagon_install(self, plugin, args): client = get_rest_client() wagon_dir = tempfile.mkdtemp(prefix='{0}-'.format(plugin.id)) wagon_path = os.path.join(wagon_dir, 'wagon.tar.gz') try: self.logger.debug('Downloading plugin {0} from manager into {1}' .format(plugin.id, wagon_path)) client.plugins.download(plugin_id=plugin.id, output_file=wagon_path) self.logger.debug('Installing plugin {0} using wagon' .format(plugin.id)) wagon.install( wagon_path, ignore_platform=True, install_args=args, venv=VIRTUALENV ) finally: self.logger.debug('Removing directory: {0}' .format(wagon_dir)) self._rmtree(wagon_dir)