Ticket #1397: patch-setup.py.diff

File patch-setup.py.diff, 4.7 KB (added by ryanwilcox@…, 21 years ago)

Version 2 of the patch for setup.py

  • .py

    old new  
    2020name = "MySQL-%s" % os.path.basename(sys.executable)
    2121version = "0.9.2"
    2222
    23 mysqlclient = thread_safe_library and "mysqlclient_r" or "mysqlclient"
     23mysqlclient = thread_safe_library and "mysqlclient"
    2424
    2525# include files and library locations should cover most platforms
    26 include_dirs = [
    27     '/usr/include/mysql', '/usr/local/include/mysql',
    28     '/usr/local/mysql/include/mysql'
    29     ]
    30 library_dirs = [
    31     '/usr/lib/mysql', '/usr/local/lib/mysql',
    32     '/usr/local/mysql/lib/mysql'
    33     ]
    3426
     27dir_given = 0
     28
     29include_dirs = []
     30library_dirs = []
     31
     32args = sys.argv[:]
     33if len(args) > 2:
     34        for y in args:
     35                        found = y.find('--prefix=')
     36                        if(found > -1):
     37                                found = found + len('--prefix=')
     38                                z = y[found:]
     39                                include_dirs = [os.path.join(z, 'include')]
     40                                library_dirs = [os.path.join(z, 'lib')]
     41                                dir_given = 1   
     42                                sys.argv.remove(y)
     43                        found = y.find('--includedir=')
     44                        if (found > -1):
     45                                found = found + len('--includedir=')
     46                                z = y[found:]
     47                                include_dirs = [z]
     48                                dir_given = 1
     49                                sys.argv.remove(y)
     50                        found = y.find('--libdir=')
     51                        if (found > -1 ):
     52                                found = found + len('--libdir=')
     53                                z = y[found:]
     54                                library_dirs = [z]
     55                                dir_given = 1
     56                                sys.argv.remove(y)
     57else:
     58    include_dirs = ['/usr/include/mysql', '/usr/local/include/mysql','/usr/local/mysql/include/mysql']
     59    library_dirs = ['/usr/lib/mysql', '/usr/local/lib/mysql','/usr/local/mysql/lib/mysql']
     60   
    3561# MySQL-3.23 and newer need libz
    3662libraries = [mysqlclient, "z"]
    3763
     
    4874extra_compile_args = []
    4975extra_link_args = []
    5076
    51 if sys.platform == "netbsd1":
    52     include_dirs = ['/usr/pkg/include/mysql']
    53     library_dirs = ['/usr/pkg/lib/mysql']
    54 elif sys.platform in ("freebsd4", "openbsd3"):
    55     LOCALBASE = os.environ.get('LOCALBASE', '/usr/local')
    56     include_dirs = ['%s/include/mysql' % LOCALBASE]
    57     library_dirs = ['%s/lib/mysql' % LOCALBASE]
    58 elif sys.platform == "sunos5": # Solaris 2.8 + gcc
    59     runtime_library_dirs.append('/usr/local/lib:/usr/openwin/lib:/usr/dt/lib')
    60     extra_compile_args.append("-fPIC")
    61 elif sys.platform == "win32": # Ugh
    62     include_dirs = [r'c:\mysql\include']
    63     library_dirs = [r'c:\mysql\lib\opt']
    64     libraries = [mysqlclient, 'zlib', 'msvcrt', 'libcmt',
    65                  'wsock32', 'advapi32']
    66     extra_objects = [r'c:\mysql\lib\opt\mysqlclient.lib']
    67 elif sys.platform == "cygwin":
    68     include_dirs = ['/c/mysql/include']
    69     library_dirs = ['/c/mysql/lib']
    70     extra_compile_args.append('-DMS_WIN32')
    71 elif sys.platform[:6] == "darwin": # Mac OS X
    72     include_dirs.append('/sw/include')
    73     library_dirs.append('/sw/lib')
    74     extra_link_args.append('-flat_namespace')
    75 elif sys.platform == 'linux2' and os.environ.get('HOSTTYPE') == 'alpha':
    76     libraries.extend(['ots', 'cpml'])
    77 elif os.name == "posix": # UNIX-ish platforms not covered above
    78     pass # default should work
     77if(dir_given == 0):
     78    if sys.platform == "netbsd1":
     79        include_dirs = ['/usr/pkg/include/mysql']
     80        library_dirs = ['/usr/pkg/lib/mysql']
     81    elif sys.platform in ("freebsd4", "openbsd3"):
     82        LOCALBASE = os.environ.get('LOCALBASE', '/usr/local')
     83        include_dirs = ['%s/include/mysql' % LOCALBASE]
     84        library_dirs = ['%s/lib/mysql' % LOCALBASE]
     85    elif sys.platform == "sunos5": # Solaris 2.8 + gcc
     86        runtime_library_dirs.append('/usr/local/lib:/usr/openwin/lib:/usr/dt/lib')
     87        extra_compile_args.append("-fPIC")
     88    elif sys.platform == "win32": # Ugh
     89        include_dirs = [r'c:\mysql\include']
     90        library_dirs = [r'c:\mysql\lib\opt']
     91        libraries = [mysqlclient, 'zlib', 'msvcrt', 'libcmt',
     92                     'wsock32', 'advapi32']
     93        extra_objects = [r'c:\mysql\lib\opt\mysqlclient.lib']
     94    elif sys.platform == "cygwin":
     95        include_dirs = ['/c/mysql/include']
     96        library_dirs = ['/c/mysql/lib']
     97        extra_compile_args.append('-DMS_WIN32')
     98    elif sys.platform[:6] == "darwin": # Mac OS X
     99        include_dirs.append('/sw/include')
     100        library_dirs.append('/sw/lib')
     101        extra_link_args.append('-flat_namespace')
     102    elif sys.platform == 'linux2' and os.environ.get('HOSTTYPE') == 'alpha':
     103        libraries.extend(['ots', 'cpml'])
     104    elif os.name == "posix": # UNIX-ish platforms not covered above
     105        pass # default should work
     106    else:
     107        raise "UnknownPlatform", "sys.platform=%s, os.name=%s" % \
     108              (sys.platform, os.name)
    79109else:
    80     raise "UnknownPlatform", "sys.platform=%s, os.name=%s" % \
    81           (sys.platform, os.name)
     110    if (sys.platform[:6] == "darwin"): # Mac OS X
     111        extra_link_args.append('-flat_namespace')
    82112   
    83113long_description = \
    84114"""Python interface to MySQL-3.23