]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - setuptools-0.6c16dev3.egg/setuptools/command/develop.py
setup.py: compile C modules with -Wextra warning flag
[tahoe-lafs/zfec.git] / setuptools-0.6c16dev3.egg / setuptools / command / develop.py
1 from setuptools.command.easy_install import easy_install
2 from distutils.util import convert_path
3 from pkg_resources import Distribution, PathMetadata, normalize_path
4 from distutils import log
5 from distutils.errors import *
6 import sys, os, setuptools, glob
7
8 class develop(easy_install):
9     """Set up package for development"""
10
11     description = "install package in 'development mode'"
12
13     user_options = easy_install.user_options + [
14         ("uninstall", "u", "Uninstall this source package"),
15         ("egg-path=", None, "Set the path to be used in the .egg-link file"),
16     ]
17
18     boolean_options = easy_install.boolean_options + ['uninstall']
19
20     command_consumes_arguments = False  # override base
21
22     def run(self):
23         self.old_run()
24         if sys.platform == "win32":
25             from setuptools.command.scriptsetup import do_scriptsetup
26             do_scriptsetup()
27
28     def old_run(self):
29         if self.uninstall:
30             self.multi_version = True
31             self.uninstall_link()
32         else:
33             self.install_for_development()
34         self.warn_deprecated_options()
35
36     def initialize_options(self):
37         self.uninstall = None
38         self.egg_path = None
39         easy_install.initialize_options(self)
40         self.setup_path = None
41         self.always_copy_from = '.'   # always copy eggs installed in curdir
42
43     def finalize_options(self):
44         ei = self.get_finalized_command("egg_info")
45         if ei.broken_egg_info:
46             raise DistutilsError(
47             "Please rename %r to %r before using 'develop'"
48             % (ei.egg_info, ei.broken_egg_info)
49             )
50         self.args = [ei.egg_name]
51         easy_install.finalize_options(self)
52         # pick up setup-dir .egg files only: no .egg-info
53         self.package_index.scan(glob.glob('*.egg'))
54
55         self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link')
56         self.egg_base = ei.egg_base
57         if self.egg_path is None:
58             self.egg_path = os.path.abspath(ei.egg_base)
59
60         target = normalize_path(self.egg_base)
61         if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target:
62             raise DistutilsOptionError(
63                 "--egg-path must be a relative path from the install"
64                 " directory to "+target
65         )
66         
67         # Make a distribution for the package's source
68         self.dist = Distribution(
69             target,
70             PathMetadata(target, os.path.abspath(ei.egg_info)),
71             project_name = ei.egg_name
72         )
73
74         p = self.egg_base.replace(os.sep,'/')
75         if p!= os.curdir:
76             p = '../' * (p.count('/')+1)
77         self.setup_path = p
78         p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
79         if  p != normalize_path(os.curdir):
80             raise DistutilsOptionError(
81                 "Can't get a consistent path to setup script from"
82                 " installation directory", p, normalize_path(os.curdir))
83
84     def install_for_development(self):
85         # Ensure metadata is up-to-date
86         self.run_command('egg_info')
87         # Build extensions in-place
88         self.reinitialize_command('build_ext', inplace=1)
89         self.run_command('build_ext')
90         self.install_site_py()  # ensure that target dir is site-safe
91         if setuptools.bootstrap_install_from:
92             self.easy_install(setuptools.bootstrap_install_from)
93             setuptools.bootstrap_install_from = None
94
95         # create an .egg-link in the installation dir, pointing to our egg
96         log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
97         if not self.dry_run:
98             f = open(self.egg_link,"w")
99             f.write(self.egg_path + "\n" + self.setup_path)
100             f.close()
101         # postprocess the installed distro, fixing up .pth, installing scripts,
102         # and handling requirements
103         self.process_distribution(None, self.dist, not self.no_deps)
104
105
106     def uninstall_link(self):
107         if os.path.exists(self.egg_link):
108             log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)
109             contents = [line.rstrip() for line in file(self.egg_link)]
110             if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
111                 log.warn("Link points to %s: uninstall aborted", contents)
112                 return
113             if not self.dry_run:
114                 os.unlink(self.egg_link)
115         if not self.dry_run:
116             self.update_pth(self.dist)  # remove any .pth link to us
117         if self.distribution.scripts:
118             # XXX should also check for entry point scripts!
119             log.warn("Note: you must uninstall or replace scripts manually!")
120
121
122
123
124
125     def install_egg_scripts(self, dist):
126         if dist is not self.dist:
127             # Installing a dependency, so fall back to normal behavior
128             return easy_install.install_egg_scripts(self,dist)
129
130         # create wrapper scripts in the script dir, pointing to dist.scripts
131
132         # new-style...
133         self.install_wrapper_scripts(dist)
134
135         # ...and old-style
136         for script_name in self.distribution.scripts or []:
137             script_path = os.path.abspath(convert_path(script_name))
138             script_name = os.path.basename(script_path)
139             f = open(script_path,'rU')
140             script_text = f.read()
141             f.close()
142             self.install_script(dist, script_name, script_text, script_path)
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165