/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-17 13:21:28 UTC
  • mto: This revision was merged to the branch mainline in revision 1937.
  • Revision ID: john@arbash-meinel.com-20060817132128-d1b2808d560292ef
Restore comment about using a memory server for .bzr/

Show diffs side-by-side

added added

removed removed

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