13
if sys.version_info < (2, 4):
14
sys.stderr.write("[ERROR] Not a supported Python version. Need 2.4+\n")
17
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
18
# './setup.py' or the equivalent with another path, should always be at the
19
# start of the path, so this should find the right one...
22
def get_long_description():
23
dirname = os.path.dirname(__file__)
24
readme = os.path.join(dirname, 'README')
25
f = open(readme, 'rb')
33
15
# META INFORMATION FOR SETUP
34
# see http://docs.python.org/dist/meta-data.html
37
'version': bzrlib.__version__,
38
'author': 'Canonical Ltd',
39
'author_email': 'bazaar@lists.canonical.com',
40
'url': 'http://www.bazaar-vcs.org/',
41
'description': 'Friendly distributed version control system',
42
'license': 'GNU GPL v2',
43
'download_url': 'http://bazaar-vcs.org/Download',
44
'long_description': get_long_description(),
46
'Development Status :: 6 - Mature',
47
'Environment :: Console',
48
'Intended Audience :: Developers',
49
'Intended Audience :: System Administrators',
50
'License :: OSI Approved :: GNU General Public License (GPL)',
51
'Operating System :: Microsoft :: Windows',
52
'Operating System :: OS Independent',
53
'Operating System :: POSIX',
54
'Programming Language :: Python',
55
'Programming Language :: C',
56
'Topic :: Software Development :: Version Control',
17
META_INFO = {'name': 'bzr',
18
'version': bzrlib.__version__,
19
'author': 'Canonical Ltd',
20
'author_email': 'bazaar@lists.canonical.com',
21
'url': 'http://www.bazaar-vcs.org/',
22
'description': 'Friendly distributed version control system',
23
'license': 'GNU GPL v2',
60
26
# The list of packages is automatically generated later. Add other things
61
27
# that are part of BZRLIB here.
64
30
PKG_DATA = {# install files from selftest suite
65
31
'package_data': {'bzrlib': ['doc/api/*.txt',
66
32
'tests/test_patches_data/*',
67
'help_topics/en/*.txt',
36
######################################################################
37
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
38
# including bzrlib.help
41
version_info = sys.version_info
42
except AttributeError:
43
version_info = 1, 5 # 1.5 or older
45
REINVOKE = "__BZR_REINVOKE"
47
KNOWN_PYTHONS = ('python2.4',)
49
if version_info < NEED_VERS:
50
if not os.environ.has_key(REINVOKE):
51
# mutating os.environ doesn't work in old Pythons
52
os.putenv(REINVOKE, "1")
53
for python in KNOWN_PYTHONS:
55
os.execvp(python, [python] + sys.argv)
58
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
59
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
61
if getattr(os, "unsetenv", None) is not None:
72
65
def get_bzrlib_packages():
73
66
"""Recurse through the bzrlib directory, and extract the package names"""
155
148
########################
157
150
command_classes = {'install_scripts': my_install_scripts,
159
from distutils import log
160
from distutils.errors import CCompilerError, DistutilsPlatformError
161
from distutils.extension import Extension
164
154
from Pyrex.Distutils import build_ext
165
155
except ImportError:
167
156
# try to build the extension from the prior generated source.
169
print ("The python package 'Pyrex' is not available."
170
" If the .c files are available,")
171
print ("they will be built,"
172
" but modifying the .pyx files will not rebuild them.")
157
print ("Pyrex not available, while bzr will build, "
158
"you cannot modify the C extensions.")
174
159
from distutils.command.build_ext import build_ext
160
from distutils.extension import Extension
162
Extension("bzrlib.compiled.dirstate_helpers",
163
["bzrlib/compiled/dirstate_helpers.c"],
179
class build_ext_if_possible(build_ext):
184
except DistutilsPlatformError, e:
186
log.warn('Extensions cannot be built, '
187
'will use the Python versions instead')
189
def build_extension(self, ext):
191
build_ext.build_extension(self, ext)
192
except CCompilerError:
193
log.warn('Building of "%s" extension failed, '
194
'will use the Python version instead' % (ext.name,))
197
# Override the build_ext if we have Pyrex available
198
command_classes['build_ext'] = build_ext_if_possible
199
unavailable_files = []
202
def add_pyrex_extension(module_name, **kwargs):
203
"""Add a pyrex module to build.
205
This will use Pyrex to auto-generate the .c file if it is available.
206
Otherwise it will fall back on the .c file. If the .c file is not
207
available, it will warn, and not add anything.
209
You can pass any extra options to Extension through kwargs. One example is
212
:param module_name: The python path to the module. This will be used to
213
determine the .pyx and .c files to use.
215
path = module_name.replace('.', '/')
216
pyrex_name = path + '.pyx'
219
ext_modules.append(Extension(module_name, [pyrex_name]))
221
if not os.path.isfile(c_name):
222
unavailable_files.append(c_name)
224
ext_modules.append(Extension(module_name, [c_name]))
227
add_pyrex_extension('bzrlib._dirstate_helpers_c')
228
add_pyrex_extension('bzrlib._knit_load_data_c')
229
ext_modules.append(Extension('bzrlib._patiencediff_c', ['bzrlib/_patiencediff_c.c']))
232
if unavailable_files:
233
print 'C extension(s) not found:'
234
print ' %s' % ('\n '.join(unavailable_files),)
235
print 'The python versions will be used instead.'
168
from distutils.extension import Extension
170
Extension("bzrlib.compiled.dirstate_helpers",
171
["bzrlib/compiled/dirstate_helpers.pyx"],
175
command_classes['build_ext'] = build_ext
239
177
if 'bdist_wininst' in sys.argv:
242
for root, dirs, files in os.walk('doc'):
245
if (os.path.splitext(f)[1] in ('.html','.css','.png','.pdf')
246
or f == 'quick-start-summary.svg'):
247
r.append(os.path.join(root, f))
251
target = os.path.join('Doc\\Bazaar', relative)
253
target = 'Doc\\Bazaar'
254
docs.append((target, r))
180
docs = glob.glob('doc/*.htm') + ['doc/default.css']
257
181
# python's distutils-based win32 installer
258
182
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
259
'ext_modules': ext_modules,
261
'data_files': find_docs(),
262
# for building pyrex extensions
263
'cmdclass': {'build_ext': build_ext_if_possible},
184
'data_files': [('Doc/Bazaar', docs)],
266
187
ARGS.update(META_INFO)
298
218
comments = META_INFO['description'],
301
packages = BZRLIB['packages']
302
packages.remove('bzrlib')
303
packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
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)
311
additional_packages = set()
221
additional_packages = []
312
222
if sys.version.startswith('2.4'):
313
223
# adding elementtree package
314
additional_packages.add('elementtree')
224
additional_packages.append('elementtree')
315
225
elif sys.version.startswith('2.5'):
316
additional_packages.add('xml.etree')
226
additional_packages.append('xml.etree')
319
229
warnings.warn('Unknown Python version.\n'
320
230
'Please check setup.py script for compatibility.')
321
# email package from std python library use lazy import,
322
# so we need to explicitly add all package
323
additional_packages.add('email')
325
# text files for help topis
326
text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
327
topics_files = [('lib/help_topics/en', text_topics)]
331
for root, dirs, files in os.walk('bzrlib/plugins'):
334
if not i.endswith('.py'):
336
if i == '__init__.py' and root == 'bzrlib/plugins':
338
x.append(os.path.join(root, i))
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)
349
options_list = {"py2exe": {"packages": packages + list(additional_packages),
350
"includes": includes + mods,
351
"excludes": ["Tkinter", "medusa", "tools"],
232
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
234
"excludes": ["Tkinter", "medusa"],
352
235
"dist_dir": "win32_bzr.exe",
357
240
'tools/win32/bzr_postinstall.py',
359
zipfile='lib/library.zip',
360
data_files=topics_files + plugins_files,
242
zipfile='lib/library.zip')
364
# ad-hoc for easy_install
366
if not 'bdist_egg' in sys.argv:
367
# generate and install bzr.1 only with plain install, not easy_install one
368
DATA_FILES = [('man/man1', ['bzr.1'])]
371
246
ARGS = {'scripts': ['bzr'],
372
'data_files': DATA_FILES,
247
'data_files': [('man/man1', ['bzr.1'])],
373
248
'cmdclass': command_classes,
374
249
'ext_modules': ext_modules,
377
252
ARGS.update(META_INFO)
378
253
ARGS.update(BZRLIB)
379
254
ARGS.update(PKG_DATA)