def _install_from_file(self, target_package_file: str, scope: Scope, upgrade: bool = False): name = get_package_name_from_file(target_package_file) version = get_package_version_from_file(target_package_file) resolver = DependencyResolver(self.list(), name) if resolver.requirement_met(upgrade, version): serverversion = resolver.get_target_server_version() print(messages.no_upgrade(name, serverversion, version)) return # Download requirements from PyPI with tempfile.TemporaryDirectory() as temporary_directory: pipdownloader = PipDownloader(self._connection_info, temporary_directory, target_package_file) # For now, we download all target package dependencies from PyPI. target_package_requirements, requirements_downloaded = pipdownloader.download( ) # Resolve which package dependencies need to be installed or upgraded on server. required_installs = resolver.get_required_installs( target_package_requirements) dependencies_to_install = self._get_required_files_to_install( requirements_downloaded, required_installs) self._install_many(target_package_file, dependencies_to_install, scope)
def _install_from_pypi(self, target_package: str, upgrade: bool = False, version: str = None, install_dependencies: bool = True, scope: Scope = Scope.private_scope(), out_file: str = None): if not install_dependencies: raise ValueError( "Dependencies will always be installed - " "single package install without dependencies not yet supported." ) if version is not None: target_package = target_package + "==" + version with tempfile.TemporaryDirectory() as temporary_directory: pipdownloader = PipDownloader(self._connection_info, temporary_directory, target_package, language_name=self._language_name) target_package_file = pipdownloader.download_single() self._install_from_file(target_package_file, scope, upgrade, out_file=out_file)
else: manager.uninstall(pkg, scope=Scope.public_scope()) else: if sc != original_libs[lib][1]: if sc: manager.uninstall(pkg, scope=Scope.private_scope()) else: manager.uninstall(pkg, scope=Scope.public_scope()) # Download the package zips we will use for these tests # packages = ["astor==0.8.1", "html5lib==1.0.1", "termcolor==1.1.0"] for package in packages: pipdownloader = PipDownloader(connection, path_to_packages, package, language_name="Python") pipdownloader.download_single() def test_install_basic_zip_package(): """Test a basic zip package""" package = os.path.join(path_to_packages, "testpackageA-0.0.1.zip") module_name = "testpackageA" _remove_all_new_packages(pkgmanager) _create(module_name=module_name, package_file=package, class_to_check="ClassA") def test_install_whl_files(): """Test some basic wheel files""" packages = ["html5lib-1.0.1-py2.py3-none-any.whl", "astor-0.8.1-py2.py3-none-any.whl"]
else: if sc != original_libs[lib][1]: if sc: manager.uninstall(pkg, scope=Scope.private_scope()) else: manager.uninstall(pkg, scope=Scope.public_scope()) packages = [ "absl-py==0.1.13", "astor==0.6.2", "bleach==1.5.0", "cryptography==2.2.2", "html5lib==1.0.1", "Markdown==2.6.11", "numpy==1.14.3", "termcolor==1.1.0", "webencodings==0.5.1" ] for package in packages: pipdownloader = PipDownloader(connection, path_to_packages, package) pipdownloader.download_single() def test_install_basic_zip_package(): package = os.path.join(path_to_packages, "testpackageA-0.0.1.zip") module_name = "testpackageA" _remove_all_new_packages(pkgmanager) _create(module_name=module_name, package_file=package, class_to_check="ClassA") def test_install_basic_zip_package_different_name():