def install_file(self, source_path, destination_path, directory): """Install a folder or a file to a installation one. """ if destination_path in self.status.installed_paths: self.status.paths.add(destination_path, directory=directory) return if directory: if os.path.exists(destination_path): if not os.path.isdir(destination_path): raise InstallationError( u"Error target directory already exists as a file", destination_path) else: create_directory(destination_path, quiet=True) else: self.status.test_override_rule(destination_path) if not os.path.exists(source_path): raise InstallationError( u"Error missing directory or file in source", source_path) parent_path = os.path.dirname(destination_path) if not os.path.exists(parent_path): create_directory(parent_path, quiet=True) shutil.copy2(source_path, destination_path) self.status.paths.add(destination_path, directory=directory, added=True)
def write_egg_info(package, writers=[write_pkg_info, write_missing_setuptool_files, write_entry_points, write_requires], package_path=None): if package_path is None: package_path = package.path logger.info('Writing EGG-INFO in %s for %s' % (package_path, package.name)) path = os.path.join(package_path, 'EGG-INFO') create_directory(path) for writer in writers: writer(path, package)
def __init__(self, options, status): super(File, self).__init__(options, status) self.overrides = options.get('files_overrides', '').as_list() self.files = parse_files(options, 'files') self.urls = parse_files(options, 'urls') self.directory = options['directory'].as_text() download_path = options.get( 'download_directory', '${setup:prefix_directory}/download').as_text() create_directory(download_path) self.downloader = DownloadManager(download_path) self._do = MultiTask(options, 'download')
def preinstall(self): __status__ = u"Preparing installing VCS directories." if self.checkouts: VCS.initialize() create_directory(self.directory) update = self.status.strategy != STRATEGY_QUICK def prepare(checkout): repository = VCS(checkout) repository.inspect(update=update) return repository self.repositories.extend(self._do(prepare, self.checkouts.values()))
def install(self, path): # Remove egg_info to prevent strange things to happen shutil.rmtree(self.egg_info) create_directory(path) output, errors, code = self.execute( 'bdist_egg', '-k', '--bdist-dir', path, path=self.distribution.package_path) if code: raise PackageError( u"Setuptools retuned status code %s, " u"while installing in %s." % (code, path), detail='\n'.join((output, errors)))
def prepare(self, context): __status__ = u"Preparing remote development sources." checkouts = list(self.get_checkouts()) if checkouts: VCS.initialize() create_directory(self.directory) sources = {} for checkout in checkouts: if self.enabled and checkout.name not in self.enabled: continue sources[keyify(checkout.name)] = VCS(checkout) return VCSQuery(context, sources) return None
def prepare(self, context): __status__ = u"Analysing local software source %s." % ( ', '.join(self.paths)) installers = Installers() def build_installer(informations): return self.installer_factory(context, **informations) for path in self.paths: create_directory(path) installers.extend(map(build_installer, self.get_information(path))) if installers: return Query(context, installers) return None
def __init__(self, configuration, strategy): # Store all parts status for mutual access self.parts_status = {} self.strategy = strategy # Look which parts must installed self._setup = configuration['setup'] to_install_names = set(self._setup['install'].as_list()) # Look previous configuration installed_cfg = configuration.utilities.installed installed_setup = installed_cfg.get('setup', None) if installed_setup is not None: self.prefix_changed = ( self._setup['prefix_directory'].as_text() != installed_setup['prefix_directory'].as_text()) if self.prefix_changed: # Set prefix in previous configuration to the new not to # confuse installed paths. installed_setup['prefix_directory'].set_value( self._setup['prefix_directory'].as_text()) # Look what should be uninstalled to_uninstall_names = set(installed_setup['install'].as_list()) to_uninstall_names -= to_install_names else: self.prefix_changed = False to_uninstall_names = [] self.to_uninstall = [ (name, installed_cfg[name]) for name in to_uninstall_names] self.to_install = [ (name, configuration[name]) for name in to_install_names] # Setup working set: used only for recipes self._install_set = WorkingSet(no_activate=False) self._installer = PackageInstaller( self._setup, self._install_set, directory=create_directory(os.path.join( configuration.get_previous_cfg_directory(), 'lib'))) self.get_recipe_entry_point = self._install_set.get_entry_point
def get_download_directory(self): """Return the created download directory. """ directory = self.options['download_directory'].as_text() create_directory(directory) return directory
def as_directory(self): """Return the value as a directory, creating it if needed. """ return create_directory(self.as_text())
def get_previous_cfg_directory(self, *ignore): """Return the previous configuration directory. """ destination = self['setup']['prefix_directory'].as_directory() return create_directory(os.path.join(destination, DEFAULT_CONFIG_DIR))
def get_default_cfg_directory(self): """Return the default configuration directory. """ user_directory = os.path.expanduser('~') return create_directory( os.path.join(user_directory, DEFAULT_CONFIG_DIR))