/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: 2007-03-01 21:56:19 UTC
  • mto: (2255.7.84 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: john@arbash-meinel.com-20070301215619-wpt6kz8yem3ypu1b
Update to dirstate locking.
Move all of WT4.lock_* functions locally, so that they can
properly interact and cleanup around when we lock/unlock the
dirstate file.
Change all Lock objects to be non-blocking. So that if someone
grabs a lock on the DirState we find out immediately, rather
than blocking.
Change WT4.unlock() so that if the dirstate is dirty, it will
save the contents even if it only has a read lock.
It does this by trying to take a write lock, if it fails
we just ignore it. If it succeeds, then we can flush to disk.
This is more important now that DirState tracks file changes.
It allows 'bzr status' to update the cached stat and sha values.

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@lists.canonical.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:
30
58
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
31
59
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
32
60
    sys.exit(1)
33
 
if hasattr(os, "unsetenv"):
 
61
if getattr(os, "unsetenv", None) is not None:
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
47
99
    Create bzr.bat for win32.
48
100
    """
49
101
    def run(self):
50
 
        import os
51
 
        import sys
52
 
 
53
102
        install_scripts.run(self)   # standard action
54
103
 
55
104
        if sys.platform == "win32":
56
105
            try:
57
106
                scripts_dir = self.install_dir
58
 
                script_path = os.path.join(scripts_dir, "bzr")
59
 
                batch_str = "@%s %s %%*\n" % (sys.executable, script_path)
 
107
                script_path = self._quoted_path(os.path.join(scripts_dir,
 
108
                                                             "bzr"))
 
109
                python_exe = self._quoted_path(sys.executable)
 
110
                args = self._win_batch_args()
 
111
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
60
112
                batch_path = script_path + ".bat"
61
113
                f = file(batch_path, "w")
62
114
                f.write(batch_str)
65
117
            except Exception, e:
66
118
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
67
119
 
 
120
    def _quoted_path(self, path):
 
121
        if ' ' in path:
 
122
            return '"' + path + '"'
 
123
        else:
 
124
            return path
 
125
 
 
126
    def _win_batch_args(self):
 
127
        from bzrlib.win32utils import winver
 
128
        if winver == 'Windows NT':
 
129
            return '%*'
 
130
        else:
 
131
            return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
 
132
#/class my_install_scripts
 
133
 
68
134
 
69
135
class bzr_build(build):
70
136
    """Customized build distutils action.
76
142
        import generate_docs
77
143
        generate_docs.main(argv=["bzr", "man"])
78
144
 
 
145
 
79
146
########################
80
147
## Setup
81
148
########################
82
149
 
83
 
setup(name='bzr',
84
 
      version='0.8pre',
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.doc',
92
 
                'bzrlib.doc.api',
93
 
                'bzrlib.export',
94
 
                'bzrlib.plugins',
95
 
                'bzrlib.store',
96
 
                'bzrlib.store.revision',
97
 
                'bzrlib.store.versioned',
98
 
                'bzrlib.tests',
99
 
                'bzrlib.tests.blackbox',
100
 
                'bzrlib.tests.branch_implementations',
101
 
                'bzrlib.tests.bzrdir_implementations',
102
 
                'bzrlib.tests.interrepository_implementations',
103
 
                'bzrlib.tests.interversionedfile_implementations',
104
 
                'bzrlib.tests.repository_implementations',
105
 
                'bzrlib.tests.revisionstore_implementations',
106
 
                'bzrlib.tests.workingtree_implementations',
107
 
                'bzrlib.transport',
108
 
                'bzrlib.transport.http',
109
 
                'bzrlib.ui',
110
 
                'bzrlib.util',
111
 
                'bzrlib.util.elementtree',
112
 
                'bzrlib.util.effbot.org',
113
 
                'bzrlib.util.configobj',
114
 
                ],
115
 
      scripts=['bzr'],
116
 
      cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
117
 
      data_files=[('man/man1', ['bzr.1'])],
118
 
    #   todo: install the txt files from bzrlib.doc.api.
119
 
     )
 
150
if 'bdist_wininst' in sys.argv:
 
151
    import glob
 
152
    # doc files
 
153
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
 
154
    # python's distutils-based win32 installer
 
155
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
156
            # help pages
 
157
            'data_files': [('Doc/Bazaar', docs)],
 
158
           }
 
159
 
 
160
    ARGS.update(META_INFO)
 
161
    ARGS.update(BZRLIB)
 
162
    ARGS.update(PKG_DATA)
 
163
    
 
164
    setup(**ARGS)
 
165
 
 
166
elif 'py2exe' in sys.argv:
 
167
    # py2exe setup
 
168
    import py2exe
 
169
 
 
170
    # pick real bzr version
 
171
    import bzrlib
 
172
 
 
173
    version_number = []
 
174
    for i in bzrlib.version_info[:4]:
 
175
        try:
 
176
            i = int(i)
 
177
        except ValueError:
 
178
            i = 0
 
179
        version_number.append(str(i))
 
180
    version_str = '.'.join(version_number)
 
181
 
 
182
    target = py2exe.build_exe.Target(script = "bzr",
 
183
                                     dest_base = "bzr",
 
184
                                     icon_resources = [(0,'bzr.ico')],
 
185
                                     name = META_INFO['name'],
 
186
                                     version = version_str,
 
187
                                     description = META_INFO['description'],
 
188
                                     author = META_INFO['author'],
 
189
                                     copyright = "(c) Canonical Ltd, 2005-2007",
 
190
                                     company_name = "Canonical Ltd.",
 
191
                                     comments = META_INFO['description'],
 
192
                                    )
 
193
 
 
194
    additional_packages =  []
 
195
    if sys.version.startswith('2.4'):
 
196
        # adding elementtree package
 
197
        additional_packages.append('elementtree')
 
198
    elif sys.version.startswith('2.5'):
 
199
        additional_packages.append('xml.etree')
 
200
    else:
 
201
        import warnings
 
202
        warnings.warn('Unknown Python version.\n'
 
203
                      'Please check setup.py script for compatibility.')
 
204
 
 
205
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
 
206
                                           additional_packages,
 
207
                               "excludes": ["Tkinter", "medusa"],
 
208
                               "dist_dir": "win32_bzr.exe",
 
209
                              },
 
210
                   }
 
211
    setup(options=options_list,
 
212
          console=[target,
 
213
                   'tools/win32/bzr_postinstall.py',
 
214
                  ],
 
215
          zipfile='lib/library.zip')
 
216
 
 
217
else:
 
218
    # std setup
 
219
    ARGS = {'scripts': ['bzr'],
 
220
            'data_files': [('man/man1', ['bzr.1'])],
 
221
            'cmdclass': {'build': bzr_build,
 
222
                         'install_scripts': my_install_scripts,
 
223
                        },
 
224
           }
 
225
    
 
226
    ARGS.update(META_INFO)
 
227
    ARGS.update(BZRLIB)
 
228
    ARGS.update(PKG_DATA)
 
229
 
 
230
    setup(**ARGS)