~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 './setup.py --help' for more options
7
7
"""
8
8
 
9
 
import os
10
 
import sys
11
 
 
12
 
import bzrlib
13
 
 
14
9
##
15
10
# META INFORMATION FOR SETUP
16
11
 
17
12
META_INFO = {'name':         'bzr',
18
 
             'version':      bzrlib.__version__,
 
13
             'version':      '0.9pre',
19
14
             'author':       'Canonical Ltd',
20
 
             'author_email': 'bazaar@lists.canonical.com',
 
15
             'author_email': 'bazaar-ng@lists.ubuntu.com',
21
16
             'url':          'http://www.bazaar-vcs.org/',
22
17
             'description':  'Friendly distributed version control system',
23
18
             'license':      'GNU GPL v2',
24
19
            }
25
20
 
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
 
######################################################################
 
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
##
37
54
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
38
55
# including bzrlib.help
39
56
 
 
57
import os
 
58
import sys
 
59
 
40
60
try:
41
61
    version_info = sys.version_info
42
62
except AttributeError:
58
78
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
59
79
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
60
80
    sys.exit(1)
61
 
if getattr(os, "unsetenv", None) is not None:
 
81
if hasattr(os, "unsetenv"):
62
82
    os.unsetenv(REINVOKE)
63
83
 
64
84
 
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
 
 
89
85
from distutils.core import setup
90
86
from distutils.command.install_scripts import install_scripts
91
87
from distutils.command.build import build
99
95
    Create bzr.bat for win32.
100
96
    """
101
97
    def run(self):
 
98
        import os
 
99
        import sys
 
100
 
102
101
        install_scripts.run(self)   # standard action
103
102
 
104
103
        if sys.platform == "win32":
105
104
            try:
106
105
                scripts_dir = self.install_dir
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)
 
106
                script_path = os.path.join(scripts_dir, "bzr")
 
107
                batch_str = "@%s %s %%*\n" % (sys.executable, script_path)
112
108
                batch_path = script_path + ".bat"
113
109
                f = file(batch_path, "w")
114
110
                f.write(batch_str)
117
113
            except Exception, e:
118
114
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
119
115
 
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
 
 
134
116
 
135
117
class bzr_build(build):
136
118
    """Customized build distutils action.
147
129
## Setup
148
130
########################
149
131
 
150
 
command_classes = {'install_scripts': my_install_scripts,
151
 
                  'build': bzr_build}
152
 
ext_modules = []
153
 
try:
154
 
    from Pyrex.Distutils import build_ext
155
 
except ImportError:
156
 
    # try to build the extension from the prior generated source.
157
 
    print ("Pyrex not available, while bzr will build, "
158
 
           "you cannot modify the C extensions.")
159
 
    from distutils.command.build_ext import build_ext
160
 
    from distutils.extension import Extension
161
 
    ext_modules.extend([
162
 
        Extension("bzrlib.compiled.dirstate_helpers",
163
 
                  ["bzrlib/compiled/dirstate_helpers.c"],
164
 
                  libraries=[],
165
 
                  ),
166
 
    ])
167
 
else:
168
 
    from distutils.extension import Extension
169
 
    ext_modules.extend([
170
 
        Extension("bzrlib.compiled.dirstate_helpers",
171
 
                  ["bzrlib/compiled/dirstate_helpers.pyx"],
172
 
                  libraries=[],
173
 
                  ),
174
 
    ])
175
 
command_classes['build_ext'] = build_ext
176
 
 
177
132
if 'bdist_wininst' in sys.argv:
178
133
    import glob
179
134
    # doc files
180
135
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
181
136
    # python's distutils-based win32 installer
182
137
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
138
            # install the txt files from bzrlib.doc.api.
 
139
            'package_data': {'bzrlib': ['doc/api/*.txt']},
183
140
            # help pages
184
141
            'data_files': [('Doc/Bazaar', docs)],
185
142
           }
186
143
 
187
144
    ARGS.update(META_INFO)
188
145
    ARGS.update(BZRLIB)
189
 
    ARGS.update(PKG_DATA)
190
146
    
191
147
    setup(**ARGS)
192
148
 
213
169
                                     version = version_str,
214
170
                                     description = META_INFO['description'],
215
171
                                     author = META_INFO['author'],
216
 
                                     copyright = "(c) Canonical Ltd, 2005-2007",
 
172
                                     copyright = "(c) Canonical Ltd, 2005-2006",
217
173
                                     company_name = "Canonical Ltd.",
218
174
                                     comments = META_INFO['description'],
219
175
                                    )
220
 
 
221
 
    additional_packages =  []
222
 
    if sys.version.startswith('2.4'):
223
 
        # adding elementtree package
224
 
        additional_packages.append('elementtree')
225
 
    elif sys.version.startswith('2.5'):
226
 
        additional_packages.append('xml.etree')
227
 
    else:
228
 
        import warnings
229
 
        warnings.warn('Unknown Python version.\n'
230
 
                      'Please check setup.py script for compatibility.')
231
 
 
232
176
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
233
 
                                           additional_packages,
 
177
                                           ['elementtree'],
234
178
                               "excludes": ["Tkinter", "medusa"],
235
179
                               "dist_dir": "win32_bzr.exe",
236
180
                              },
245
189
    # std setup
246
190
    ARGS = {'scripts': ['bzr'],
247
191
            'data_files': [('man/man1', ['bzr.1'])],
248
 
            'cmdclass': command_classes,
249
 
            'ext_modules': ext_modules,
 
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
                        },
250
197
           }
251
198
    
252
199
    ARGS.update(META_INFO)
253
200
    ARGS.update(BZRLIB)
254
 
    ARGS.update(PKG_DATA)
255
201
 
256
202
    setup(**ARGS)
 
203