def install_packages(self): self._update_package_with_install_path() installed_packages = [] for p in self._packages: if 'install_from' not in p: print("[dem] Could not find package: {}, version: {}".format(p['name'], p['version'])) else: if not self._cache.is_package_installed(p['name'], p['version']): print('[dem] installing {}-{}'.format(p['name'], p['version'])) if p['install_from_ext'] == 'zip': with ZipFile(p['install_from'], 'r') as archive: locations = self._extract(archive, p) elif p['install_from_ext'] == 'tar.gz': with TarFile.open(p['install_from'], 'r:gz') as archive: locations = self._extract(archive, p) elif p['install_from_ext'] == 'tar.bz2': with TarFile.open(p['install_from'], 'r:bz2') as archive: locations = self._extract(archive, p) elif p['install_from_ext'] == 'gz': with gzip.open(p['install_from'], 'r') as archive: locations = self._extract(archive, p) if 'pkg-config' in p: PkgConfigProcessor.replace_prefix(locations, p['pkg-config']) else: print('[dem] {}-{} already installed'.format(p['name'], p['version'])) locations = self._cache.install_locations(p['name']) package = dict() package[p['name']] = {'version': p['version'], 'type': 'local', 'install_locations': locations} installed_packages.append(package) return installed_packages
def test_will_replace_prefix_variable_in_all_pc_files(self): self.setup_files(SAMPLE_YAML_CONTENT, SAMPLE_CACHE_CONTENT) self.create_dependency_directory(os.path.join('qt', 'lib')) self.create_dependency_directory(os.path.join('qt', 'lib', 'pkgconfig')) self.create_dependency_file(os.path.join('qt', 'lib', 'pkgconfig', 'Qt5Core.pc'), SAMPLE_PKG_CONFIG_FILE) cache = PackageCache('myProject', self._base_path) (_, packages) = reader.devenv_from_file(self._yaml_file) PkgConfigProcessor.replace_prefix(cache.install_locations('qt'), packages['qt']['pkg-config']) with open(os.path.join(self._deps, 'qt', 'lib', 'pkgconfig', 'Qt5Core.pc')) as f: replaced_pkg_config_data = f.readlines() self.assertEqual(''.join(replaced_pkg_config_data), EXPECTED_SAMPLE_PKG_CONFIG_FILE)