~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

Fix BzrDir.create_workingtree for NULL_REVISION

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
6
 
 
 
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 os
 
10
import sys
 
11
 
 
12
import bzrlib
 
13
 
 
14
##
 
15
# META INFORMATION FOR SETUP
 
16
 
 
17
META_INFO = {'name':         'bzr',
 
18
             'version':      bzrlib.__version__,
 
19
             'author':       'Canonical Ltd',
 
20
             'author_email': 'bazaar-ng@lists.ubuntu.com',
 
21
             'url':          'http://www.bazaar-vcs.org/',
 
22
             'description':  'Friendly distributed version control system',
 
23
             'license':      'GNU GPL v2',
 
24
            }
 
25
 
 
26
# The list of packages is automatically generated later. Add other things
 
27
# that are part of BZRLIB here.
 
28
BZRLIB = {}
 
29
 
 
30
PKG_DATA = {# install files from selftest suite
 
31
            'package_data': {'bzrlib': ['doc/api/*.txt',
 
32
                                        'tests/test_patches_data/*',
 
33
                                       ]},
 
34
           }
 
35
 
 
36
######################################################################
7
37
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
8
38
# including bzrlib.help
9
39
 
10
 
import os, sys
11
 
 
12
40
try:
13
41
    version_info = sys.version_info
14
42
except AttributeError:
34
62
    os.unsetenv(REINVOKE)
35
63
 
36
64
 
 
65
def get_bzrlib_packages():
 
66
    """Recurse through the bzrlib directory, and extract the package names"""
 
67
 
 
68
    packages = []
 
69
    base_path = os.path.dirname(os.path.abspath(bzrlib.__file__))
 
70
    for root, dirs, files in os.walk(base_path):
 
71
        if '__init__.py' in files:
 
72
            assert root.startswith(base_path)
 
73
            # Get just the path below bzrlib
 
74
            package_path = root[len(base_path):]
 
75
            # Remove leading and trailing slashes
 
76
            package_path = package_path.strip('\\/')
 
77
            if not package_path:
 
78
                package_name = 'bzrlib'
 
79
            else:
 
80
                package_name = ('bzrlib.' +
 
81
                            package_path.replace('/', '.').replace('\\', '.'))
 
82
            packages.append(package_name)
 
83
    return sorted(packages)
 
84
 
 
85
 
 
86
BZRLIB['packages'] = get_bzrlib_packages()
 
87
 
 
88
 
37
89
from distutils.core import setup
38
90
from distutils.command.install_scripts import install_scripts
39
91
from distutils.command.build import build
55
107
        if sys.platform == "win32":
56
108
            try:
57
109
                scripts_dir = self.install_dir
58
 
                script_path = os.path.join(scripts_dir, "bzr")
59
 
                batch_str = "@%s %s %%*\n" % (sys.executable, script_path)
 
110
                script_path = self._quoted_path(os.path.join(scripts_dir,
 
111
                                                             "bzr"))
 
112
                python_exe = self._quoted_path(sys.executable)
 
113
                args = self._win_batch_args()
 
114
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
60
115
                batch_path = script_path + ".bat"
61
116
                f = file(batch_path, "w")
62
117
                f.write(batch_str)
65
120
            except Exception, e:
66
121
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
67
122
 
 
123
    def _quoted_path(self, path):
 
124
        if ' ' in path:
 
125
            return '"' + path + '"'
 
126
        else:
 
127
            return path
 
128
 
 
129
    def _win_batch_args(self):
 
130
        if os.name == 'nt':
 
131
            return '%*'
 
132
        else:
 
133
            return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
 
134
#/class my_install_scripts
 
135
 
68
136
 
69
137
class bzr_build(build):
70
138
    """Customized build distutils action.
73
141
    def run(self):
74
142
        build.run(self)
75
143
 
76
 
        import bzr_man
77
 
        bzr_man.main()
 
144
        import generate_docs
 
145
        generate_docs.main(argv=["bzr", "man"])
 
146
 
78
147
 
79
148
########################
80
149
## Setup
81
150
########################
82
151
 
83
 
setup(name='bzr',
84
 
      version='0.7pre',
85
 
      author='Martin Pool',
86
 
      author_email='mbp@sourcefrog.net',
87
 
      url='http://www.bazaar-ng.org/',
88
 
      description='Friendly distributed version control system',
89
 
      license='GNU GPL v2',
90
 
      packages=['bzrlib',
91
 
                'bzrlib.export',
92
 
                'bzrlib.plugins',
93
 
                'bzrlib.store',
94
 
                'bzrlib.tests',
95
 
                'bzrlib.tests.blackbox',
96
 
                'bzrlib.transport',
97
 
                'bzrlib.ui',
98
 
                'bzrlib.util',
99
 
                'bzrlib.util.elementtree',
100
 
                'bzrlib.util.effbot.org',
101
 
                'bzrlib.util.configobj',
102
 
                ],
103
 
      scripts=['bzr'],
104
 
      cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
105
 
      data_files=[('man/man1', ['bzr.1'])],
106
 
     )
 
152
if 'bdist_wininst' in sys.argv:
 
153
    import glob
 
154
    # doc files
 
155
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
 
156
    # python's distutils-based win32 installer
 
157
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
158
            # help pages
 
159
            'data_files': [('Doc/Bazaar', docs)],
 
160
           }
 
161
 
 
162
    ARGS.update(META_INFO)
 
163
    ARGS.update(BZRLIB)
 
164
    ARGS.update(PKG_DATA)
 
165
    
 
166
    setup(**ARGS)
 
167
 
 
168
elif 'py2exe' in sys.argv:
 
169
    # py2exe setup
 
170
    import py2exe
 
171
 
 
172
    # pick real bzr version
 
173
    import bzrlib
 
174
 
 
175
    version_number = []
 
176
    for i in bzrlib.version_info[:4]:
 
177
        try:
 
178
            i = int(i)
 
179
        except ValueError:
 
180
            i = 0
 
181
        version_number.append(str(i))
 
182
    version_str = '.'.join(version_number)
 
183
 
 
184
    target = py2exe.build_exe.Target(script = "bzr",
 
185
                                     dest_base = "bzr",
 
186
                                     icon_resources = [(0,'bzr.ico')],
 
187
                                     name = META_INFO['name'],
 
188
                                     version = version_str,
 
189
                                     description = META_INFO['description'],
 
190
                                     author = META_INFO['author'],
 
191
                                     copyright = "(c) Canonical Ltd, 2005-2006",
 
192
                                     company_name = "Canonical Ltd.",
 
193
                                     comments = META_INFO['description'],
 
194
                                    )
 
195
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
 
196
                                           ['elementtree'],
 
197
                               "excludes": ["Tkinter", "medusa"],
 
198
                               "dist_dir": "win32_bzr.exe",
 
199
                              },
 
200
                   }
 
201
    setup(options=options_list,
 
202
          console=[target,
 
203
                   'tools/win32/bzr_postinstall.py',
 
204
                  ],
 
205
          zipfile='lib/library.zip')
 
206
 
 
207
else:
 
208
    # std setup
 
209
    ARGS = {'scripts': ['bzr'],
 
210
            'data_files': [('man/man1', ['bzr.1'])],
 
211
            'cmdclass': {'build': bzr_build,
 
212
                         'install_scripts': my_install_scripts,
 
213
                        },
 
214
           }
 
215
    
 
216
    ARGS.update(META_INFO)
 
217
    ARGS.update(BZRLIB)
 
218
    ARGS.update(PKG_DATA)
 
219
 
 
220
    setup(**ARGS)