19
19
# NOTE: The directory containing setup.py, whether run by 'python setup.py' or
20
20
# './setup.py' or the equivalent with another path, should always be at the
21
21
# start of the path, so this should find the right one...
24
24
def get_long_description():
25
25
dirname = os.path.dirname(__file__)
35
35
# META INFORMATION FOR SETUP
36
36
# see http://docs.python.org/dist/meta-data.html
39
'version': bzrlib.__version__,
39
'version': breezy.__version__,
40
40
'author': 'Canonical Ltd',
41
41
'author_email': 'bazaar@lists.canonical.com',
42
'maintainer': 'Breezy Developers',
42
43
'url': 'http://bazaar.canonical.com/',
43
44
'description': 'Friendly distributed version control system',
44
45
'license': 'GNU GPL v2',
66
67
PKG_DATA = {# install files from selftest suite
67
'package_data': {'bzrlib': ['doc/api/*.txt',
68
'package_data': {'breezy': ['doc/api/*.txt',
68
69
'tests/test_patches_data/*',
69
70
'help_topics/en/*.txt',
70
71
'tests/ssl_certs/ca.crt',
77
for filepath in glob.glob("bzrlib/locale/*/LC_MESSAGES/*.mo"):
78
langfile = filepath[len("bzrlib/locale/"):]
78
for filepath in glob.glob("breezy/locale/*/LC_MESSAGES/*.mo"):
79
langfile = filepath[len("breezy/locale/"):]
79
80
targetpath = os.path.dirname(os.path.join("share/locale", langfile))
80
81
I18N_FILES.append((targetpath, [filepath]))
82
def get_bzrlib_packages():
83
"""Recurse through the bzrlib directory, and extract the package names"""
83
def get_breezy_packages():
84
"""Recurse through the breezy directory, and extract the package names"""
86
base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
87
base_path = os.path.dirname(os.path.abspath(breezy.__file__))
87
88
for root, dirs, files in os.walk(base_path):
88
89
if '__init__.py' in files:
89
90
assert root.startswith(base_path)
90
# Get just the path below bzrlib
91
# Get just the path below breezy
91
92
package_path = root[len(base_path):]
92
93
# Remove leading and trailing slashes
93
94
package_path = package_path.strip('\\/')
94
95
if not package_path:
95
package_name = 'bzrlib'
96
package_name = 'breezy'
97
package_name = ('bzrlib.' +
98
package_name = ('breezy.' +
98
99
package_path.replace('/', '.').replace('\\', '.'))
99
100
packages.append(package_name)
100
101
return sorted(packages)
103
BZRLIB['packages'] = get_bzrlib_packages()
104
BZRLIB['packages'] = get_breezy_packages()
106
107
from distutils import log
117
118
class my_install_scripts(install_scripts):
118
119
""" Customized install_scripts distutils action.
119
Create bzr.bat for win32.
120
Create brz.bat for win32.
122
123
install_scripts.run(self) # standard action
126
127
scripts_dir = os.path.join(sys.prefix, 'Scripts')
127
128
script_path = self._quoted_path(os.path.join(scripts_dir,
129
130
python_exe = self._quoted_path(sys.executable)
130
131
args = self._win_batch_args()
131
132
batch_str = "@%s %s %s" % (python_exe, script_path, args)
132
batch_path = os.path.join(self.install_dir, "bzr.bat")
133
batch_path = os.path.join(self.install_dir, "brz.bat")
133
134
f = file(batch_path, "w")
134
135
f.write(batch_str)
168
169
from tools import generate_docs
169
generate_docs.main(argv=["bzr", "man"])
170
generate_docs.main(argv=["brz", "man"])
172
173
########################
174
175
########################
176
from bzrlib.bzr_distutils import build_mo
177
from breezy.bzr_distutils import build_mo
178
179
command_classes = {'install_scripts': my_install_scripts,
179
180
'build': bzr_build,
287
288
define_macros=define_macros, libraries=libraries))
290
add_pyrex_extension('bzrlib._annotator_pyx')
291
add_pyrex_extension('bzrlib._bencode_pyx')
292
add_pyrex_extension('bzrlib._chunks_to_lines_pyx')
293
add_pyrex_extension('bzrlib._groupcompress_pyx',
294
extra_source=['bzrlib/diff-delta.c'])
295
add_pyrex_extension('bzrlib._knit_load_data_pyx')
296
add_pyrex_extension('bzrlib._known_graph_pyx')
297
add_pyrex_extension('bzrlib._rio_pyx')
291
add_pyrex_extension('breezy._annotator_pyx')
292
add_pyrex_extension('breezy._bencode_pyx')
293
add_pyrex_extension('breezy._chunks_to_lines_pyx')
294
add_pyrex_extension('breezy._groupcompress_pyx',
295
extra_source=['breezy/diff-delta.c'])
296
add_pyrex_extension('breezy._knit_load_data_pyx')
297
add_pyrex_extension('breezy._known_graph_pyx')
298
add_pyrex_extension('breezy._rio_pyx')
298
299
if sys.platform == 'win32':
299
add_pyrex_extension('bzrlib._dirstate_helpers_pyx',
300
add_pyrex_extension('breezy._dirstate_helpers_pyx',
300
301
libraries=['Ws2_32'])
301
add_pyrex_extension('bzrlib._walkdirs_win32')
302
add_pyrex_extension('breezy._walkdirs_win32')
303
304
if have_pyrex and pyrex_version_info == LooseVersion("0.9.4.1"):
304
305
# Pyrex 0.9.4.1 fails to compile this extension correctly
307
308
# which is NULL safe with PY_DECREF which is not.)
308
309
# <https://bugs.launchpad.net/bzr/+bug/449372>
309
310
# <https://bugs.launchpad.net/bzr/+bug/276868>
310
print('Cannot build extension "bzrlib._dirstate_helpers_pyx" using')
311
print('Cannot build extension "breezy._dirstate_helpers_pyx" using')
311
312
print('your version of pyrex "%s". Please upgrade your pyrex'
312
313
% (pyrex_version,))
313
314
print('install. For now, the non-compiled (python) version will')
314
315
print('be used instead.')
316
add_pyrex_extension('bzrlib._dirstate_helpers_pyx')
317
add_pyrex_extension('bzrlib._readdir_pyx')
318
add_pyrex_extension('bzrlib._chk_map_pyx')
319
ext_modules.append(Extension('bzrlib._patiencediff_c',
320
['bzrlib/_patiencediff_c.c']))
317
add_pyrex_extension('breezy._dirstate_helpers_pyx')
318
add_pyrex_extension('breezy._readdir_pyx')
319
add_pyrex_extension('breezy._chk_map_pyx')
320
ext_modules.append(Extension('breezy._patiencediff_c',
321
['breezy/_patiencediff_c.c']))
321
322
if have_pyrex and pyrex_version_info < LooseVersion("0.9.6.3"):
323
324
print('Your Pyrex/Cython version %s is too old to build the simple_set' % (
330
331
# We only need 0.9.6.3 to build _simple_set_pyx, but static_tuple depends
332
add_pyrex_extension('bzrlib._simple_set_pyx')
333
ext_modules.append(Extension('bzrlib._static_tuple_c',
334
['bzrlib/_static_tuple_c.c']))
335
add_pyrex_extension('bzrlib._btree_serializer_pyx')
333
add_pyrex_extension('breezy._simple_set_pyx')
334
ext_modules.append(Extension('breezy._static_tuple_c',
335
['breezy/_static_tuple_c.c']))
336
add_pyrex_extension('breezy._btree_serializer_pyx')
338
339
if unavailable_files:
362
363
# TBZR points to the TBZR directory
363
364
tbzr_root = os.environ["TBZR"]
365
# Ensure tbzrlib itself is on sys.path
366
# Ensure tbreezy itself is on sys.path
366
367
sys.path.append(tbzr_root)
368
packages.append("tbzrlib")
369
packages.append("tbreezy")
370
371
# collect up our icons.
371
372
cwd = os.getcwd()
372
ico_root = os.path.join(tbzr_root, 'tbzrlib', 'resources')
373
ico_root = os.path.join(tbzr_root, 'tbreezy', 'resources')
373
374
icos = [] # list of (path_root, relative_ico_path)
374
# First always bzr's icon and its in the root of the bzr tree.
375
icos.append(('', 'bzr.ico'))
375
# First always brz's icon and its in the root of the brz tree.
376
icos.append(('', 'brz.ico'))
376
377
for root, dirs, files in os.walk(ico_root):
377
378
icos.extend([(ico_root, os.path.join(root, f)[len(ico_root)+1:])
378
379
for f in files if f.endswith('.ico')])
491
492
def get_fastimport_py2exe_info(includes, excludes, packages):
492
493
# This is the python-fastimport package, not to be confused with the
493
# bzr-fastimport plugin.
494
# brz-fastimport plugin.
494
495
packages.append('fastimport')
507
508
relative = root[4:]
509
target = os.path.join('Doc\\Bazaar', relative)
510
target = os.path.join('Doc\\Breezy', relative)
511
target = 'Doc\\Bazaar'
512
target = 'Doc\\Breezy'
512
513
docs.append((target, r))
515
516
# python's distutils-based win32 installer
516
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
517
ARGS = {'scripts': ['brz', 'tools/win32/brz-win32-bdist-postinstall.py'],
517
518
'ext_modules': ext_modules,
519
520
'data_files': find_docs(),
574
575
self.outfiles.extend([f + 'o' for f in compile_names])
575
576
# end of class install_data_with_bytecompile
577
target = py2exe.build_exe.Target(script = "bzr",
579
icon_resources = [(0,'bzr.ico')],
578
target = py2exe.build_exe.Target(script = "brz",
580
icon_resources = [(0,'brz.ico')],
580
581
name = META_INFO['name'],
581
582
version = version_str,
582
583
description = META_INFO['description'],
589
590
gui_target.dest_base = "bzrw"
591
592
packages = BZRLIB['packages']
592
packages.remove('bzrlib')
593
packages = [i for i in packages if not i.startswith('bzrlib.plugins')]
593
packages.remove('breezy')
594
packages = [i for i in packages if not i.startswith('breezy.plugins')]
595
for i in glob.glob('bzrlib\\*.py'):
596
for i in glob.glob('breezy\\*.py'):
596
597
module = i[:-3].replace('\\', '.')
597
598
if module.endswith('__init__'):
598
599
module = module[:-len('__init__')]
633
634
excludes.append("email.MIME" + oldname)
635
636
# text files for help topis
636
text_topics = glob.glob('bzrlib/help_topics/en/*.txt')
637
text_topics = glob.glob('breezy/help_topics/en/*.txt')
637
638
topics_files = [('lib/help_topics/en', text_topics)]
639
640
# built-in plugins
642
643
# which hard-codes the list of plugins, gets more upset if modules are
644
645
plugins = None # will be a set after plugin sniffing...
645
for root, dirs, files in os.walk('bzrlib/plugins'):
646
if root == 'bzrlib/plugins':
646
for root, dirs, files in os.walk('breezy/plugins'):
647
if root == 'breezy/plugins':
647
648
plugins = set(dirs)
648
649
# We ship plugins as normal files on the file-system - however,
649
650
# the build process can cause *some* of these plugin files to end
651
652
# library.zip, and then saw import errors related to that as the
652
653
# rest of the svn plugin wasn't. So we tell py2exe to leave the
653
654
# plugins out of the .zip file
654
excludes.extend(["bzrlib.plugins." + d for d in dirs])
655
excludes.extend(["breezy.plugins." + d for d in dirs])
657
658
# Throw away files we don't want packaged. Note that plugins may
660
661
ext = os.path.splitext(i)[1]
661
662
if ext.endswith('~') or ext in [".pyc", ".swp"]:
663
if i == '__init__.py' and root == 'bzrlib/plugins':
664
if i == '__init__.py' and root == 'breezy/plugins':
665
666
x.append(os.path.join(root, i))
667
target_dir = root[len('bzrlib/'):] # install to 'plugins/...'
668
target_dir = root[len('breezy/'):] # install to 'plugins/...'
668
669
plugins_files.append((target_dir, x))
669
670
# find modules for built-in plugins
670
671
import tools.package_mf
671
672
mf = tools.package_mf.CustomModuleFinder()
672
mf.run_package('bzrlib/plugins')
673
mf.run_package('breezy/plugins')
673
674
packs, mods = mf.get_result()
674
675
additional_packages.update(packs)
675
676
includes.extend(mods)
761
762
# ad-hoc for easy_install
763
764
if not 'bdist_egg' in sys.argv:
764
# generate and install bzr.1 only with plain install, not the
765
# generate and install brz.1 only with plain install, not the
765
766
# easy_install one
766
DATA_FILES = [('man/man1', ['bzr.1'])]
767
DATA_FILES = [('man/man1', ['brz.1'])]
768
769
DATA_FILES = DATA_FILES + I18N_FILES
770
ARGS = {'scripts': ['bzr'],
771
ARGS = {'scripts': ['brz'],
771
772
'data_files': DATA_FILES,
772
773
'cmdclass': command_classes,
773
774
'ext_modules': ext_modules,