/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: Andrew Bennetts
  • Date: 2008-03-14 14:59:07 UTC
  • mfrom: (3272 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3308.
  • Revision ID: andrew.bennetts@canonical.com-20080314145907-c2avcip1jcqlk77d
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import os
10
10
import sys
11
11
 
 
12
if sys.version_info < (2, 4):
 
13
    sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
 
14
    sys.exit(1)
 
15
 
12
16
import bzrlib
13
17
 
14
18
##
34
38
                                       ]},
35
39
           }
36
40
 
37
 
######################################################################
38
 
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
39
 
# including bzrlib.help
40
 
 
41
 
try:
42
 
    version_info = sys.version_info
43
 
except AttributeError:
44
 
    version_info = 1, 5 # 1.5 or older
45
 
 
46
 
REINVOKE = "__BZR_REINVOKE"
47
 
NEED_VERS = (2, 4)
48
 
KNOWN_PYTHONS = ('python2.4',)
49
 
 
50
 
if version_info < NEED_VERS:
51
 
    if not os.environ.has_key(REINVOKE):
52
 
        # mutating os.environ doesn't work in old Pythons
53
 
        os.putenv(REINVOKE, "1")
54
 
        for python in KNOWN_PYTHONS:
55
 
            try:
56
 
                os.execvp(python, [python] + sys.argv)
57
 
            except OSError:
58
 
                pass
59
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
60
 
    sys.stderr.write("  (need %d.%d or later)" % NEED_VERS)
61
 
    sys.stderr.write('\n')
62
 
    sys.exit(1)
63
 
if getattr(os, "unsetenv", None) is not None:
64
 
    os.unsetenv(REINVOKE)
65
 
 
66
41
 
67
42
def get_bzrlib_packages():
68
43
    """Recurse through the bzrlib directory, and extract the package names"""
237
212
        for root, dirs, files in os.walk('doc'):
238
213
            r = []
239
214
            for f in files:
240
 
                if os.path.splitext(f)[1] in ('.html','.css','.png','.pdf'):
 
215
                if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
 
216
                    or f == 'quick-start-summary.svg'):
241
217
                    r.append(os.path.join(root, f))
242
218
            if r:
243
219
                relative = root[4:]
264
240
    setup(**ARGS)
265
241
 
266
242
elif 'py2exe' in sys.argv:
 
243
    import glob
267
244
    # py2exe setup
268
245
    import py2exe
269
246
 
291
268
                                     comments = META_INFO['description'],
292
269
                                    )
293
270
 
294
 
    additional_packages =  []
 
271
    packages = BZRLIB['packages']
 
272
    packages.remove('bzrlib')
 
273
    packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
 
274
    includes = []
 
275
    for i in glob.glob('bzrlib\\*.py'):
 
276
        module = i[:-3].replace('\\', '.')
 
277
        if module.endswith('__init__'):
 
278
            module = module[:-len('__init__')]
 
279
        includes.append(module)
 
280
 
 
281
    additional_packages = set()
295
282
    if sys.version.startswith('2.4'):
296
283
        # adding elementtree package
297
 
        additional_packages.append('elementtree')
 
284
        additional_packages.add('elementtree')
298
285
    elif sys.version.startswith('2.5'):
299
 
        additional_packages.append('xml.etree')
 
286
        additional_packages.add('xml.etree')
300
287
    else:
301
288
        import warnings
302
289
        warnings.warn('Unknown Python version.\n'
303
290
                      'Please check setup.py script for compatibility.')
304
291
    # email package from std python library use lazy import,
305
292
    # so we need to explicitly add all package
306
 
    additional_packages.append('email')
 
293
    additional_packages.add('email')
307
294
 
308
295
    # text files for help topis
309
 
    import glob
310
296
    text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
311
 
 
312
 
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
313
 
                                           additional_packages,
 
297
    topics_files = [('lib/help_topics/en', text_topics)]
 
298
 
 
299
    # built-in plugins
 
300
    plugins_files = []
 
301
    for root, dirs, files in os.walk('bzrlib/plugins'):
 
302
        x = []
 
303
        for i in files:
 
304
            if not i.endswith('.py'):
 
305
                continue
 
306
            if i == '__init__.py' and root == 'bzrlib/plugins':
 
307
                continue
 
308
            x.append(os.path.join(root, i))
 
309
        if x:
 
310
            target_dir = root[len('bzrlib/'):]  # install to 'plugins/...'
 
311
            plugins_files.append((target_dir, x))
 
312
    # find modules for built-in plugins
 
313
    import tools.package_mf
 
314
    mf = tools.package_mf.CustomModuleFinder()
 
315
    mf.run_package('bzrlib/plugins')
 
316
    packs, mods = mf.get_result()
 
317
    additional_packages.update(packs)
 
318
 
 
319
    options_list = {"py2exe": {"packages": packages + list(additional_packages),
 
320
                               "includes": includes + mods,
314
321
                               "excludes": ["Tkinter", "medusa", "tools"],
315
322
                               "dist_dir": "win32_bzr.exe",
316
323
                              },
320
327
                   'tools/win32/bzr_postinstall.py',
321
328
                  ],
322
329
          zipfile='lib/library.zip',
323
 
          data_files=[('lib/help_topics/en', text_topics)],
 
330
          data_files=topics_files + plugins_files,
324
331
          )
325
332
 
326
333
else: