def run(self): # I believe the word 'bogus' is operative here. When we run # get_outputs() it will create subcommands, which will try to # create the original 'install' object, which does not exist # at this point. We need to make sure that the --prefix # argument gets propagated to said object. This is not the # right way to do that, but it works, for now. install = self.distribution.get_command_obj('install') install.prefix = self.prefix install.ensure_finalized() dirs = {} for f in self.get_outputs(): dirs[os.path.dirname(f)] = 1 if os.path.isdir(f): dirs[f] = 1 continue print "Trying to remove file", f try: os.unlink(f) except: pass # Gently try to remove any empty directories. # This is really not guaranteed to work!!! for d in dirs: while d != self.prefix: print "Trying to remove dir", d try: if d.endswith(".egg-info"): files=[os.path.join(d,f) for f in os.listdir(d)] print "Trying to remove:", " ".join(files) for f in files: os.unlink(f) os.rmdir(d) except: pass d = os.path.dirname(d)
def run(self): # I believe the word 'bogus' is operative here. When we run # get_outputs() it will create subcommands, which will try to # create the original 'install' object, which does not exist # at this point. We need to make sure that the --prefix # argument gets propagated to said object. This is not the # right way to do that, but it works, for now. install = self.distribution.get_command_obj('install') install.prefix = self.prefix install.ensure_finalized() dirs = {} for f in self.get_outputs(): dirs[os.path.dirname(f)] = 1 if os.path.isdir(f): dirs[f] = 1 continue print "Trying to remove file", f try: os.unlink(f) except: pass # Gently try to remove any empty directories. # This is really not guaranteed to work!!! for d in dirs: while d != self.prefix: print "Trying to remove dir", d try: if d.endswith(".egg-info"): files=[os.path.join(d,f) for f in os.listdir(d)] print "Trying to remove:", " ".join(files) for f in files: os.unlink(f) os.rmdir(d) except: pass d = os.path.dirname(d)
def run(self): if sys.version < '2.3': raise DistutilsPlatformError('Python Eggs require Python 2.3+') if not self.skip_build: # Run any build commands self.run_command_family('build', self.build_commands) self.mkpath(self.bdist_dir) # Set the options for the installation commands install = self.reinitialize_command('install') # We need a "prestine" command (no options from anywhere else) install.initialize_options() for cmd_name, predicate in install.sub_commands: self.reinitialize_command(cmd_name).initialize_options() install.skip_build = self.skip_build install.compile = True install.install_base = install.install_platbase = self.bdist_dir install.select_scheme('zip') install.ensure_finalized() # Make the install appear to be a "chroot" install install.root = self.bdist_dir install.install_base = install.install_platbase = None # Run the commands that install "resources" commands = self.run_command_family('install', self.install_commands) outputs = [] for command in commands: cmd = self.get_finalized_command(command) outputs.extend(cmd.get_outputs()) # Create stub loaders for any extension modules py_files = self.write_extension_module_stubs() # Create namespace package loaders py_files.extend(self.write_namespace_package_stubs()) # Byte-compile any additional Python source files if py_files: outputs.extend(py_files) # Byte-compile the stubs and record the compiled filenames install_lib = self.get_finalized_command('install_lib') install_lib.byte_compile(py_files) for py_file in py_files: if install_lib.compile: outputs.append(py_file + 'c') if install_lib.optimize > 0: outputs.append(py_file + 'o') # Add the standard metadata (EGG-INFO directory) outputs.extend(self.write_metadata()) # Make the egg distribution dist_filename = self.make_distribution(outputs) # Add to 'Distribution.dist_files' so that the "upload" command works if hasattr(self.distribution, 'dist_files'): spec = ('bdist_egg', get_python_version(), dist_filename) self.distribution.dist_files.append(spec) if not self.keep_temp: remove_tree(self.bdist_dir, self.verbose, self.dry_run) return
def run(self): if sys.version < '2.3': raise DistutilsPlatformError('Python Eggs require Python 2.3+') if not self.skip_build: # Run any build commands self.run_command_family('build', self.build_commands) self.mkpath(self.bdist_dir) # Set the options for the installation commands install = self.reinitialize_command('install') # We need a "prestine" command (no options from anywhere else) install.initialize_options() for cmd_name, predicate in install.sub_commands: self.reinitialize_command(cmd_name).initialize_options() install.skip_build = self.skip_build install.compile = True install.install_base = install.install_platbase = self.bdist_dir install.select_scheme('zip') install.ensure_finalized() # Make the install appear to be a "chroot" install install.root = self.bdist_dir install.install_base = install.install_platbase = None # Run the commands that install "resources" commands = self.run_command_family('install', self.install_commands) outputs = [] for command in commands: cmd = self.get_finalized_command(command) outputs.extend(cmd.get_outputs()) # Create stub loaders for any extension modules py_files = self.write_extension_module_stubs() # Create namespace package loaders py_files.extend(self.write_namespace_package_stubs()) # Byte-compile any additional Python source files if py_files: outputs.extend(py_files) # Byte-compile the stubs and record the compiled filenames install_lib = self.get_finalized_command('install_lib') install_lib.byte_compile(py_files) for py_file in py_files: if install_lib.compile: outputs.append(py_file + 'c') if install_lib.optimize > 0: outputs.append(py_file + 'o') # Add the standard metadata (EGG-INFO directory) outputs.extend(self.write_metadata()) # Make the egg distribution dist_filename = self.make_distribution(outputs) # Add to 'Distribution.dist_files' so that the "upload" command works if hasattr(self.distribution, 'dist_files'): spec = ('bdist_egg', get_python_version(), dist_filename) self.distribution.dist_files.append(spec) if not self.keep_temp: remove_tree(self.bdist_dir, self.verbose, self.dry_run) return