~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 16:12:57 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731161257-91a231523255332c
new official bzr.ico

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 './setup.py --help' for more options
7
7
"""
8
8
 
9
 
import os
10
 
import sys
11
 
 
12
 
import bzrlib
13
 
 
14
9
##
15
10
# META INFORMATION FOR SETUP
16
11
 
17
12
META_INFO = {'name':         'bzr',
18
 
             'version':      bzrlib.__version__,
 
13
             'version':      '<unknown>',
19
14
             'author':       'Canonical Ltd',
20
 
             'author_email': 'bazaar@lists.canonical.com',
 
15
             'author_email': 'bazaar-ng@lists.ubuntu.com',
21
16
             'url':          'http://www.bazaar-vcs.org/',
22
17
             'description':  'Friendly distributed version control system',
23
18
             'license':      'GNU GPL v2',
24
19
            }
25
20
 
26
 
# The list of packages is automatically generated later. Add other things
27
 
# that are part of BZRLIB here.
28
 
BZRLIB = {}
 
21
BZRLIB = {'packages': ['bzrlib',
 
22
                       'bzrlib.benchmarks',
 
23
                       'bzrlib.bundle',
 
24
                       'bzrlib.bundle.serializer',
 
25
                       'bzrlib.doc',
 
26
                       'bzrlib.doc.api',
 
27
                       'bzrlib.export',
 
28
                       'bzrlib.plugins',
 
29
                       'bzrlib.plugins.launchpad',
 
30
                       'bzrlib.store',
 
31
                       'bzrlib.store.revision',
 
32
                       'bzrlib.store.versioned',
 
33
                       'bzrlib.tests',
 
34
                       'bzrlib.tests.blackbox',
 
35
                       'bzrlib.tests.branch_implementations',
 
36
                       'bzrlib.tests.bzrdir_implementations',
 
37
                       'bzrlib.tests.interrepository_implementations',
 
38
                       'bzrlib.tests.interversionedfile_implementations',
 
39
                       'bzrlib.tests.repository_implementations',
 
40
                       'bzrlib.tests.revisionstore_implementations',
 
41
                       'bzrlib.tests.workingtree_implementations',
 
42
                       'bzrlib.transport',
 
43
                       'bzrlib.transport.http',
 
44
                       'bzrlib.ui',
 
45
                       'bzrlib.util',
 
46
                       'bzrlib.util.configobj',
 
47
                       'bzrlib.util.effbot.org',
 
48
                       'bzrlib.util.elementtree',
 
49
                      ],
 
50
         }
29
51
 
30
 
PKG_DATA = {# install files from selftest suite
31
 
            'package_data': {'bzrlib': ['doc/api/*.txt',
32
 
                                        'tests/test_patches_data/*',
33
 
                                       ]},
34
 
           }
35
52
 
36
53
######################################################################
37
54
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
38
55
# including bzrlib.help
39
56
 
 
57
import os
 
58
import sys
 
59
 
40
60
try:
41
61
    version_info = sys.version_info
42
62
except AttributeError:
58
78
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
59
79
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
60
80
    sys.exit(1)
61
 
if getattr(os, "unsetenv", None) is not None:
 
81
if hasattr(os, "unsetenv"):
62
82
    os.unsetenv(REINVOKE)
63
83
 
64
84
 
65
 
def get_bzrlib_packages():
66
 
    """Recurse through the bzrlib directory, and extract the package names"""
67
 
 
68
 
    packages = []
69
 
    base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
70
 
    for root, dirs, files in os.walk(base_path):
71
 
        if '__init__.py' in files:
72
 
            assert root.startswith(base_path)
73
 
            # Get just the path below bzrlib
74
 
            package_path = root[len(base_path):]
75
 
            # Remove leading and trailing slashes
76
 
            package_path = package_path.strip('\\/')
77
 
            if not package_path:
78
 
                package_name = 'bzrlib'
79
 
            else:
80
 
                package_name = ('bzrlib.' +
81
 
                            package_path.replace('/', '.').replace('\\', '.'))
82
 
            packages.append(package_name)
83
 
    return sorted(packages)
84
 
 
85
 
 
86
 
BZRLIB['packages'] = get_bzrlib_packages()
87
 
 
88
 
 
89
85
from distutils.core import setup
90
86
from distutils.command.install_scripts import install_scripts
91
87
from distutils.command.build import build
99
95
    Create bzr.bat for win32.
100
96
    """
101
97
    def run(self):
 
98
        import os
 
99
        import sys
 
100
 
102
101
        install_scripts.run(self)   # standard action
103
102
 
104
103
        if sys.platform == "win32":
124
123
            return path
125
124
 
126
125
    def _win_batch_args(self):
127
 
        from bzrlib.win32utils import winver
128
 
        if winver == 'Windows NT':
 
126
        if os.name == 'nt':
129
127
            return '%*'
130
128
        else:
131
129
            return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
147
145
## Setup
148
146
########################
149
147
 
150
 
command_classes = {'install_scripts': my_install_scripts,
151
 
                   'build': bzr_build}
152
 
from distutils.extension import Extension
153
 
ext_modules = []
154
 
try:
155
 
    from Pyrex.Distutils import build_ext
156
 
except ImportError:
157
 
    have_pyrex = False
158
 
    # try to build the extension from the prior generated source.
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
165
 
    from distutils.command.build_ext import build_ext
166
 
else:
167
 
    have_pyrex = True
168
 
# Override the build_ext if we have Pyrex available
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
 
148
def get_bzr_version():
 
149
    import bzrlib
 
150
    return bzrlib.__version__
207
151
 
208
152
 
209
153
if 'bdist_wininst' in sys.argv:
210
154
    import glob
211
155
    # doc files
212
156
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
213
 
    dev_docs = glob.glob('doc/developers/*.htm')
214
157
    # python's distutils-based win32 installer
215
158
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
216
 
            'ext_modules': ext_modules,
 
159
            # install the txt files from bzrlib.doc.api.
 
160
            'package_data': {'bzrlib': ['doc/api/*.txt']},
217
161
            # help pages
218
 
            'data_files': [('Doc/Bazaar', docs),
219
 
                           ('Doc/Bazaar/developers', dev_docs),
220
 
                          ],
221
 
            # for building pyrex extensions
222
 
            'cmdclass': {'build_ext': build_ext},
 
162
            'data_files': [('Doc/Bazaar', docs)],
223
163
           }
224
164
 
225
165
    ARGS.update(META_INFO)
 
166
    ARGS.update({'version': get_bzr_version()})
226
167
    ARGS.update(BZRLIB)
227
 
    ARGS.update(PKG_DATA)
228
168
    
229
169
    setup(**ARGS)
230
170
 
251
191
                                     version = version_str,
252
192
                                     description = META_INFO['description'],
253
193
                                     author = META_INFO['author'],
254
 
                                     copyright = "(c) Canonical Ltd, 2005-2007",
 
194
                                     copyright = "(c) Canonical Ltd, 2005-2006",
255
195
                                     company_name = "Canonical Ltd.",
256
196
                                     comments = META_INFO['description'],
257
197
                                    )
258
 
 
259
 
    additional_packages =  []
260
 
    if sys.version.startswith('2.4'):
261
 
        # adding elementtree package
262
 
        additional_packages.append('elementtree')
263
 
    elif sys.version.startswith('2.5'):
264
 
        additional_packages.append('xml.etree')
265
 
    else:
266
 
        import warnings
267
 
        warnings.warn('Unknown Python version.\n'
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')
272
 
 
273
198
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
274
 
                                           additional_packages,
275
 
                               "excludes": ["Tkinter", "medusa", "tools"],
 
199
                                           ['elementtree'],
 
200
                               "excludes": ["Tkinter", "medusa"],
276
201
                               "dist_dir": "win32_bzr.exe",
277
202
                              },
278
203
                   }
286
211
    # std setup
287
212
    ARGS = {'scripts': ['bzr'],
288
213
            'data_files': [('man/man1', ['bzr.1'])],
289
 
            'cmdclass': command_classes,
290
 
            'ext_modules': ext_modules,
 
214
            # install the txt files from bzrlib.doc.api.
 
215
            'package_data': {'bzrlib': ['doc/api/*.txt']},
 
216
            'cmdclass': {'build': bzr_build,
 
217
                         'install_scripts': my_install_scripts,
 
218
                        },
291
219
           }
292
220
    
293
221
    ARGS.update(META_INFO)
 
222
    ARGS.update({'version': get_bzr_version()})
294
223
    ARGS.update(BZRLIB)
295
 
    ARGS.update(PKG_DATA)
296
224
 
297
225
    setup(**ARGS)