/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Martin Pool
  • Date: 2007-08-20 05:53:39 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2730.
  • Revision ID: mbp@sourcefrog.net-20070820055339-uzei7f7i7jo6tugg
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
        if sys.platform == "win32":
105
105
            try:
106
 
                scripts_dir = self.install_dir
 
106
                scripts_dir = os.path.join(sys.prefix, 'Scripts')
107
107
                script_path = self._quoted_path(os.path.join(scripts_dir,
108
108
                                                             "bzr"))
109
109
                python_exe = self._quoted_path(sys.executable)
110
110
                args = self._win_batch_args()
111
111
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
112
 
                batch_path = script_path + ".bat"
 
112
                batch_path = os.path.join(self.install_dir, "bzr.bat")
113
113
                f = file(batch_path, "w")
114
114
                f.write(batch_str)
115
115
                f.close()
148
148
########################
149
149
 
150
150
command_classes = {'install_scripts': my_install_scripts,
151
 
                  'build': bzr_build}
 
151
                   'build': bzr_build}
 
152
from distutils.extension import Extension
152
153
ext_modules = []
153
154
try:
154
155
    from Pyrex.Distutils import build_ext
155
156
except ImportError:
 
157
    have_pyrex = False
156
158
    # try to build the extension from the prior generated source.
157
 
    print ("Pyrex not available, while bzr will build, "
158
 
           "you cannot modify the C extensions.")
 
159
    print
 
160
    print ("The python package 'Pyrex' is not available."
 
161
           " If the .c files are available,")
 
162
    print ("they will be built,"
 
163
           " but modifying the .pyx files will not rebuild them.")
 
164
    print
159
165
    from distutils.command.build_ext import build_ext
160
 
    from distutils.extension import Extension
161
 
    #ext_modules.append(
162
 
    #    Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
163
166
else:
164
 
    from distutils.extension import Extension
165
 
    #ext_modules.append(
166
 
    #    Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
 
167
    have_pyrex = True
 
168
# Override the build_ext if we have Pyrex available
167
169
command_classes['build_ext'] = build_ext
 
170
unavailable_files = []
 
171
 
 
172
 
 
173
def add_pyrex_extension(module_name, **kwargs):
 
174
    """Add a pyrex module to build.
 
175
 
 
176
    This will use Pyrex to auto-generate the .c file if it is available.
 
177
    Otherwise it will fall back on the .c file. If the .c file is not
 
178
    available, it will warn, and not add anything.
 
179
 
 
180
    You can pass any extra options to Extension through kwargs. One example is
 
181
    'libraries = []'.
 
182
 
 
183
    :param module_name: The python path to the module. This will be used to
 
184
        determine the .pyx and .c files to use.
 
185
    """
 
186
    path = module_name.replace('.', '/')
 
187
    pyrex_name = path + '.pyx'
 
188
    c_name = path + '.c'
 
189
    if have_pyrex:
 
190
        ext_modules.append(Extension(module_name, [pyrex_name]))
 
191
    else:
 
192
        if not os.path.isfile(c_name):
 
193
            unavailable_files.append(c_name)
 
194
        else:
 
195
            ext_modules.append(Extension(module_name, [c_name]))
 
196
 
 
197
 
 
198
add_pyrex_extension('bzrlib._dirstate_helpers_c')
 
199
add_pyrex_extension('bzrlib._knit_load_data_c')
 
200
 
 
201
 
 
202
if unavailable_files:
 
203
    print 'C extension(s) not found:'
 
204
    print '   %s' % ('\n  '.join(unavailable_files),)
 
205
    print 'The python versions will be used instead.'
 
206
    print
 
207
 
168
208
 
169
209
if 'bdist_wininst' in sys.argv:
170
210
    import glob
171
211
    # doc files
172
 
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
173
 
    dev_docs = glob.glob('doc/developers/*.htm')
 
212
    docs = glob.glob('doc/*.html') + ['doc/default.css']
 
213
    dev_docs = glob.glob('doc/developers/*.html')
174
214
    # python's distutils-based win32 installer
175
215
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
216
            'ext_modules': ext_modules,
176
217
            # help pages
177
218
            'data_files': [('Doc/Bazaar', docs),
178
219
                           ('Doc/Bazaar/developers', dev_docs),
179
220
                          ],
 
221
            # for building pyrex extensions
 
222
            'cmdclass': {'build_ext': build_ext},
180
223
           }
181
224
 
182
225
    ARGS.update(META_INFO)
223
266
        import warnings
224
267
        warnings.warn('Unknown Python version.\n'
225
268
                      'Please check setup.py script for compatibility.')
 
269
    # email package from std python library use lazy import,
 
270
    # so we need to explicitly add all package
 
271
    additional_packages.append('email')
226
272
 
227
273
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
228
274
                                           additional_packages,
237
283
          zipfile='lib/library.zip')
238
284
 
239
285
else:
 
286
    # ad-hoc for easy_install
 
287
    DATA_FILES = []
 
288
    if not 'bdist_egg' in sys.argv:
 
289
        # generate and install bzr.1 only with plain install, not easy_install one
 
290
        DATA_FILES = [('man/man1', ['bzr.1'])]
 
291
 
240
292
    # std setup
241
293
    ARGS = {'scripts': ['bzr'],
242
 
            'data_files': [('man/man1', ['bzr.1'])],
 
294
            'data_files': DATA_FILES,
243
295
            'cmdclass': command_classes,
244
296
            'ext_modules': ext_modules,
245
297
           }
246
 
    
 
298
 
247
299
    ARGS.update(META_INFO)
248
300
    ARGS.update(BZRLIB)
249
301
    ARGS.update(PKG_DATA)