~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
import os.path
11
11
import sys
12
12
 
 
13
if sys.version_info < (2, 4):
 
14
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
 
15
    sys.exit(1)
 
16
 
13
17
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
14
18
# './setup.py' or the equivalent with another path, should always be at the
15
19
# start of the path, so this should find the right one...
64
68
                                       ]},
65
69
           }
66
70
 
67
 
######################################################################
68
 
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
69
 
# including bzrlib.help
70
 
 
71
 
try:
72
 
    version_info = sys.version_info
73
 
except AttributeError:
74
 
    version_info = 1, 5 # 1.5 or older
75
 
 
76
 
REINVOKE = "__BZR_REINVOKE"
77
 
NEED_VERS = (2, 4)
78
 
KNOWN_PYTHONS = ('python2.4',)
79
 
 
80
 
if version_info < NEED_VERS:
81
 
    if not os.environ.has_key(REINVOKE):
82
 
        # mutating os.environ doesn't work in old Pythons
83
 
        os.putenv(REINVOKE, "1")
84
 
        for python in KNOWN_PYTHONS:
85
 
            try:
86
 
                os.execvp(python, [python] + sys.argv)
87
 
            except OSError:
88
 
                pass
89
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
90
 
    sys.stderr.write("  (need %d.%d or later)" % NEED_VERS)
91
 
    sys.stderr.write('\n')
92
 
    sys.exit(1)
93
 
if getattr(os, "unsetenv", None) is not None:
94
 
    os.unsetenv(REINVOKE)
95
 
 
96
71
 
97
72
def get_bzrlib_packages():
98
73
    """Recurse through the bzrlib directory, and extract the package names"""
267
242
        for root, dirs, files in os.walk('doc'):
268
243
            r = []
269
244
            for f in files:
270
 
                if os.path.splitext(f)[1] in ('.html','.css','.png','.pdf'):
 
245
                if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
 
246
                    or f == 'quick-start-summary.svg'):
271
247
                    r.append(os.path.join(root, f))
272
248
            if r:
273
249
                relative = root[4:]
294
270
    setup(**ARGS)
295
271
 
296
272
elif 'py2exe' in sys.argv:
 
273
    import glob
297
274
    # py2exe setup
298
275
    import py2exe
299
276
 
321
298
                                     comments = META_INFO['description'],
322
299
                                    )
323
300
 
324
 
    additional_packages =  []
 
301
    packages = BZRLIB['packages']
 
302
    packages.remove('bzrlib')
 
303
    packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
 
304
    includes = []
 
305
    for i in glob.glob('bzrlib\\*.py'):
 
306
        module = i[:-3].replace('\\', '.')
 
307
        if module.endswith('__init__'):
 
308
            module = module[:-len('__init__')]
 
309
        includes.append(module)
 
310
 
 
311
    additional_packages = set()
325
312
    if sys.version.startswith('2.4'):
326
313
        # adding elementtree package
327
 
        additional_packages.append('elementtree')
 
314
        additional_packages.add('elementtree')
328
315
    elif sys.version.startswith('2.5'):
329
 
        additional_packages.append('xml.etree')
 
316
        additional_packages.add('xml.etree')
330
317
    else:
331
318
        import warnings
332
319
        warnings.warn('Unknown Python version.\n'
333
320
                      'Please check setup.py script for compatibility.')
334
321
    # email package from std python library use lazy import,
335
322
    # so we need to explicitly add all package
336
 
    additional_packages.append('email')
 
323
    additional_packages.add('email')
337
324
 
338
325
    # text files for help topis
339
 
    import glob
340
326
    text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
341
 
 
342
 
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
343
 
                                           additional_packages,
 
327
    topics_files = [('lib/help_topics/en', text_topics)]
 
328
 
 
329
    # built-in plugins
 
330
    plugins_files = []
 
331
    for root, dirs, files in os.walk('bzrlib/plugins'):
 
332
        x = []
 
333
        for i in files:
 
334
            if not i.endswith('.py'):
 
335
                continue
 
336
            if i == '__init__.py' and root == 'bzrlib/plugins':
 
337
                continue
 
338
            x.append(os.path.join(root, i))
 
339
        if x:
 
340
            target_dir = root[len('bzrlib/'):]  # install to 'plugins/...'
 
341
            plugins_files.append((target_dir, x))
 
342
    # find modules for built-in plugins
 
343
    import tools.package_mf
 
344
    mf = tools.package_mf.CustomModuleFinder()
 
345
    mf.run_package('bzrlib/plugins')
 
346
    packs, mods = mf.get_result()
 
347
    additional_packages.update(packs)
 
348
 
 
349
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
 
350
                               "includes": includes + mods,
344
351
                               "excludes": ["Tkinter", "medusa", "tools"],
345
352
                               "dist_dir": "win32_bzr.exe",
346
353
                              },
350
357
                   'tools/win32/bzr_postinstall.py',
351
358
                  ],
352
359
          zipfile='lib/library.zip',
353
 
          data_files=[('lib/help_topics/en', text_topics)],
 
360
          data_files=topics_files + plugins_files,
354
361
          )
355
362
 
356
363
else: