~launchpad-committers/ubuntu/lucid/pysvn/launchpad-ppa

« back to all changes in this revision

Viewing changes to Source/setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-01-28 21:36:43 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128213643-e3nprfrxn2wzc6c5
Tags: 1.5.2-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# ====================================================================
3
 
# (c) 2005-2006 Barry A Scott.  All rights reserved.
 
3
# (c) 2005-2007 Barry A Scott.  All rights reserved.
4
4
#
5
5
# This software is licensed as described in the file LICENSE.txt,
6
6
# which you should have received as part of this distribution.
59
59
        --svn-inc-dir=<dir>
60
60
        --svn-lib-dir=<dir>
61
61
        --define=<define-string>
 
62
        --universal (build Mac OS X universal binary - not working at yet)
62
63
 
63
64
''' % (basename, basename)
64
65
    return 1
70
71
        self.is_mac_os_x_fink = False
71
72
        self.is_mac_os_x_darwin_ports = False
72
73
        self.mac_os_x_version = None
 
74
        self.mac_os_x_universal = False
73
75
 
74
76
    def node_text( self, all_nodes ):
75
77
        all_text = []
98
100
                    self.mac_os_x_version = [int(s) for s in self.mac_os_x_version_string.split('.')]
99
101
                    self.is_mac_os_x = True
100
102
 
 
103
                    # look for the universal SDK
 
104
                    self.mac_os_x_universal = os.path.exists( '/Developer/SDKs/MacOSX%d.%du.sdk' %
 
105
                                                (self.mac_os_x_version[0], self.mac_os_x_version[1]) )
 
106
                    if self.mac_os_x_universal:
 
107
                        print 'Info: Mac OS X Universal SDKs found'
101
108
 
102
109
    def createMakefile( self, argv ):
103
110
        self.verbose = '--verbose' in argv
104
111
        self.detectMacVersion()
 
112
        if '--universal' in argv and self.mac_os_x_universal:
 
113
            print 'Info: turning on universal support'
 
114
            self.mac_os_x_universal = True
 
115
        else:
 
116
            self.mac_os_x_universal = False
105
117
 
106
118
        if self.verbose:
107
119
            print 'Info: Creating makefile for python %r' % (sys.version_info,)
108
120
 
109
121
        debug_cflags_list = []
110
122
        if '--enable-debug' in argv:
 
123
            print 'Info: Enabling debug'
111
124
            debug_cflags_list.append( '-g' )
112
125
 
113
126
        include_dir_list = []
155
168
        py_cflags_list.append( '-Dinit_pysvn=init_pysvn_%d_%d' % sys.version_info[:2] )
156
169
        py_cflags_list.append( '-Dinit_pysvn_d=init_pysvn_%d_%d_d' % sys.version_info[:2] )
157
170
 
 
171
        module_type = '.so'
 
172
        if sys.platform == 'cygwin':
 
173
            module_type = '.dll'
158
174
        template_values = {
159
 
#            'pysvn_module_name': '_pysvn_%d_%d' % sys.version_info[:2],
160
 
            'pysvn_module_name': '_pysvn',
 
175
            'pysvn_module_name': '_pysvn_%d_%d%s' % (sys.version_info[0], sys.version_info[1], module_type),
161
176
 
162
177
            # python executable
163
178
            'python_exe':       sys.executable,
200
215
 
201
216
                # 10.4 needs the libintl.a but 10.3 does not
202
217
                template_values['extra_libs'] = '%(svn_lib_dir)s/libintl.a' % template_values
203
 
                template_values['frameworks'] = '-framework System %s -framework CoreFoundation -framework Kerberos' % framework_lib
 
218
                template_values['frameworks'] = '-framework System %s -framework CoreFoundation -framework Kerberos -framework Security' % framework_lib
204
219
            else:
205
220
                if self.verbose:
206
221
                    print 'Info: Using Mac OS X 10.3 makefile template'
214
229
            elif self.is_mac_os_x_darwin_ports:
215
230
                makefile.write( self.makefile_template_macosx_darwin_ports % template_values )
216
231
 
 
232
            elif self.mac_os_x_universal:
 
233
                makefile.write( self.makefile_template_macosx_universal % template_values )
217
234
            else:
218
 
                makefile.write( self.makefile_template_macosx % template_values )
 
235
                makefile.write( self.makefile_template_macosx_one_arch % template_values )
 
236
 
219
237
        elif sys.platform.startswith('aix'):
220
238
            if self.verbose:
221
239
                print 'Info: Using AIX makefile template'
232
250
                else:
233
251
                    template_values['python_exp'] = 'python.exp'
234
252
            makefile.write( self.makefile_template_aix % template_values )
 
253
 
235
254
        elif sys.platform.startswith('linux'):
236
255
            if self.verbose:
237
256
                print 'Info: Using Linux makefile template'
238
257
            makefile.write( self.makefile_template_linux % template_values )
 
258
 
 
259
        elif sys.platform.startswith('freebsd'):
 
260
            if self.verbose:
 
261
                print 'Info: Using FreeBSD makefile template'
 
262
            makefile.write( self.makefile_template_freebsd % template_values )
 
263
 
 
264
        elif sys.platform == 'cygwin':
 
265
            if self.verbose:
 
266
                print 'Info: Using Cygwin makefile template'
 
267
            makefile.write( self.makefile_template_cygwin % template_values )
 
268
 
 
269
 
239
270
        else:
240
271
            if self.verbose:
241
272
                print 'Info: Using unix makefile template'
306
337
#include pysvn_common.mak
307
338
'''
308
339
 
 
340
    makefile_template_freebsd = '''#
 
341
#       Created by pysvn Extension/Source/setup.py
 
342
#       -- makefile_template_freebsd --
 
343
#
 
344
PYTHON=%(python_exe)s
 
345
SVN_INCLUDE=%(svn_include)s
 
346
CCC=g++ -c
 
347
CCCFLAGS=-Wall -fPIC -fexceptions -frtti %(includes)s %(py_cflags)s %(debug_cflags)s
 
348
CC=gcc -c
 
349
CCFLAGS=-Wall -fPIC %(includes)s %(debug_cflags)s
 
350
PYCXX=%(pycxx_dir)s
 
351
LDSHARED=g++ -shared %(debug_cflags)s
 
352
LDLIBS=-L%(svn_lib_dir)s -Wl,--rpath -Wl,/usr/lib:/usr/local/lib:%(svn_lib_dir)s \
 
353
-lsvn_client-1 \
 
354
-lsvn_diff-1 \
 
355
-lsvn_repos-1 \
 
356
 -lkrb5 -lcom_err -lexpat -lneon
 
357
 
 
358
#include pysvn_common.mak
 
359
'''
 
360
 
 
361
    makefile_template_cygwin = '''#
 
362
#       Created by pysvn Extension/Source/setup.py
 
363
#       -- makefile_template_cygwin --
 
364
#
 
365
PYTHON=%(python_exe)s
 
366
SVN_INCLUDE=%(svn_include)s
 
367
CCC=g++ -c
 
368
CCCFLAGS=-Wall -fexceptions -frtti %(includes)s %(py_cflags)s %(debug_cflags)s
 
369
CC=gcc -c
 
370
CCFLAGS=-Wall %(includes)s %(debug_cflags)s
 
371
PYCXX=%(pycxx_dir)s
 
372
LDSHARED=g++ -shared %(debug_cflags)s
 
373
LDLIBS=-L%(svn_lib_dir)s \
 
374
-L/usr/lib/python2.5/config -lpython2.5.dll \
 
375
-lsvn_client-1   \
 
376
-lsvn_repos-1    \
 
377
-lsvn_subr-1     \
 
378
-lsvn_delta-1    \
 
379
-lsvn_fs_fs-1    \
 
380
-lsvn_fs-1       \
 
381
-lsvn_ra_svn-1   \
 
382
-lsvn_repos-1    \
 
383
-lsvn_ra_local-1 \
 
384
-lsvn_ra_dav-1   \
 
385
-lsvn_diff-1     \
 
386
-lsvn_ra-1       \
 
387
-lsvn_wc-1       \
 
388
-lapr-1          \
 
389
-lneon           \
 
390
-laprutil-1      \
 
391
-liconv          \
 
392
-lexpat          \
 
393
-lpthread        \
 
394
-lz              \
 
395
 
 
396
 
 
397
#include pysvn_common.mak
 
398
'''
 
399
 
309
400
    makefile_template_aix = '''#
310
401
#       Created by pysvn Extension/Source/setup.py
311
402
#       -- makefile_template_aix --
345
436
#include pysvn_common.mak
346
437
'''
347
438
 
348
 
    makefile_template_macosx = '''#
 
439
    makefile_template_macosx_one_arch = '''#
349
440
#       Created by pysvn Extension/Source/setup.py
350
 
#       -- makefile_template_macosx --
 
441
#       -- makefile_template_macosx_one_arch --
351
442
#
352
443
PYTHON=%(python_exe)s
353
444
SVN_INCLUDE=%(svn_include)s
369
460
#include pysvn_common.mak
370
461
'''
371
462
 
 
463
    makefile_template_macosx_universal = '''#
 
464
#       Created by pysvn Extension/Source/setup.py
 
465
#       -- makefile_template_macosx_universal --
 
466
#
 
467
PYTHON=%(python_exe)s
 
468
SVN_INCLUDE=%(svn_include)s
 
469
CCC=g++ -c
 
470
CCCFLAGS=-Wall -Wno-long-double -fPIC -fexceptions -frtti %(includes)s %(py_cflags)s %(debug_cflags)s -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
 
471
CC=gcc -c
 
472
CCFLAGS=-Wall -Wno-long-double -fPIC %(includes)s %(debug_cflags)s -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
 
473
PYCXX=%(pycxx_dir)s
 
474
LDSHARED=g++ -bundle -twolevel_namespace %(debug_cflags)s -u _PyMac_Error %(frameworks)s -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
 
475
LDLIBS=-L%(svn_lib_dir)s \
 
476
-L%(apr_lib_dir)s \
 
477
-lsvn_client-1 \
 
478
-lsvn_repos-1 \
 
479
-lsvn_wc-1 \
 
480
-lsvn_fs-1 \
 
481
-lsvn_subr-1 \
 
482
-lsvn_diff-1 \
 
483
-lsvn_ra_dav-1 \
 
484
-l%(lib_apr)s
 
485
#include pysvn_common.mak
 
486
'''
 
487
 
372
488
    makefile_template_macosx_fink = '''#
373
489
#       Created by pysvn Extension/Source/setup.py
374
490
#       -- makefile_template_macosx_fink --
486
602
                        '/usr/local/lib',                       # typical *BSD
487
603
                        '/usr/pkg/lib',                         # netbsb
488
604
                    ],
489
 
                    self.is_mac_os_x and 'libsvn_client-1.dylib' or 'libsvn_client-1.so' )
 
605
                    self.get_lib_name_for_platform( 'libsvn_client-1' ) )
490
606
        # if we are using the Fink SVN then remember this
491
607
        self.is_mac_os_x_fink = dir.startswith( '/sw/' )
492
608
        self.is_mac_os_x_darwin_ports = dir.startswith( '/opt/local/' )
530
646
 
531
647
    def find_apr_lib( self, argv ):
532
648
        last_exception = None
533
 
        for apr_libname, self.lib_apr in [
534
 
                            (self.is_mac_os_x and 'libapr-1.dylib' or 'libapr-1.so', 'apr-1'),
535
 
                            (self.is_mac_os_x and 'libapr-0.dylib' or 'libapr-0.so', 'apr-0')]:
 
649
        lib_list = [(self.get_lib_name_for_platform( 'libapr-1' ), 'apr-1'),
 
650
                    (self.get_lib_name_for_platform( 'libapr-0' ), 'apr-0')]
 
651
 
 
652
        for apr_libname, self.lib_apr in lib_list:
536
653
            try:
537
654
                return self.find_dir( argv,
538
655
                    'APR library',
543
660
            except SetupError:
544
661
                pass
545
662
 
546
 
        for apr_libname, self.lib_apr in [
547
 
                            (self.is_mac_os_x and 'libapr-1.dylib' or 'libapr-1.so', 'apr-1'),
548
 
                            (self.is_mac_os_x and 'libapr-0.dylib' or 'libapr-0.so', 'apr-0')]:
 
663
        for apr_libname, self.lib_apr in lib_list:
549
664
            try:
550
665
                return self.find_dir( argv,
551
666
                    'APR library',
567
682
        raise last_exception
568
683
 
569
684
 
 
685
    def get_lib_name_for_platform( self, libname ):
 
686
        if self.is_mac_os_x:
 
687
            return '%s.dylib' % libname
 
688
        elif sys.platform == 'cygwin':
 
689
            return '%s.dll.a' % libname
 
690
        else:
 
691
            return '%s.so' % libname
 
692
 
570
693
    def find_dir( self, argv, name, kw, svn_root_suffix, base_dir_list, check_file ):
571
694
        dirname = self.__find_dir( argv, name, kw, svn_root_suffix, base_dir_list, check_file )
572
695
        print 'Info: Found %14.14s in %s' % (name, dirname)