45
by Martin Pool
- add setup.py and install instructions |
1 |
#! /usr/bin/env python
|
2 |
||
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
3 |
"""Installation script for bzr.
|
4 |
Run it with
|
|
5 |
'./setup.py install', or
|
|
6 |
'./setup.py --help' for more options
|
|
7 |
"""
|
|
8 |
||
9 |
##
|
|
10 |
# META INFORMATION FOR SETUP
|
|
11 |
||
12 |
META_INFO = {'name': 'bzr', |
|
13 |
'version': '0.9pre', |
|
14 |
'author': 'Canonical Ltd', |
|
15 |
'author_email': 'bazaar-ng@lists.ubuntu.com', |
|
16 |
'url': 'http://www.bazaar-vcs.org/', |
|
17 |
'description': 'Friendly distributed version control system', |
|
18 |
'license': 'GNU GPL v2', |
|
19 |
}
|
|
20 |
||
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 |
}
|
|
51 |
||
52 |
||
53 |
##
|
|
1185.29.5
by Wouter van Heyst
Add reinvocation code to ensure setup.py is run by python2.4 |
54 |
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
|
55 |
# including bzrlib.help
|
|
56 |
||
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
57 |
import os |
58 |
import sys |
|
1185.29.5
by Wouter van Heyst
Add reinvocation code to ensure setup.py is run by python2.4 |
59 |
|
60 |
try: |
|
61 |
version_info = sys.version_info |
|
62 |
except AttributeError: |
|
63 |
version_info = 1, 5 # 1.5 or older |
|
64 |
||
65 |
REINVOKE = "__BZR_REINVOKE" |
|
66 |
NEED_VERS = (2, 4) |
|
67 |
KNOWN_PYTHONS = ('python2.4',) |
|
68 |
||
69 |
if version_info < NEED_VERS: |
|
70 |
if not os.environ.has_key(REINVOKE): |
|
71 |
# mutating os.environ doesn't work in old Pythons
|
|
72 |
os.putenv(REINVOKE, "1") |
|
73 |
for python in KNOWN_PYTHONS: |
|
74 |
try: |
|
75 |
os.execvp(python, [python] + sys.argv) |
|
76 |
except OSError: |
|
77 |
pass
|
|
78 |
print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter" |
|
79 |
print >>sys.stderr, " (need %d.%d or later)" % NEED_VERS |
|
80 |
sys.exit(1) |
|
81 |
if hasattr(os, "unsetenv"): |
|
82 |
os.unsetenv(REINVOKE) |
|
83 |
||
84 |
||
45
by Martin Pool
- add setup.py and install instructions |
85 |
from distutils.core import setup |
1185.23.1
by Aaron Bentley
win32 setup fixes from Belchenko |
86 |
from distutils.command.install_scripts import install_scripts |
1185.29.3
by Wouter van Heyst
Create bzr.1 manpage from setup.py |
87 |
from distutils.command.build import build |
1185.1.40
by Robert Collins
Merge what applied of Alexander Belchenko's win32 patch. |
88 |
|
89 |
###############################
|
|
90 |
# Overridden distutils actions
|
|
91 |
###############################
|
|
92 |
||
1185.23.1
by Aaron Bentley
win32 setup fixes from Belchenko |
93 |
class my_install_scripts(install_scripts): |
94 |
""" Customized install_scripts distutils action.
|
|
1185.1.40
by Robert Collins
Merge what applied of Alexander Belchenko's win32 patch. |
95 |
Create bzr.bat for win32.
|
96 |
"""
|
|
97 |
def run(self): |
|
1185.23.1
by Aaron Bentley
win32 setup fixes from Belchenko |
98 |
import os |
99 |
import sys |
|
100 |
||
101 |
install_scripts.run(self) # standard action |
|
102 |
||
1185.1.40
by Robert Collins
Merge what applied of Alexander Belchenko's win32 patch. |
103 |
if sys.platform == "win32": |
1185.23.1
by Aaron Bentley
win32 setup fixes from Belchenko |
104 |
try: |
105 |
scripts_dir = self.install_dir |
|
106 |
script_path = os.path.join(scripts_dir, "bzr") |
|
107 |
batch_str = "@%s %s %%*\n" % (sys.executable, script_path) |
|
108 |
batch_path = script_path + ".bat" |
|
109 |
f = file(batch_path, "w") |
|
110 |
f.write(batch_str) |
|
111 |
f.close() |
|
112 |
print "Created:", batch_path |
|
113 |
except Exception, e: |
|
114 |
print "ERROR: Unable to create %s: %s" % (batch_path, e) |
|
1185.1.40
by Robert Collins
Merge what applied of Alexander Belchenko's win32 patch. |
115 |
|
116 |
||
1185.29.3
by Wouter van Heyst
Create bzr.1 manpage from setup.py |
117 |
class bzr_build(build): |
118 |
"""Customized build distutils action.
|
|
119 |
Generate bzr.1.
|
|
120 |
"""
|
|
121 |
def run(self): |
|
122 |
build.run(self) |
|
123 |
||
1551.3.11
by Aaron Bentley
Merge from Robert |
124 |
import generate_docs |
125 |
generate_docs.main(argv=["bzr", "man"]) |
|
1185.29.3
by Wouter van Heyst
Create bzr.1 manpage from setup.py |
126 |
|
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
127 |
|
1185.1.40
by Robert Collins
Merge what applied of Alexander Belchenko's win32 patch. |
128 |
########################
|
129 |
## Setup
|
|
130 |
########################
|
|
131 |
||
1860.1.2
by Alexander Belchenko
setup.py: |
132 |
if 'bdist_wininst' in sys.argv: |
1860.1.3
by Alexander Belchenko
python-installer: |
133 |
import glob |
134 |
# doc files
|
|
135 |
docs = glob.glob('doc/*.htm') + ['doc/default.css'] |
|
1860.1.2
by Alexander Belchenko
setup.py: |
136 |
# python's distutils-based win32 installer
|
137 |
ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'], |
|
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
138 |
# install the txt files from bzrlib.doc.api.
|
139 |
'package_data': {'bzrlib': ['doc/api/*.txt']}, |
|
1860.1.3
by Alexander Belchenko
python-installer: |
140 |
# help pages
|
1861.2.6
by Alexander Belchenko
branding: change Bazaar-NG to Bazaar |
141 |
'data_files': [('Doc/Bazaar', docs)], |
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
142 |
}
|
1821.1.2
by Alexander Belchenko
resurrected python's distutils based installer for win32 |
143 |
|
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
144 |
ARGS.update(META_INFO) |
145 |
ARGS.update(BZRLIB) |
|
146 |
||
147 |
setup(**ARGS) |
|
148 |
||
1860.1.2
by Alexander Belchenko
setup.py: |
149 |
elif 'py2exe' in sys.argv: |
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
150 |
# py2exe setup
|
151 |
import py2exe |
|
152 |
||
153 |
# pick real bzr version
|
|
154 |
import bzrlib |
|
155 |
||
156 |
version_number = [] |
|
157 |
for i in bzrlib.version_info[:4]: |
|
158 |
try: |
|
159 |
i = int(i) |
|
160 |
except ValueError: |
|
161 |
i = 0 |
|
162 |
version_number.append(str(i)) |
|
163 |
version_str = '.'.join(version_number) |
|
164 |
||
165 |
target = py2exe.build_exe.Target(script = "bzr", |
|
166 |
dest_base = "bzr", |
|
167 |
icon_resources = [(0,'bzr.ico')], |
|
168 |
name = META_INFO['name'], |
|
169 |
version = version_str, |
|
170 |
description = META_INFO['description'], |
|
171 |
author = META_INFO['author'], |
|
172 |
copyright = "(c) Canonical Ltd, 2005-2006", |
|
173 |
company_name = "Canonical Ltd.", |
|
174 |
comments = META_INFO['description'], |
|
175 |
)
|
|
176 |
options_list = {"py2exe": {"packages": BZRLIB['packages'] + |
|
177 |
['elementtree'], |
|
1860.1.2
by Alexander Belchenko
setup.py: |
178 |
"excludes": ["Tkinter", "medusa"], |
1821.1.1
by Alexander Belchenko
win32 installer for bzr.dev.0.9 |
179 |
"dist_dir": "win32_bzr.exe", |
180 |
},
|
|
181 |
}
|
|
182 |
setup(options=options_list, |
|
183 |
console=[target, |
|
184 |
'tools/win32/bzr_postinstall.py', |
|
185 |
],
|
|
186 |
zipfile='lib/library.zip') |
|
1860.1.2
by Alexander Belchenko
setup.py: |
187 |
|
188 |
else: |
|
189 |
# std setup
|
|
190 |
ARGS = {'scripts': ['bzr'], |
|
191 |
'data_files': [('man/man1', ['bzr.1'])], |
|
192 |
# install the txt files from bzrlib.doc.api.
|
|
193 |
'package_data': {'bzrlib': ['doc/api/*.txt']}, |
|
194 |
'cmdclass': {'build': bzr_build, |
|
195 |
'install_scripts': my_install_scripts, |
|
196 |
},
|
|
197 |
}
|
|
198 |
||
199 |
ARGS.update(META_INFO) |
|
200 |
ARGS.update(BZRLIB) |
|
201 |
||
202 |
setup(**ARGS) |
|
203 |