def _install_requirements(plugin_path): requirement_file = os.path.join(plugin_path, "plugin_requirements.txt") if os.path.isfile(requirement_file): LOG.info( "Installing requirements from: {}".format(requirement_file)) pip_args = ['install', '-r', requirement_file] pip_main(args=pip_args)
def run(self): import shutil import tempfile import subprocess tmpd = tempfile.mkdtemp() try: subprocess.call(["git", "clone", trezorlib_git, "."], cwd=tmpd) subprocess.call(["git", "checkout", trezorlib_commit], cwd=tmpd) subprocess.call(["git", "submodule", "init"], cwd=tmpd) subprocess.call(["git", "submodule", "update", "--recursive"], cwd=tmpd) # Not nice, but due to virtualenv we dont know which pip is being used try: from pip._internal import main as pip_main pip_main(["install", "-U", tmpd]) except Exception as e: logger.warning('Programatical pip installation failed: %s' % e) pip_path = os.getenv('PIP_PATH', None) pip = os.path.join(pip_path, 'pip') if pip_path else 'pip' subprocess.call([pip, "install", "-U", tmpd]) except Exception as e: msg = 'Error installing "trezor" package. Try the manual way: ' \ 'git clone %s /tmp/trezorlib && cd /tmp/trezorlib && git checkout %s && ' \ 'git submodule init && git submodule update --recursive && ' \ 'cd - && pip install -U /tmp/trezorlib' % (trezorlib_git, trezorlib_commit) raise DistutilsError(msg) from e finally: shutil.rmtree(tmpd)
def _install_package(args): try: import pip from pip._internal import main as pip_main pip_main(args) except: _install_pip()
def download(dest_directory, requirements_file_path, *extra_args): with _add_pip_import_paths_to_pythonpath(): pip_main(args=[ "wheel", "-w", dest_directory, "-r", requirements_file_path, ] + list(extra_args))
def install(package): if hasattr(pip, 'main'): pip.main(['install', package]) else: from pip._internal import main as pip_main if hasattr(pip_main, 'main'): pip_main.main(['install', package]) else: pip_main(['install', package])
def pip_install(module_or_requirements, is_requirements=False): try: if is_requirements: pip_main(['install', '--no-cache-dir', '-r', module_or_requirements]) else: pip_main(['install', '--no-cache-dir', module_or_requirements]) except SystemExit as se: log.error("Error when trying to install python modules %s.", module_or_requirements) log.exception(se)
def install(package): import pip as p # TODO: Fix this ugly work around to mitigate PIP issue. if int(p.__version__.split('.')[0]) > 9: from pip._internal import main as pip_main pip_main(['install', package]) else: if hasattr(p, 'main'): p.main(['install', package])
def read_requirements(): # # parses requirements from requirements.txt reqs_path = os.path.join(__location__, 'requirements.txt') install_reqs = parse_requirements(reqs_path, session=PipSession()) reqs = [] for ir in install_reqs: pip_main(['install', str(ir.req or ir.link)]) if ir.req: reqs.append(str(ir.req)) return reqs
def main(): findlinks, download_dest, pkg, pkgname = sys.argv[1:] assert not pip_main(['wheel', pkg, '--wheel-dir', findlinks]) os.environ.pop('PIP_REQ_TRACKER', None) # not reentrant assert not pip_main([ 'download', '--dest', download_dest, '--find-links', 'file://{}'.format(findlinks), '--no-index', pkgname, ])
def main(): findlinks, download_dest, pkg, pkgname = sys.argv[1:] assert not pip_main(['wheel', pkg, '--wheel-dir', findlinks]) assert not pip_main([ 'download', '--dest', download_dest, '--find-links', 'file://{}'.format(findlinks), '--no-index', pkgname, ])
def pip_auto_install(_package): """ Automatically installs all requirements if pip is installed. """ try: from pip._internal import main as pip_main pip_main(['install', _package]) except ImportError: print("Failed to import pip. Please ensure that pip is installed.") print("For further instructions see " "https://pip.pypa.io/en/stable/installing/") #sys.exit(-1) except Exception as err: print("Failed to install pip requirements: " + err.message)
def install_and_import(package): try: importlib.import_module(package) except ImportError: from pip._internal import main as pip_main warnings.warn( 'package ' + package + ' is required through installation: trying to install it with pip') try: pip_main(['install', package]) except Exception: raise globals()[package] = importlib.import_module(package)
def ensure_bio2bel_installation(package: str): """Import a package, or install it.""" try: b_module = importlib.import_module(package) except ImportError: logger.info(f'{EMOJI} pip install {package}') # Install this package using pip # https://stackoverflow.com/questions/12332975/installing-python-module-within-code from pip._internal import main as pip_main with redirect_stdout(sys.stderr): pip_exit_code = pip_main(['install', '-q', package]) # -q means quiet if 0 != pip_exit_code: # command failed logger.warning( f'{EMOJI} could not find {package} on PyPI. Try installing from GitHub with:' ) name = package.split("_")[-1] logger.warning( f'\n pip install git+https://github.com/bio2bel/{name}.git\n' ) sys.exit(1) try: return importlib.import_module(package) except ImportError: logger.exception(f'{EMOJI} failed to import {package}') sys.exit(1) return b_module
def pip_install(package): """ Install the package using pip """ try: if hasattr(pip, 'main'): pip.main(['install', "--upgrade", package]) else: from pip._internal import main as pip_main pip_main(['install', "--upgrade", package]) return True except: info("Unable to install %s using pip." % package) info("Please read the instructions for manual installation.") info("Error: %s: %s" % (exc_info()[0], exc_info()[1])) return False
def pip_install(package): """ Install the package using pip """ try: if hasattr(pip, 'main'): pip.main(['install', "--upgrade", package]) else: from pip._internal import main as pip_main pip_main(['install', "--upgrade", package]) return True except: info("Unable to install %s using pip." % package) info("Please read the instructions for manual installation.") info("Error: %s: %s" % (exc_info()[0] ,exc_info()[1])) return False
def install(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=""" Install all requirements from specified file with pip. Optionally transform git+git and git+ssh url to private repo's to use a given Personal Access Token for github. That way installing them does not depend on a ssh-agent with suitable keys. Which you don't have when installing requirements in a Docker. These URLs will also be stripped of the -e flag, so they're installed globally. Note the -e flag is optional for the git+git//github.com and git+ssh://github.com urls. This means that the following URL: -e [email protected]:MyOrg/my-project.git@my-tag#egg=my_project would be transformed to: git+https://<token>:[email protected]/MyOrg/my-project.git@my-tag#egg=my_project Non-private GitHub URL's (git+https) and non-GitHub URL's are kept as-is, but are also stripped of the -e flag. If no token is given, private URLs will be kept, including the -e flag (otherwise they can't be installed at all). """) parser.add_argument('--token', '-t', help='Your Personal Access Token for private GitHub repositories', default=os.environ.get('GITHUB_TOKEN')) parser.add_argument('req_file', help='path to the requirements file to install') args = parser.parse_args() # TODO: rewrite to a clear collect and a clear transform phase. Or pass in a transform function pip_args = ['install'] + collect_requirements(args.req_file, transform_with_token=args.token) if pip_main(pip_args) != status_codes.SUCCESS: raise RuntimeError('Error installing requirements')
def _resolve_pip_dependencies(tmp_dir: str) -> int: pip_verbosity = [] if logging.is_debug_enabled() else ["--quiet"] pip_cmd = [ "install", "--requirement", os.path.join(tmp_dir, "requirements.txt"), "--target", tmp_dir ] + pip_verbosity return pip_main(pip_cmd)
def _import1(module, name=None, table=None): if name is None: name = module if table is None: table = globals() try: table[name] = importlib.import_module(module) except ImportError: try: pip_main(['install', module]) table[name] = importlib.import_module(module) except: print(f'Import failed: {module}')
def install_libs(sources, develop=False): print("installing all libs in {} mode".format( "development" if develop else "normal")) wd = os.getcwd() for k, v in sources.items(): try: os.chdir(os.path.join(wd, v)) if develop: pip_main(["install", "-v", "-e", "."]) else: pip_main(["install", "."]) except Exception as e: print("Oops, something went wrong installing", k) print(e) finally: os.chdir(wd)
def run(self): '''Run the build step.''' # Clean staging path shutil.rmtree(STAGING_PATH, ignore_errors=True) # Copy resource files shutil.copytree(HOOK_PATH, os.path.join(STAGING_PATH, 'hook')) # Copy resource files shutil.copytree(ADDON_PATH, os.path.join(STAGING_PATH, 'scripts')) pip_main([ 'install', '.', '--target', os.path.join(STAGING_PATH, 'dependencies'), '--process-dependency-links' ]) result_path = shutil.make_archive( os.path.join(BUILD_PATH, 'ftrack-connect-blender-{0}'.format(VERSION)), 'zip', STAGING_PATH)
def try_pip_install(exception=None): print(str(exception)) print("检测到你有python模块找不到,你可在搜索引擎搜索安装相关模块。") print( "或转到上一级目录,运行:pip3 install -r requiremes.txt 或 pip install -r requirements.txt" ) print("下面为你尝试自动安装requirement.txt") input("如需自动安装按回车键继续...(如不需要自动尝试安装可现在关闭程序)\n") try: from pip._internal import main as pip_main pip_main([ 'install', '-r', '../requirements.txt', '-i', 'https://mirrors.aliyun.com/pypi/simple/' ]) print("\n自动安装完成,请重新运行程序") input("按回车键退出程序......") exit(333) except Exception as e: print("\n", str(e)) print("尝试自动安装requirement.txt失败,请手动安装并反馈此报错信息") input("按回车键退出程序......") exit(333)
def create_dependency_layer(): """ Installs dependencies in a target directory and then packages it into a zip file that can be used by CDK to create Lambda dependency layer """ # file paths requirements_file_path = "requirements.txt" target_directory = "python" zip_file_path = "dependency-layer.zip" # change directory so that relative paths work cwd = os.getcwd() os.chdir("lambda") # create new dependency zip only if it doesn't exist if not os.path.isfile(zip_file_path): pip_main([ "install", "-r", requirements_file_path, "--target", target_directory, ]) # package dependencies as a zip file dep_zip = zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED) for root, dirs, files in os.walk(target_directory): for file in files: dep_zip.write(os.path.join(root, file)) dep_zip.close() # change directory back os.chdir(cwd)
def uninstall(params): """ Uninstall third-party Mod """ try: from pip._internal import main as pip_main from pip._internal.commands.uninstall import UninstallCommand except ImportError: # be compatible with pip < 10.0 from pip import main as pip_main from pip.commands.uninstall import UninstallCommand if hasattr(UninstallCommand, "name"): uninstall_command = UninstallCommand() else: uninstall_command = UninstallCommand(name='uninstall', summary='Uninstall packages.') pip_main = pip_main.main params = [param for param in params] options, mod_list = uninstall_command.parse_args(params) params = ["uninstall"] + params for mod_name in mod_list: mod_name_index = params.index(mod_name) if mod_name.startswith("rqalpha_mod_sys_"): six.print_('System Mod can not be installed or uninstalled') return if "rqalpha_mod_" in mod_name: lib_name = mod_name else: lib_name = "rqalpha_mod_" + mod_name params[mod_name_index] = lib_name # Uninstall Mod uninstalled_result = pip_main(params) # Remove Mod Config from rqalpha.utils.config import user_mod_conf_path, load_yaml user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}} for mod_name in mod_list: if "rqalpha_mod_" in mod_name: mod_name = mod_name.replace("rqalpha_mod_", "") del user_conf['mod'][mod_name] dump_config(user_mod_conf_path(), user_conf) return uninstalled_result
def __get_pip_module_version(module_name): """Return module version using Pip (not all modules have "__version__" attribute).""" global __module_version_cache if module_name not in __module_version_cache: f = StringIO() sys.stdout = f pip_main(['show', module_name]) sys.stdout = sys.__stdout__ module_version = None for line in f.getvalue().splitlines(): if line.startswith('Version'): module_version = line.split(':', 1)[1].strip() break if module_version is None: raise McGetPipModuleVersionException("Unable to determine '%s' module version" % module_name) __module_version_cache[module_name] = module_version return __module_version_cache[module_name]
def installdeps(file): # Load all pipelines for filename in file: print_info("Loading pipeline", filename) pipeline = PipelineInfo(file=filename) # Remove duplicates requires = set(pipeline.requires) missing = requires requires_str = ', '.join(missing) if not requires_str: print("No additional python packages are required.") return print_info("The following python packages are required:\n", requires_str) answer = None while answer not in ['Y', 'N']: answer = input("Install now? (Y/N)").upper() if answer == "N": return for package in missing: pip_main(['install', package])
def __get_pip_module_version(module_name): """Return module version using Pip (not all modules have "__version__" attribute).""" global __module_version_cache if module_name not in __module_version_cache: f = StringIO() sys.stdout = f pip_main(['show', module_name]) sys.stdout = sys.__stdout__ module_version = None for line in f.getvalue().splitlines(): if line.startswith('Version'): module_version = line.split(':', 1)[1].strip() break if module_version is None: raise McGetPipModuleVersionException( "Unable to determine '%s' module version" % module_name) __module_version_cache[module_name] = module_version return __module_version_cache[module_name]
def main(): if not check_version(): logger.error("Unsupported pip version: '{}'".format(pip.__version__)) logger.error("Use one of the supported versions: {}".format( ', '.join(SUPPORTED_PIP_VERSIONS))) if not ask_user("Do you really want to continue?"): sys.exit(1) if not os.environ.get('AURA_PATH'): logger.error( "You need to set AURA_PATH environment variable that points to the AURA framework executable" ) logger.debug("Monkey patching pip...") monkey_patch() sys.exit(pip_main())
def uninstall(params): """ Uninstall third-party Mod """ from pip import main as pip_main from pip.commands.uninstall import UninstallCommand params = [param for param in params] options, mod_list = UninstallCommand().parse_args(params) params = ["uninstall"] + params for mod_name in mod_list: mod_name_index = params.index(mod_name) if mod_name.startswith("rqalpha_mod_sys_"): six.print_('System Mod can not be installed or uninstalled') return if "rqalpha_mod_" in mod_name: lib_name = mod_name else: lib_name = "rqalpha_mod_" + mod_name params[mod_name_index] = lib_name # Uninstall Mod uninstalled_result = pip_main(params) # Remove Mod Config from rqalpha.utils.config import user_mod_conf_path, load_yaml user_conf = load_yaml(user_mod_conf_path()) if os.path.exists( user_mod_conf_path()) else { 'mod': {} } for mod_name in mod_list: if "rqalpha_mod_" in mod_name: mod_name = mod_name.replace("rqalpha_mod_", "") del user_conf['mod'][mod_name] dump_config(user_mod_conf_path(), user_conf) return uninstalled_result
def pip_search(packages, directory) -> str: # pip automatically send message to stdout by logging module, so we need to redirect it import sys if isinstance(packages, str): packages = [packages] packages.insert(0, "search") print("Searching in pip, please wait...") console = sys.stdout cache = open(os.path.join(directory, "pip_search_result.txt"), "w") sys.stdout = cache code = pip_main(packages) sys.stdout = console if code == 0: print("please check search_result.txt under %s" % directory) else: print("something wrong when running pip_search") return ""
def pip_run_command(pip_args): if not has_pip: print("===== WARNING =====") print("Cannot `import pip` - falling back to the pip executable.") print("This will be deprecated in a future release.") print("Please open an issue if this will be a problem: " "https://github.com/wolever/pip2pi/issues") print("===================") check_call(["pip"] + pip_args) return if pip_version < (1, 1): raise RuntimeError("pip >= 1.1 required, but %s is installed" %(pip_version, )) # TODO: Remove this once # pip._internal.req.req_tracker.RequirementTracker.cleanup() does it # already. os.environ.pop('PIP_REQ_TRACKER', None) res = pip_main(pip_args) if res != 0: raise PipError("pip failed with status %s while running: %s" %(res, pip_args))
def uninstall(params): """ Uninstall third-party Mod """ from pip import main as pip_main from pip.commands.uninstall import UninstallCommand params = [param for param in params] options, mod_list = UninstallCommand().parse_args(params) params = ["uninstall"] + params for mod_name in mod_list: mod_name_index = params.index(mod_name) if mod_name.startswith("rqalpha_mod_sys_"): six.print_('System Mod can not be installed or uninstalled') return if "rqalpha_mod_" in mod_name: lib_name = mod_name else: lib_name = "rqalpha_mod_" + mod_name params[mod_name_index] = lib_name # Uninstall Mod uninstalled_result = pip_main(params) # Remove Mod Config from rqalpha.utils.config import user_mod_conf_path, load_yaml user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}} for mod_name in mod_list: if "rqalpha_mod_" in mod_name: mod_name = mod_name.replace("rqalpha_mod_", "") del user_conf['mod'][mod_name] dump_config(user_mod_conf_path(), user_conf) return uninstalled_result
def pip_run_command(pip_args): if not has_pip: print("===== WARNING =====") print("Cannot `import pip` - falling back to the pip executable.") print("This will be deprecated in a future release.") print("Please open an issue if this will be a problem: " "https://github.com/wolever/pip2pi/issues") print("===================") check_call(["pip"] + pip_args) return if pip_version < (1, 1): raise RuntimeError("pip >= 1.1 required, but %s is installed" % (pip_version, )) # TODO: Remove this once # pip._internal.req.req_tracker.RequirementTracker.cleanup() does it # already. os.environ.pop('PIP_REQ_TRACKER', None) res = pip_main(pip_args) if res != 0: raise PipError("pip failed with status %s while running: %s" % (res, pip_args))
# we want to handle package names and also repo urls if getattr(item, 'url', None): # older pip has url links.append(str(item.url)) if getattr(item, 'link', None): # newer pip has link links.append(str(item.link)) if item.req: requires.append(str(item.req)) # TODO(frennkie) Evil Hack! print("===================================================") print("Starting installation of dependencies from Github..") print("===================================================") for idx, link in enumerate(links, 1): print("{} - Source: {}".format(idx, link)) pip_main(['install', link]) data_files = [('/usr/share/viper/', ['viper.conf.sample']), ('/usr/share/viper/peid/', ['data/peid/UserDB.TXT'])] for rule_name in os.listdir('data/yara/'): data_files.append(('/usr/share/viper/yara/', ['data/yara/{0}'.format(rule_name)])) description = "Binary Analysis & Management Framework" setup( name='viper-framework', version=__version__, author='Claudio Guarnieri', author_email='*****@*****.**', description=description, long_description=description,
def _pip_install_helper(package_names): for package in package_names: pip_main(['install', '-q', package]) logger.reset()
for i in range(number_of_courses): COURSES.append((course_depts[i], course_crns[i])) with open('preferences', 'wb') as f: pickle.dump([ TERM, COURSES, INTERVAL, SMS_ACTIVE, SMS_RECIPIENT, TWILIO_SID, TWILIO_AUTH_TOKEN, TWILIO_NUMBER ], f) # install packages # check for installed packages twilio_installed = importlib.util.find_spec('twilio') requests_installed = importlib.util.find_spec('requests') if SMS_ACTIVE and not twilio_installed: print('Twilio package not found. Installing twilio package with pip...') # pip pip_main(['install', 'twilio']) print('') if not requests_installed: print('Requests package not found. ' + 'Installing requests package with pip...') # pip pip_main(['install', 'requests'])
def install(params): """ Install third-party Mod """ try: from pip._internal import main as pip_main from pip._internal.commands.install import InstallCommand except ImportError: from pip import main as pip_main from pip.commands.install import InstallCommand params = [param for param in params] options, mod_list = InstallCommand().parse_args(params) mod_list = [mod_name for mod_name in mod_list if mod_name != "."] params = ["install"] + params for mod_name in mod_list: mod_name_index = params.index(mod_name) if mod_name.startswith("rqalpha_mod_sys_"): six.print_('System Mod can not be installed or uninstalled') return if "rqalpha_mod_" in mod_name: lib_name = mod_name else: lib_name = "rqalpha_mod_" + mod_name params[mod_name_index] = lib_name # Install Mod installed_result = pip_main(params) # Export config from rqalpha.utils.config import load_yaml, user_mod_conf_path user_conf = load_yaml(user_mod_conf_path()) if os.path.exists(user_mod_conf_path()) else {'mod': {}} if installed_result == 0: # 如果为0,则说明安装成功 if len(mod_list) == 0: """ 主要是方便 `pip install -e .` 这种方式 本地调试 Mod 使用,需要满足以下条件: 1. `rqalpha mod install -e .` 命令是在对应 自定义 Mod 的根目录下 2. 该 Mod 必须包含 `setup.py` 文件(否则也不能正常的 `pip install -e .` 来安装) 3. 该 Mod 包名必须按照 RQAlpha 的规范来命名,具体规则如下 * 必须以 `rqalpha-mod-` 来开头,比如 `rqalpha-mod-xxx-yyy` * 对应import的库名必须要 `rqalpha_mod_` 来开头,并且需要和包名后半部分一致,但是 `-` 需要替换为 `_`, 比如 `rqalpha_mod_xxx_yyy` """ mod_name = _detect_package_name_from_dir() mod_name = mod_name.replace("-", "_").replace("rqalpha_mod_", "") mod_list.append(mod_name) for mod_name in mod_list: if "rqalpha_mod_" in mod_name: mod_name = mod_name.replace("rqalpha_mod_", "") if "==" in mod_name: mod_name = mod_name.split('==')[0] user_conf['mod'][mod_name] = {} user_conf['mod'][mod_name]['enabled'] = False dump_config(user_mod_conf_path(), user_conf) return installed_result
def pip_install(*packages): for package in packages: pip_main(['install', package]) return True
#!/usr/bin/env python if __name__ == '__main__': import os import sys if sys.version_info[0:2] < (3, 4): raise SystemExit('python 3.4+ is required') try: import mtp_common if mtp_common.VERSION < (5,): raise ImportError except ImportError: try: try: from pip._internal import main as pip_main except ImportError: from pip import main as pip_main except ImportError: raise SystemExit('setuptools and pip are required') print('Pre-installing MTP-common') pip_main(['--quiet', 'install', '--upgrade', 'money-to-prisoners-common']) from mtp_common.build_tasks.executor import Executor exit(Executor(root_path=os.path.dirname(__file__)).run())
"""Install code on Binder. This script is executed from Dockerfile configuration file It installs software dependencies declared in environment.yml in the docker container built for the Binder service. """ import yaml import conda.cli from pip._internal import main as pip_main with open("environment.yml") as stream: content = yaml.load(stream) for chan in content['channels']: print("RUN conda config --add channels {}".format(chan)) conda.cli.main('conda', 'config', '--add', 'channels', chan) for pack in content['dependencies']: if isinstance(pack, str): print("RUN conda install -q -y {}".format(pack)) conda.cli.main('conda', 'install', '-y', '-q', pack) else: print("RUN pip install {}".format(pack['pip'][0])) pip_main(["install", pack['pip'][0]])
def update_plugin(self, plugin_name, revision=None, skip_reqs=False, hard_reset=False): """Updates a Git-based plugin Pulls changes from the remote, and checkout a specific revision. (will point to the tip of the branch if revision isn't given) :param plugin_name: Name of plugin to update. :param revision: Revision to checkout. :param skip_reqs: If True, will skip plugin requirements installation. :param hard_reset: Whether to drop all changes using git hard reset """ if plugin_name not in self.PLUGINS_DICT: raise IRFailedToUpdatePlugin( "Plugin '{}' isn't installed".format(plugin_name)) plugin = self.get_plugin(plugin_name) try: repo = git.Repo(plugin.path, search_parent_directories=True) except git.InvalidGitRepositoryError: raise IRFailedToUpdatePlugin( "Plugin '{}' isn't a Git-based plugin".format(plugin_name)) # microseconds ('%f') required for unit testing timestamp = \ datetime.datetime.fromtimestamp( time.time()).strftime('%B-%d-%Y_%H-%M-%S-%f') update_string = \ 'IR_Plugin_update_{plugin_name}_{timestamp}' \ ''.format(plugin_name=plugin_name, timestamp=timestamp) LOG.debug("Checking for changes of tracked files " "in {}".format(plugin.path)) changed_tracked_files = \ repo.git.status('--porcelain', '--untracked-files=no') all_changed_files = repo.git.status('--porcelain') if changed_tracked_files and not hard_reset: raise IRFailedToUpdatePlugin( "Failed to update plugin {}\n" "Found changes in tracked files, " "please go to {}, and manually save " "your changes!".format(plugin_name, plugin.path)) if hard_reset: if all_changed_files: repo.git.stash('save', '-u', update_string) LOG.warning("All changes have been " "stashed - '{}'".format(update_string)) repo.git.reset('--hard', 'HEAD') # checkout revision self._checkout_git_plugin_revision(repo, revision, update_string) if not hard_reset: # pull changes self._pull_git_plugin_changes(repo) if repo.git.status('--porcelain', '--untracked-files=no'): LOG.warning("Changes in tracked files have been found") if not skip_reqs: reqs_file = os.path.join(plugin.path, 'requirements.txt') if os.path.isfile(reqs_file): pip_main(['install', '-r', reqs_file])