~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-16 16:27:58 UTC
  • mto: This revision was merged to the branch mainline in revision 1938.
  • Revision ID: john@arbash-meinel.com-20060816162758-752ad5818bc063c9
Move out the blackbox testament tests into a real blackbox module

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