home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2409 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  5.2 KB  |  110 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from setuptools.command.easy_install import easy_install
  5. from distutils.util import convert_path
  6. from pkg_resources import Distribution, PathMetadata, normalize_path
  7. from distutils import log
  8. from distutils.errors import *
  9. import sys
  10. import os
  11. import setuptools
  12. import glob
  13.  
  14. class develop(easy_install):
  15.     description = "install package in 'development mode'"
  16.     user_options = easy_install.user_options + [
  17.         ('uninstall', 'u', 'Uninstall this source package'),
  18.         ('egg-path=', None, 'Set the path to be used in the .egg-link file')]
  19.     boolean_options = easy_install.boolean_options + [
  20.         'uninstall']
  21.     command_consumes_arguments = False
  22.     
  23.     def run(self):
  24.         if self.uninstall:
  25.             self.multi_version = True
  26.             self.uninstall_link()
  27.         else:
  28.             self.install_for_development()
  29.         self.warn_deprecated_options()
  30.  
  31.     
  32.     def initialize_options(self):
  33.         self.uninstall = None
  34.         self.egg_path = None
  35.         easy_install.initialize_options(self)
  36.         self.setup_path = None
  37.         self.always_copy_from = '.'
  38.  
  39.     
  40.     def finalize_options(self):
  41.         ei = self.get_finalized_command('egg_info')
  42.         if ei.broken_egg_info:
  43.             raise DistutilsError("Please rename %r to %r before using 'develop'" % (ei.egg_info, ei.broken_egg_info))
  44.         ei.broken_egg_info
  45.         self.args = [
  46.             ei.egg_name]
  47.         easy_install.finalize_options(self)
  48.         self.package_index.scan(glob.glob('*.egg'))
  49.         self.egg_link = os.path.join(self.install_dir, ei.egg_name + '.egg-link')
  50.         self.egg_base = ei.egg_base
  51.         if self.egg_path is None:
  52.             self.egg_path = os.path.abspath(ei.egg_base)
  53.         
  54.         target = normalize_path(self.egg_base)
  55.         if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target:
  56.             raise DistutilsOptionError('--egg-path must be a relative path from the install directory to ' + target)
  57.         normalize_path(os.path.join(self.install_dir, self.egg_path)) != target
  58.         self.dist = Distribution(target, PathMetadata(target, os.path.abspath(ei.egg_info)), project_name = ei.egg_name)
  59.         p = self.egg_base.replace(os.sep, '/')
  60.         if p != os.curdir:
  61.             p = '../' * (p.count('/') + 1)
  62.         
  63.         self.setup_path = p
  64.         p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
  65.         if p != normalize_path(os.curdir):
  66.             raise DistutilsOptionError("Can't get a consistent path to setup script from installation directory", p, normalize_path(os.curdir))
  67.         p != normalize_path(os.curdir)
  68.  
  69.     
  70.     def install_for_development(self):
  71.         self.run_command('egg_info')
  72.         self.reinitialize_command('build_ext', inplace = 1)
  73.         self.run_command('build_ext')
  74.         self.install_site_py()
  75.         if setuptools.bootstrap_install_from:
  76.             self.easy_install(setuptools.bootstrap_install_from)
  77.             setuptools.bootstrap_install_from = None
  78.         
  79.         log.info('Creating %s (link to %s)', self.egg_link, self.egg_base)
  80.         if not self.dry_run:
  81.             f = open(self.egg_link, 'w')
  82.             f.write(self.egg_path + '\n' + self.setup_path)
  83.             f.close()
  84.         
  85.         self.process_distribution(None, self.dist, not (self.no_deps))
  86.  
  87.     
  88.     def uninstall_link(self):
  89.         if not self.dry_run:
  90.             self.update_pth(self.dist)
  91.         
  92.         if self.distribution.scripts:
  93.             log.warn('Note: you must uninstall or replace scripts manually!')
  94.         
  95.  
  96.     
  97.     def install_egg_scripts(self, dist):
  98.         if dist is not self.dist:
  99.             return easy_install.install_egg_scripts(self, dist)
  100.         self.install_wrapper_scripts(dist)
  101.         for script_name in []:
  102.             script_path = os.path.abspath(convert_path(script_name))
  103.             script_name = os.path.basename(script_path)
  104.             f = open(script_path, 'rU')
  105.             script_text = f.read()
  106.             f.close()
  107.             self.install_script(dist, script_name, script_text, script_path)
  108.  
  109.  
  110.