1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
#! /usr/bin/env python
"""Installation script for bzr.
Run it with
'./setup.py install', or
'./setup.py --help' for more options
"""
##
# META INFORMATION FOR SETUP
META_INFO = {'name': 'bzr',
'version': '0.9pre',
'author': 'Canonical Ltd',
'author_email': 'bazaar-ng@lists.ubuntu.com',
'url': 'http://www.bazaar-vcs.org/',
'description': 'Friendly distributed version control system',
'license': 'GNU GPL v2',
}
BZRLIB = {'packages': ['bzrlib',
'bzrlib.benchmarks',
'bzrlib.bundle',
'bzrlib.bundle.serializer',
'bzrlib.doc',
'bzrlib.doc.api',
'bzrlib.export',
'bzrlib.plugins',
'bzrlib.plugins.launchpad',
'bzrlib.store',
'bzrlib.store.revision',
'bzrlib.store.versioned',
'bzrlib.tests',
'bzrlib.tests.blackbox',
'bzrlib.tests.branch_implementations',
'bzrlib.tests.bzrdir_implementations',
'bzrlib.tests.interrepository_implementations',
'bzrlib.tests.interversionedfile_implementations',
'bzrlib.tests.repository_implementations',
'bzrlib.tests.revisionstore_implementations',
'bzrlib.tests.workingtree_implementations',
'bzrlib.transport',
'bzrlib.transport.http',
'bzrlib.ui',
'bzrlib.util',
'bzrlib.util.configobj',
'bzrlib.util.effbot.org',
'bzrlib.util.elementtree',
],
}
##
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
# including bzrlib.help
import os
import sys
try:
version_info = sys.version_info
except AttributeError:
version_info = 1, 5 # 1.5 or older
REINVOKE = "__BZR_REINVOKE"
NEED_VERS = (2, 4)
KNOWN_PYTHONS = ('python2.4',)
if version_info < NEED_VERS:
if not os.environ.has_key(REINVOKE):
# mutating os.environ doesn't work in old Pythons
os.putenv(REINVOKE, "1")
for python in KNOWN_PYTHONS:
try:
os.execvp(python, [python] + sys.argv)
except OSError:
pass
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS
sys.exit(1)
if hasattr(os, "unsetenv"):
os.unsetenv(REINVOKE)
from distutils.core import setup
from distutils.command.install_scripts import install_scripts
from distutils.command.build import build
###############################
# Overridden distutils actions
###############################
class my_install_scripts(install_scripts):
""" Customized install_scripts distutils action.
Create bzr.bat for win32.
"""
def run(self):
import os
import sys
install_scripts.run(self) # standard action
if sys.platform == "win32":
try:
scripts_dir = self.install_dir
script_path = os.path.join(scripts_dir, "bzr")
batch_str = "@%s %s %%*\n" % (sys.executable, script_path)
batch_path = script_path + ".bat"
f = file(batch_path, "w")
f.write(batch_str)
f.close()
print "Created:", batch_path
except Exception, e:
print "ERROR: Unable to create %s: %s" % (batch_path, e)
class bzr_build(build):
"""Customized build distutils action.
Generate bzr.1.
"""
def run(self):
build.run(self)
import generate_docs
generate_docs.main(argv=["bzr", "man"])
########################
## Setup
########################
if not ('py2exe' in sys.argv):
# std setup
ARGS = {'scripts': ['bzr'],
'data_files': [('man/man1', ['bzr.1'])],
# install the txt files from bzrlib.doc.api.
'package_data': {'bzrlib': ['doc/api/*.txt']},
}
# for python-based installer we don't need to use custom cmdclasses
if not ('bdist_wininst' in sys.argv):
ARGS['cmdclass'] = {'build': bzr_build,
'install_scripts': my_install_scripts,
}
else:
# but need to add postinstall script
ARGS['scripts'].append('tools/win32/bzr-win32-bdist-postinstall.py')
ARGS.update(META_INFO)
ARGS.update(BZRLIB)
print ARGS
setup(**ARGS)
else:
# py2exe setup
import py2exe
# pick real bzr version
import bzrlib
version_number = []
for i in bzrlib.version_info[:4]:
try:
i = int(i)
except ValueError:
i = 0
version_number.append(str(i))
version_str = '.'.join(version_number)
target = py2exe.build_exe.Target(script = "bzr",
dest_base = "bzr",
icon_resources = [(0,'bzr.ico')],
name = META_INFO['name'],
version = version_str,
description = META_INFO['description'],
author = META_INFO['author'],
copyright = "(c) Canonical Ltd, 2005-2006",
company_name = "Canonical Ltd.",
comments = META_INFO['description'],
)
options_list = {"py2exe": {"packages": BZRLIB['packages'] +
['elementtree'],
"dist_dir": "win32_bzr.exe",
},
}
setup(options=options_list,
console=[target,
'tools/win32/bzr_postinstall.py',
'tools/bzr_test_dependencies.py',
],
zipfile='lib/library.zip')
|