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_single(self, sqlexecutor: SQLQueryExecutor, package_file: str, scope: Scope, is_target=False, out_file: str = None): name = str(get_package_name_from_file(package_file)) version = str(get_package_version_from_file(package_file)) print("Installing {name} version: {version}".format(name=name, version=version)) with tempfile.TemporaryDirectory() as temporary_directory: prezip = os.path.join(temporary_directory, name + "PREZIP.zip") with zipfile.ZipFile(prezip, 'w') as zipf: zipf.write(package_file, os.path.basename(package_file)) builder = CreateLibraryBuilder(pkg_name=name, pkg_filename=prezip, scope=scope, language_name=self._language_name) sqlexecutor.execute(builder, out_file=out_file) builder = CheckLibraryBuilder(pkg_name=name, scope=scope, language_name=self._language_name) sqlexecutor.execute(builder, out_file=out_file)
def _install_single(sqlexecutor: SQLQueryExecutor, package_file: str, scope: Scope, is_target=False): name = get_package_name_from_file(package_file) version = get_package_version_from_file(package_file) with tempfile.TemporaryDirectory() as temporary_directory: prezip = os.path.join(temporary_directory, name + "PREZIP.zip") with zipfile.ZipFile(prezip, 'w') as zipf: zipf.write(package_file, os.path.basename(package_file)) builder = CreateLibraryBuilder(pkg_name=name, pkg_filename=prezip, scope=scope) sqlexecutor.execute(builder)