/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: Marius Kruger
  • Date: 2007-08-12 08:15:15 UTC
  • mfrom: (2695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2979.
  • Revision ID: amanic@gmail.com-20070812081515-vgekipfhohcuj6rn
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
        if sys.platform == "win32":
105
105
            try:
106
 
                scripts_dir = self.install_dir
 
106
                scripts_dir = os.path.join(sys.prefix, 'Scripts')
107
107
                script_path = self._quoted_path(os.path.join(scripts_dir,
108
108
                                                             "bzr"))
109
109
                python_exe = self._quoted_path(sys.executable)
110
110
                args = self._win_batch_args()
111
111
                batch_str = "@%s %s %s" % (python_exe, script_path, args)
112
 
                batch_path = script_path + ".bat"
 
112
                batch_path = os.path.join(self.install_dir, "bzr.bat")
113
113
                f = file(batch_path, "w")
114
114
                f.write(batch_str)
115
115
                f.close()
148
148
########################
149
149
 
150
150
command_classes = {'install_scripts': my_install_scripts,
151
 
                  'build': bzr_build}
 
151
                   'build': bzr_build}
 
152
from distutils.extension import Extension
152
153
ext_modules = []
153
154
try:
154
155
    from Pyrex.Distutils import build_ext
155
156
except ImportError:
 
157
    have_pyrex = False
156
158
    # 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
    print
 
160
    print ("The python package 'Pyrex' is not available."
 
161
           " If the .c files are available,")
 
162
    print ("they will be built,"
 
163
           " but modifying the .pyx files will not rebuild them.")
 
164
    print
159
165
    from distutils.command.build_ext import build_ext
160
 
    from distutils.extension import Extension
161
 
    #ext_modules.append(
162
 
    #    Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
163
166
else:
164
 
    from distutils.extension import Extension
165
 
    #ext_modules.append(
166
 
    #    Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
 
167
    have_pyrex = True
 
168
# Override the build_ext if we have Pyrex available
167
169
command_classes['build_ext'] = build_ext
 
170
unavailable_files = []
 
171
 
 
172
 
 
173
def add_pyrex_extension(module_name, **kwargs):
 
174
    """Add a pyrex module to build.
 
175
 
 
176
    This will use Pyrex to auto-generate the .c file if it is available.
 
177
    Otherwise it will fall back on the .c file. If the .c file is not
 
178
    available, it will warn, and not add anything.
 
179
 
 
180
    You can pass any extra options to Extension through kwargs. One example is
 
181
    'libraries = []'.
 
182
 
 
183
    :param module_name: The python path to the module. This will be used to
 
184
        determine the .pyx and .c files to use.
 
185
    """
 
186
    path = module_name.replace('.', '/')
 
187
    pyrex_name = path + '.pyx'
 
188
    c_name = path + '.c'
 
189
    if have_pyrex:
 
190
        ext_modules.append(Extension(module_name, [pyrex_name]))
 
191
    else:
 
192
        if not os.path.isfile(c_name):
 
193
            unavailable_files.append(c_name)
 
194
        else:
 
195
            ext_modules.append(Extension(module_name, [c_name]))
 
196
 
 
197
 
 
198
add_pyrex_extension('bzrlib._dirstate_helpers_c')
 
199
add_pyrex_extension('bzrlib._knit_load_data_c')
 
200
 
 
201
 
 
202
if unavailable_files:
 
203
    print 'C extension(s) not found:'
 
204
    print '   %s' % ('\n  '.join(unavailable_files),)
 
205
    print 'The python versions will be used instead.'
 
206
    print
 
207
 
168
208
 
169
209
if 'bdist_wininst' in sys.argv:
170
210
    import glob
171
211
    # doc files
172
 
    docs = glob.glob('doc/*.htm') + ['doc/default.css']
 
212
    docs = glob.glob('doc/*.html') + ['doc/default.css']
 
213
    dev_docs = glob.glob('doc/developers/*.html')
173
214
    # python's distutils-based win32 installer
174
215
    ARGS = {'scripts': ['bzr', 'tools/win32/bzr-win32-bdist-postinstall.py'],
 
216
            'ext_modules': ext_modules,
175
217
            # help pages
176
 
            'data_files': [('Doc/Bazaar', docs)],
 
218
            'data_files': [('Doc/Bazaar', docs),
 
219
                           ('Doc/Bazaar/developers', dev_docs),
 
220
                          ],
 
221
            # for building pyrex extensions
 
222
            'cmdclass': {'build_ext': build_ext},
177
223
           }
178
224
 
179
225
    ARGS.update(META_INFO)
220
266
        import warnings
221
267
        warnings.warn('Unknown Python version.\n'
222
268
                      'Please check setup.py script for compatibility.')
 
269
    # email package from std python library use lazy import,
 
270
    # so we need to explicitly add all package
 
271
    additional_packages.append('email')
223
272
 
224
273
    options_list = {"py2exe": {"packages": BZRLIB['packages'] +
225
274
                                           additional_packages,
226
 
                               "excludes": ["Tkinter", "medusa"],
 
275
                               "excludes": ["Tkinter", "medusa", "tools"],
227
276
                               "dist_dir": "win32_bzr.exe",
228
277
                              },
229
278
                   }
234
283
          zipfile='lib/library.zip')
235
284
 
236
285
else:
 
286
    # ad-hoc for easy_install
 
287
    DATA_FILES = []
 
288
    if not 'bdist_egg' in sys.argv:
 
289
        # generate and install bzr.1 only with plain install, not easy_install one
 
290
        DATA_FILES = [('man/man1', ['bzr.1'])]
 
291
 
237
292
    # std setup
238
293
    ARGS = {'scripts': ['bzr'],
239
 
            'data_files': [('man/man1', ['bzr.1'])],
 
294
            'data_files': DATA_FILES,
240
295
            'cmdclass': command_classes,
241
296
            'ext_modules': ext_modules,
242
297
           }
243
 
    
 
298
 
244
299
    ARGS.update(META_INFO)
245
300
    ARGS.update(BZRLIB)
246
301
    ARGS.update(PKG_DATA)