| 1 | n/a | # Autodetecting setup.py script for building the Python extensions |
|---|
| 2 | n/a | # |
|---|
| 3 | n/a | # Modified for BeOS build. Donn Cave, March 27 2001. |
|---|
| 4 | n/a | |
|---|
| 5 | n/a | __version__ = "special BeOS after 1.37" |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | import sys, os |
|---|
| 8 | n/a | from distutils import sysconfig |
|---|
| 9 | n/a | from distutils import text_file |
|---|
| 10 | n/a | from distutils.errors import * |
|---|
| 11 | n/a | from distutils.core import Extension, setup |
|---|
| 12 | n/a | from distutils.command.build_ext import build_ext |
|---|
| 13 | n/a | |
|---|
| 14 | n/a | # This global variable is used to hold the list of modules to be disabled. |
|---|
| 15 | n/a | disabled_module_list = ['dbm', 'mmap', 'resource', 'nis'] |
|---|
| 16 | n/a | |
|---|
| 17 | n/a | def find_file(filename, std_dirs, paths): |
|---|
| 18 | n/a | """Searches for the directory where a given file is located, |
|---|
| 19 | n/a | and returns a possibly-empty list of additional directories, or None |
|---|
| 20 | n/a | if the file couldn't be found at all. |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | 'filename' is the name of a file, such as readline.h or libcrypto.a. |
|---|
| 23 | n/a | 'std_dirs' is the list of standard system directories; if the |
|---|
| 24 | n/a | file is found in one of them, no additional directives are needed. |
|---|
| 25 | n/a | 'paths' is a list of additional locations to check; if the file is |
|---|
| 26 | n/a | found in one of them, the resulting list will contain the directory. |
|---|
| 27 | n/a | """ |
|---|
| 28 | n/a | |
|---|
| 29 | n/a | # Check the standard locations |
|---|
| 30 | n/a | for dir in std_dirs: |
|---|
| 31 | n/a | f = os.path.join(dir, filename) |
|---|
| 32 | n/a | if os.path.exists(f): return [] |
|---|
| 33 | n/a | |
|---|
| 34 | n/a | # Check the additional directories |
|---|
| 35 | n/a | for dir in paths: |
|---|
| 36 | n/a | f = os.path.join(dir, filename) |
|---|
| 37 | n/a | if os.path.exists(f): |
|---|
| 38 | n/a | return [dir] |
|---|
| 39 | n/a | |
|---|
| 40 | n/a | # Not found anywhere |
|---|
| 41 | n/a | return None |
|---|
| 42 | n/a | |
|---|
| 43 | n/a | def find_library_file(compiler, libname, std_dirs, paths): |
|---|
| 44 | n/a | filename = compiler.library_filename(libname, lib_type='shared') |
|---|
| 45 | n/a | result = find_file(filename, std_dirs, paths) |
|---|
| 46 | n/a | if result is not None: return result |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | filename = compiler.library_filename(libname, lib_type='static') |
|---|
| 49 | n/a | result = find_file(filename, std_dirs, paths) |
|---|
| 50 | n/a | return result |
|---|
| 51 | n/a | |
|---|
| 52 | n/a | def module_enabled(extlist, modname): |
|---|
| 53 | n/a | """Returns whether the module 'modname' is present in the list |
|---|
| 54 | n/a | of extensions 'extlist'.""" |
|---|
| 55 | n/a | extlist = [ext for ext in extlist if ext.name == modname] |
|---|
| 56 | n/a | return len(extlist) |
|---|
| 57 | n/a | |
|---|
| 58 | n/a | class PyBuildExt(build_ext): |
|---|
| 59 | n/a | |
|---|
| 60 | n/a | def build_extensions(self): |
|---|
| 61 | n/a | |
|---|
| 62 | n/a | # Detect which modules should be compiled |
|---|
| 63 | n/a | self.detect_modules() |
|---|
| 64 | n/a | |
|---|
| 65 | n/a | # Remove modules that are present on the disabled list |
|---|
| 66 | n/a | self.extensions = [ext for ext in self.extensions |
|---|
| 67 | n/a | if ext.name not in disabled_module_list] |
|---|
| 68 | n/a | |
|---|
| 69 | n/a | # Fix up the autodetected modules, prefixing all the source files |
|---|
| 70 | n/a | # with Modules/ and adding Python's include directory to the path. |
|---|
| 71 | n/a | (srcdir,) = sysconfig.get_config_vars('srcdir') |
|---|
| 72 | n/a | |
|---|
| 73 | n/a | # Figure out the location of the source code for extension modules |
|---|
| 74 | n/a | moddir = os.path.join(os.getcwd(), srcdir, 'Modules') |
|---|
| 75 | n/a | moddir = os.path.normpath(moddir) |
|---|
| 76 | n/a | srcdir, tail = os.path.split(moddir) |
|---|
| 77 | n/a | srcdir = os.path.normpath(srcdir) |
|---|
| 78 | n/a | moddir = os.path.normpath(moddir) |
|---|
| 79 | n/a | |
|---|
| 80 | n/a | # Fix up the paths for scripts, too |
|---|
| 81 | n/a | self.distribution.scripts = [os.path.join(srcdir, filename) |
|---|
| 82 | n/a | for filename in self.distribution.scripts] |
|---|
| 83 | n/a | |
|---|
| 84 | n/a | for ext in self.extensions[:]: |
|---|
| 85 | n/a | ext.sources = [ os.path.join(moddir, filename) |
|---|
| 86 | n/a | for filename in ext.sources ] |
|---|
| 87 | n/a | ext.include_dirs.append( '.' ) # to get config.h |
|---|
| 88 | n/a | ext.include_dirs.append( os.path.join(srcdir, './Include') ) |
|---|
| 89 | n/a | |
|---|
| 90 | n/a | # If a module has already been built statically, |
|---|
| 91 | n/a | # don't build it here |
|---|
| 92 | n/a | if ext.name in sys.builtin_module_names: |
|---|
| 93 | n/a | self.extensions.remove(ext) |
|---|
| 94 | n/a | |
|---|
| 95 | n/a | # Parse Modules/Setup to figure out which modules are turned |
|---|
| 96 | n/a | # on in the file. |
|---|
| 97 | n/a | input = text_file.TextFile('Modules/Setup', join_lines=1) |
|---|
| 98 | n/a | remove_modules = [] |
|---|
| 99 | n/a | while 1: |
|---|
| 100 | n/a | line = input.readline() |
|---|
| 101 | n/a | if not line: break |
|---|
| 102 | n/a | line = line.split() |
|---|
| 103 | n/a | remove_modules.append( line[0] ) |
|---|
| 104 | n/a | input.close() |
|---|
| 105 | n/a | |
|---|
| 106 | n/a | for ext in self.extensions[:]: |
|---|
| 107 | n/a | if ext.name in remove_modules: |
|---|
| 108 | n/a | self.extensions.remove(ext) |
|---|
| 109 | n/a | |
|---|
| 110 | n/a | # When you run "make CC=altcc" or something similar, you really want |
|---|
| 111 | n/a | # those environment variables passed into the setup.py phase. Here's |
|---|
| 112 | n/a | # a small set of useful ones. |
|---|
| 113 | n/a | compiler = os.environ.get('CC') |
|---|
| 114 | n/a | linker_so = os.environ.get('LDSHARED') |
|---|
| 115 | n/a | args = {} |
|---|
| 116 | n/a | # unfortunately, distutils doesn't let us provide separate C and C++ |
|---|
| 117 | n/a | # compilers |
|---|
| 118 | n/a | if compiler is not None: |
|---|
| 119 | n/a | args['compiler_so'] = compiler |
|---|
| 120 | n/a | if linker_so is not None: |
|---|
| 121 | n/a | args['linker_so'] = linker_so + ' -shared' |
|---|
| 122 | n/a | self.compiler.set_executables(**args) |
|---|
| 123 | n/a | |
|---|
| 124 | n/a | build_ext.build_extensions(self) |
|---|
| 125 | n/a | |
|---|
| 126 | n/a | def build_extension(self, ext): |
|---|
| 127 | n/a | |
|---|
| 128 | n/a | try: |
|---|
| 129 | n/a | build_ext.build_extension(self, ext) |
|---|
| 130 | n/a | except (CCompilerError, DistutilsError), why: |
|---|
| 131 | n/a | self.announce('WARNING: building of extension "%s" failed: %s' % |
|---|
| 132 | n/a | (ext.name, sys.exc_info()[1])) |
|---|
| 133 | n/a | |
|---|
| 134 | n/a | def get_platform (self): |
|---|
| 135 | n/a | # Get value of sys.platform |
|---|
| 136 | n/a | platform = sys.platform |
|---|
| 137 | n/a | if platform[:6] =='cygwin': |
|---|
| 138 | n/a | platform = 'cygwin' |
|---|
| 139 | n/a | elif platform[:4] =='beos': |
|---|
| 140 | n/a | platform = 'beos' |
|---|
| 141 | n/a | |
|---|
| 142 | n/a | return platform |
|---|
| 143 | n/a | |
|---|
| 144 | n/a | def detect_modules(self): |
|---|
| 145 | n/a | try: |
|---|
| 146 | n/a | belibs = os.environ['BELIBRARIES'].split(';') |
|---|
| 147 | n/a | except KeyError: |
|---|
| 148 | n/a | belibs = ['/boot/beos/system/lib'] |
|---|
| 149 | n/a | belibs.append('/boot/home/config/lib') |
|---|
| 150 | n/a | self.compiler.library_dirs.append('/boot/home/config/lib') |
|---|
| 151 | n/a | try: |
|---|
| 152 | n/a | beincl = os.environ['BEINCLUDES'].split(';') |
|---|
| 153 | n/a | except KeyError: |
|---|
| 154 | n/a | beincl = [] |
|---|
| 155 | n/a | beincl.append('/boot/home/config/include') |
|---|
| 156 | n/a | self.compiler.include_dirs.append('/boot/home/config/include') |
|---|
| 157 | n/a | # lib_dirs and inc_dirs are used to search for files; |
|---|
| 158 | n/a | # if a file is found in one of those directories, it can |
|---|
| 159 | n/a | # be assumed that no additional -I,-L directives are needed. |
|---|
| 160 | n/a | lib_dirs = belibs |
|---|
| 161 | n/a | inc_dirs = beincl |
|---|
| 162 | n/a | exts = [] |
|---|
| 163 | n/a | |
|---|
| 164 | n/a | platform = self.get_platform() |
|---|
| 165 | n/a | |
|---|
| 166 | n/a | # Check for MacOS X, which doesn't need libm.a at all |
|---|
| 167 | n/a | math_libs = ['m'] |
|---|
| 168 | n/a | if platform in ['Darwin1.2', 'beos']: |
|---|
| 169 | n/a | math_libs = [] |
|---|
| 170 | n/a | |
|---|
| 171 | n/a | # XXX Omitted modules: gl, pure, dl, SGI-specific modules |
|---|
| 172 | n/a | |
|---|
| 173 | n/a | # |
|---|
| 174 | n/a | # The following modules are all pretty straightforward, and compile |
|---|
| 175 | n/a | # on pretty much any POSIXish platform. |
|---|
| 176 | n/a | # |
|---|
| 177 | n/a | |
|---|
| 178 | n/a | # Some modules that are normally always on: |
|---|
| 179 | n/a | exts.append( Extension('_weakref', ['_weakref.c']) ) |
|---|
| 180 | n/a | exts.append( Extension('_symtable', ['symtablemodule.c']) ) |
|---|
| 181 | n/a | |
|---|
| 182 | n/a | # array objects |
|---|
| 183 | n/a | exts.append( Extension('array', ['arraymodule.c']) ) |
|---|
| 184 | n/a | # complex math library functions |
|---|
| 185 | n/a | exts.append( Extension('cmath', ['cmathmodule.c'], |
|---|
| 186 | n/a | libraries=math_libs) ) |
|---|
| 187 | n/a | |
|---|
| 188 | n/a | # math library functions, e.g. sin() |
|---|
| 189 | n/a | exts.append( Extension('math', ['mathmodule.c'], |
|---|
| 190 | n/a | libraries=math_libs) ) |
|---|
| 191 | n/a | # fast string operations implemented in C |
|---|
| 192 | n/a | exts.append( Extension('strop', ['stropmodule.c']) ) |
|---|
| 193 | n/a | # time operations and variables |
|---|
| 194 | n/a | exts.append( Extension('time', ['timemodule.c'], |
|---|
| 195 | n/a | libraries=math_libs) ) |
|---|
| 196 | n/a | # operator.add() and similar goodies |
|---|
| 197 | n/a | exts.append( Extension('operator', ['operator.c']) ) |
|---|
| 198 | n/a | # access to the built-in codecs and codec registry |
|---|
| 199 | n/a | exts.append( Extension('_codecs', ['_codecsmodule.c']) ) |
|---|
| 200 | n/a | # Python C API test module |
|---|
| 201 | n/a | exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) |
|---|
| 202 | n/a | # static Unicode character database |
|---|
| 203 | n/a | exts.append( Extension('unicodedata', ['unicodedata.c']) ) |
|---|
| 204 | n/a | # access to ISO C locale support |
|---|
| 205 | n/a | exts.append( Extension('_locale', ['_localemodule.c']) ) |
|---|
| 206 | n/a | |
|---|
| 207 | n/a | # Modules with some UNIX dependencies -- on by default: |
|---|
| 208 | n/a | # (If you have a really backward UNIX, select and socket may not be |
|---|
| 209 | n/a | # supported...) |
|---|
| 210 | n/a | |
|---|
| 211 | n/a | # fcntl(2) and ioctl(2) |
|---|
| 212 | n/a | exts.append( Extension('fcntl', ['fcntlmodule.c']) ) |
|---|
| 213 | n/a | # pwd(3) |
|---|
| 214 | n/a | exts.append( Extension('pwd', ['pwdmodule.c']) ) |
|---|
| 215 | n/a | # grp(3) |
|---|
| 216 | n/a | exts.append( Extension('grp', ['grpmodule.c']) ) |
|---|
| 217 | n/a | # posix (UNIX) errno values |
|---|
| 218 | n/a | exts.append( Extension('errno', ['errnomodule.c']) ) |
|---|
| 219 | n/a | # select(2); not on ancient System V |
|---|
| 220 | n/a | exts.append( Extension('select', ['selectmodule.c']) ) |
|---|
| 221 | n/a | |
|---|
| 222 | n/a | # The md5 module implements the RSA Data Security, Inc. MD5 |
|---|
| 223 | n/a | # Message-Digest Algorithm, described in RFC 1321. The necessary files |
|---|
| 224 | n/a | # md5c.c and md5.h are included here. |
|---|
| 225 | n/a | exts.append( Extension('md5', ['md5module.c', 'md5c.c']) ) |
|---|
| 226 | n/a | |
|---|
| 227 | n/a | # The sha module implements the SHA checksum algorithm. |
|---|
| 228 | n/a | # (NIST's Secure Hash Algorithm.) |
|---|
| 229 | n/a | exts.append( Extension('sha', ['shamodule.c']) ) |
|---|
| 230 | n/a | |
|---|
| 231 | n/a | # Helper module for various ascii-encoders |
|---|
| 232 | n/a | exts.append( Extension('binascii', ['binascii.c']) ) |
|---|
| 233 | n/a | |
|---|
| 234 | n/a | # Fred Drake's interface to the Python parser |
|---|
| 235 | n/a | exts.append( Extension('parser', ['parsermodule.c']) ) |
|---|
| 236 | n/a | |
|---|
| 237 | n/a | # cStringIO and cPickle |
|---|
| 238 | n/a | exts.append( Extension('cStringIO', ['cStringIO.c']) ) |
|---|
| 239 | n/a | exts.append( Extension('cPickle', ['cPickle.c']) ) |
|---|
| 240 | n/a | |
|---|
| 241 | n/a | # Memory-mapped files (also works on Win32). |
|---|
| 242 | n/a | exts.append( Extension('mmap', ['mmapmodule.c']) ) |
|---|
| 243 | n/a | |
|---|
| 244 | n/a | # Lance Ellinghaus's syslog daemon interface |
|---|
| 245 | n/a | exts.append( Extension('syslog', ['syslogmodule.c']) ) |
|---|
| 246 | n/a | |
|---|
| 247 | n/a | # George Neville-Neil's timing module: |
|---|
| 248 | n/a | exts.append( Extension('timing', ['timingmodule.c']) ) |
|---|
| 249 | n/a | |
|---|
| 250 | n/a | # |
|---|
| 251 | n/a | # Here ends the simple stuff. From here on, modules need certain |
|---|
| 252 | n/a | # libraries, are platform-specific, or present other surprises. |
|---|
| 253 | n/a | # |
|---|
| 254 | n/a | |
|---|
| 255 | n/a | # Multimedia modules |
|---|
| 256 | n/a | # These don't work for 64-bit platforms!!! |
|---|
| 257 | n/a | # These represent audio samples or images as strings: |
|---|
| 258 | n/a | |
|---|
| 259 | n/a | # Disabled on 64-bit platforms |
|---|
| 260 | n/a | if sys.maxint != 9223372036854775807L: |
|---|
| 261 | n/a | # Operations on audio samples |
|---|
| 262 | n/a | exts.append( Extension('audioop', ['audioop.c']) ) |
|---|
| 263 | n/a | # Operations on images |
|---|
| 264 | n/a | exts.append( Extension('imageop', ['imageop.c']) ) |
|---|
| 265 | n/a | # Read SGI RGB image files (but coded portably) |
|---|
| 266 | n/a | exts.append( Extension('rgbimg', ['rgbimgmodule.c']) ) |
|---|
| 267 | n/a | |
|---|
| 268 | n/a | # readline |
|---|
| 269 | n/a | if self.compiler.find_library_file(lib_dirs, 'readline'): |
|---|
| 270 | n/a | readline_libs = ['readline'] |
|---|
| 271 | n/a | if self.compiler.find_library_file(lib_dirs + |
|---|
| 272 | n/a | ['/usr/lib/termcap'], |
|---|
| 273 | n/a | 'termcap'): |
|---|
| 274 | n/a | readline_libs.append('termcap') |
|---|
| 275 | n/a | exts.append( Extension('readline', ['readline.c'], |
|---|
| 276 | n/a | library_dirs=['/usr/lib/termcap'], |
|---|
| 277 | n/a | libraries=readline_libs) ) |
|---|
| 278 | n/a | |
|---|
| 279 | n/a | # The crypt module is now disabled by default because it breaks builds |
|---|
| 280 | n/a | # on many systems (where -lcrypt is needed), e.g. Linux (I believe). |
|---|
| 281 | n/a | |
|---|
| 282 | n/a | if self.compiler.find_library_file(lib_dirs, 'crypt'): |
|---|
| 283 | n/a | libs = ['crypt'] |
|---|
| 284 | n/a | else: |
|---|
| 285 | n/a | libs = [] |
|---|
| 286 | n/a | exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) |
|---|
| 287 | n/a | |
|---|
| 288 | n/a | # socket(2) |
|---|
| 289 | n/a | # Detect SSL support for the socket module |
|---|
| 290 | n/a | ssl_incs = find_file('openssl/ssl.h', inc_dirs, |
|---|
| 291 | n/a | ['/usr/local/ssl/include', |
|---|
| 292 | n/a | '/usr/contrib/ssl/include/' |
|---|
| 293 | n/a | ] |
|---|
| 294 | n/a | ) |
|---|
| 295 | n/a | ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, |
|---|
| 296 | n/a | ['/usr/local/ssl/lib', |
|---|
| 297 | n/a | '/usr/contrib/ssl/lib/' |
|---|
| 298 | n/a | ] ) |
|---|
| 299 | n/a | |
|---|
| 300 | n/a | if (ssl_incs is not None and |
|---|
| 301 | n/a | ssl_libs is not None): |
|---|
| 302 | n/a | exts.append( Extension('_socket', ['socketmodule.c'], |
|---|
| 303 | n/a | include_dirs = ssl_incs, |
|---|
| 304 | n/a | library_dirs = ssl_libs, |
|---|
| 305 | n/a | libraries = ['ssl', 'crypto'], |
|---|
| 306 | n/a | define_macros = [('USE_SSL',1)] ) ) |
|---|
| 307 | n/a | else: |
|---|
| 308 | n/a | exts.append( Extension('_socket', ['socketmodule.c']) ) |
|---|
| 309 | n/a | |
|---|
| 310 | n/a | # Modules that provide persistent dictionary-like semantics. You will |
|---|
| 311 | n/a | # probably want to arrange for at least one of them to be available on |
|---|
| 312 | n/a | # your machine, though none are defined by default because of library |
|---|
| 313 | n/a | # dependencies. The Python module anydbm.py provides an |
|---|
| 314 | n/a | # implementation independent wrapper for these; dumbdbm.py provides |
|---|
| 315 | n/a | # similar functionality (but slower of course) implemented in Python. |
|---|
| 316 | n/a | |
|---|
| 317 | n/a | # The standard Unix dbm module: |
|---|
| 318 | n/a | if platform not in ['cygwin']: |
|---|
| 319 | n/a | if (self.compiler.find_library_file(lib_dirs, 'ndbm')): |
|---|
| 320 | n/a | exts.append( Extension('dbm', ['dbmmodule.c'], |
|---|
| 321 | n/a | libraries = ['ndbm'] ) ) |
|---|
| 322 | n/a | else: |
|---|
| 323 | n/a | exts.append( Extension('dbm', ['dbmmodule.c']) ) |
|---|
| 324 | n/a | |
|---|
| 325 | n/a | # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: |
|---|
| 326 | n/a | if (self.compiler.find_library_file(lib_dirs, 'gdbm')): |
|---|
| 327 | n/a | exts.append( Extension('gdbm', ['gdbmmodule.c'], |
|---|
| 328 | n/a | libraries = ['gdbm'] ) ) |
|---|
| 329 | n/a | |
|---|
| 330 | n/a | # Berkeley DB interface. |
|---|
| 331 | n/a | # |
|---|
| 332 | n/a | # This requires the Berkeley DB code, see |
|---|
| 333 | n/a | # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz |
|---|
| 334 | n/a | # |
|---|
| 335 | n/a | # Edit the variables DB and DBPORT to point to the db top directory |
|---|
| 336 | n/a | # and the subdirectory of PORT where you built it. |
|---|
| 337 | n/a | # |
|---|
| 338 | n/a | # (See http://electricrain.com/greg/python/bsddb3/ for an interface to |
|---|
| 339 | n/a | # BSD DB 3.x.) |
|---|
| 340 | n/a | |
|---|
| 341 | n/a | dblib = [] |
|---|
| 342 | n/a | if self.compiler.find_library_file(lib_dirs, 'db'): |
|---|
| 343 | n/a | dblib = ['db'] |
|---|
| 344 | n/a | |
|---|
| 345 | n/a | db185_incs = find_file('db_185.h', inc_dirs, |
|---|
| 346 | n/a | ['/usr/include/db3', '/usr/include/db2']) |
|---|
| 347 | n/a | db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) |
|---|
| 348 | n/a | if db185_incs is not None: |
|---|
| 349 | n/a | exts.append( Extension('bsddb', ['bsddbmodule.c'], |
|---|
| 350 | n/a | include_dirs = db185_incs, |
|---|
| 351 | n/a | define_macros=[('HAVE_DB_185_H',1)], |
|---|
| 352 | n/a | libraries = dblib ) ) |
|---|
| 353 | n/a | elif db_inc is not None: |
|---|
| 354 | n/a | exts.append( Extension('bsddb', ['bsddbmodule.c'], |
|---|
| 355 | n/a | include_dirs = db_inc, |
|---|
| 356 | n/a | libraries = dblib) ) |
|---|
| 357 | n/a | |
|---|
| 358 | n/a | # Unix-only modules |
|---|
| 359 | n/a | if platform == 'win32': |
|---|
| 360 | n/a | # Steen Lumholt's termios module |
|---|
| 361 | n/a | exts.append( Extension('termios', ['termios.c']) ) |
|---|
| 362 | n/a | # Jeremy Hylton's rlimit interface |
|---|
| 363 | n/a | if platform not in ['cygwin']: |
|---|
| 364 | n/a | exts.append( Extension('resource', ['resource.c']) ) |
|---|
| 365 | n/a | |
|---|
| 366 | n/a | # Generic dynamic loading module |
|---|
| 367 | n/a | #exts.append( Extension('dl', ['dlmodule.c']) ) |
|---|
| 368 | n/a | |
|---|
| 369 | n/a | # Sun yellow pages. Some systems have the functions in libc. |
|---|
| 370 | n/a | if platform not in ['cygwin']: |
|---|
| 371 | n/a | if (self.compiler.find_library_file(lib_dirs, 'nsl')): |
|---|
| 372 | n/a | libs = ['nsl'] |
|---|
| 373 | n/a | else: |
|---|
| 374 | n/a | libs = [] |
|---|
| 375 | n/a | exts.append( Extension('nis', ['nismodule.c'], |
|---|
| 376 | n/a | libraries = libs) ) |
|---|
| 377 | n/a | |
|---|
| 378 | n/a | # Curses support, requring the System V version of curses, often |
|---|
| 379 | n/a | # provided by the ncurses library. |
|---|
| 380 | n/a | if (self.compiler.find_library_file(lib_dirs, 'ncurses')): |
|---|
| 381 | n/a | curses_libs = ['ncurses'] |
|---|
| 382 | n/a | exts.append( Extension('_curses', ['_cursesmodule.c'], |
|---|
| 383 | n/a | libraries = curses_libs) ) |
|---|
| 384 | n/a | elif (self.compiler.find_library_file(lib_dirs, 'curses')): |
|---|
| 385 | n/a | if (self.compiler.find_library_file(lib_dirs, 'terminfo')): |
|---|
| 386 | n/a | curses_libs = ['curses', 'terminfo'] |
|---|
| 387 | n/a | else: |
|---|
| 388 | n/a | curses_libs = ['curses', 'termcap'] |
|---|
| 389 | n/a | |
|---|
| 390 | n/a | exts.append( Extension('_curses', ['_cursesmodule.c'], |
|---|
| 391 | n/a | libraries = curses_libs) ) |
|---|
| 392 | n/a | |
|---|
| 393 | n/a | # If the curses module is enabled, check for the panel module |
|---|
| 394 | n/a | if (os.path.exists('Modules/_curses_panel.c') and |
|---|
| 395 | n/a | module_enabled(exts, '_curses') and |
|---|
| 396 | n/a | self.compiler.find_library_file(lib_dirs, 'panel')): |
|---|
| 397 | n/a | exts.append( Extension('_curses_panel', ['_curses_panel.c'], |
|---|
| 398 | n/a | libraries = ['panel'] + curses_libs) ) |
|---|
| 399 | n/a | |
|---|
| 400 | n/a | |
|---|
| 401 | n/a | |
|---|
| 402 | n/a | # Lee Busby's SIGFPE modules. |
|---|
| 403 | n/a | # The library to link fpectl with is platform specific. |
|---|
| 404 | n/a | # Choose *one* of the options below for fpectl: |
|---|
| 405 | n/a | |
|---|
| 406 | n/a | if platform == 'irix5': |
|---|
| 407 | n/a | # For SGI IRIX (tested on 5.3): |
|---|
| 408 | n/a | exts.append( Extension('fpectl', ['fpectlmodule.c'], |
|---|
| 409 | n/a | libraries=['fpe']) ) |
|---|
| 410 | n/a | elif 0: # XXX how to detect SunPro? |
|---|
| 411 | n/a | # For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): |
|---|
| 412 | n/a | # (Without the compiler you don't have -lsunmath.) |
|---|
| 413 | n/a | #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm |
|---|
| 414 | n/a | pass |
|---|
| 415 | n/a | else: |
|---|
| 416 | n/a | # For other systems: see instructions in fpectlmodule.c. |
|---|
| 417 | n/a | #fpectl fpectlmodule.c ... |
|---|
| 418 | n/a | exts.append( Extension('fpectl', ['fpectlmodule.c']) ) |
|---|
| 419 | n/a | |
|---|
| 420 | n/a | |
|---|
| 421 | n/a | # Andrew Kuchling's zlib module. |
|---|
| 422 | n/a | # This require zlib 1.1.3 (or later). |
|---|
| 423 | n/a | # See http://www.gzip.org/zlib/ |
|---|
| 424 | n/a | if (self.compiler.find_library_file(lib_dirs, 'z')): |
|---|
| 425 | n/a | exts.append( Extension('zlib', ['zlibmodule.c'], |
|---|
| 426 | n/a | libraries = ['z']) ) |
|---|
| 427 | n/a | |
|---|
| 428 | n/a | # Interface to the Expat XML parser |
|---|
| 429 | n/a | # |
|---|
| 430 | n/a | # Expat is written by James Clark and must be downloaded separately |
|---|
| 431 | n/a | # (see below). The pyexpat module was written by Paul Prescod after a |
|---|
| 432 | n/a | # prototype by Jack Jansen. |
|---|
| 433 | n/a | # |
|---|
| 434 | n/a | # The Expat dist includes Windows .lib and .dll files. Home page is |
|---|
| 435 | n/a | # at http://www.jclark.com/xml/expat.html, the current production |
|---|
| 436 | n/a | # release is always ftp://ftp.jclark.com/pub/xml/expat.zip. |
|---|
| 437 | n/a | # |
|---|
| 438 | n/a | # EXPAT_DIR, below, should point to the expat/ directory created by |
|---|
| 439 | n/a | # unpacking the Expat source distribution. |
|---|
| 440 | n/a | # |
|---|
| 441 | n/a | # Note: the expat build process doesn't yet build a libexpat.a; you |
|---|
| 442 | n/a | # can do this manually while we try convince the author to add it. To |
|---|
| 443 | n/a | # do so, cd to EXPAT_DIR, run "make" if you have not done so, then |
|---|
| 444 | n/a | # run: |
|---|
| 445 | n/a | # |
|---|
| 446 | n/a | # ar cr libexpat.a xmltok/*.o xmlparse/*.o |
|---|
| 447 | n/a | # |
|---|
| 448 | n/a | expat_defs = [] |
|---|
| 449 | n/a | expat_incs = find_file('expat.h', inc_dirs, []) |
|---|
| 450 | n/a | if expat_incs is not None: |
|---|
| 451 | n/a | # expat.h was found |
|---|
| 452 | n/a | expat_defs = [('HAVE_EXPAT_H', 1)] |
|---|
| 453 | n/a | else: |
|---|
| 454 | n/a | expat_incs = find_file('xmlparse.h', inc_dirs, []) |
|---|
| 455 | n/a | |
|---|
| 456 | n/a | if (expat_incs is not None and |
|---|
| 457 | n/a | self.compiler.find_library_file(lib_dirs, 'expat')): |
|---|
| 458 | n/a | exts.append( Extension('pyexpat', ['pyexpat.c'], |
|---|
| 459 | n/a | define_macros = expat_defs, |
|---|
| 460 | n/a | libraries = ['expat']) ) |
|---|
| 461 | n/a | |
|---|
| 462 | n/a | # Platform-specific libraries |
|---|
| 463 | n/a | if platform == 'linux2': |
|---|
| 464 | n/a | # Linux-specific modules |
|---|
| 465 | n/a | exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) |
|---|
| 466 | n/a | |
|---|
| 467 | n/a | if platform == 'sunos5': |
|---|
| 468 | n/a | # SunOS specific modules |
|---|
| 469 | n/a | exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) |
|---|
| 470 | n/a | |
|---|
| 471 | n/a | self.extensions.extend(exts) |
|---|
| 472 | n/a | |
|---|
| 473 | n/a | # Call the method for detecting whether _tkinter can be compiled |
|---|
| 474 | n/a | self.detect_tkinter(inc_dirs, lib_dirs) |
|---|
| 475 | n/a | |
|---|
| 476 | n/a | |
|---|
| 477 | n/a | def detect_tkinter(self, inc_dirs, lib_dirs): |
|---|
| 478 | n/a | # The _tkinter module. |
|---|
| 479 | n/a | |
|---|
| 480 | n/a | # Assume we haven't found any of the libraries or include files |
|---|
| 481 | n/a | tcllib = tklib = tcl_includes = tk_includes = None |
|---|
| 482 | n/a | for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: |
|---|
| 483 | n/a | tklib = self.compiler.find_library_file(lib_dirs, |
|---|
| 484 | n/a | 'tk' + version ) |
|---|
| 485 | n/a | tcllib = self.compiler.find_library_file(lib_dirs, |
|---|
| 486 | n/a | 'tcl' + version ) |
|---|
| 487 | n/a | if tklib and tcllib: |
|---|
| 488 | n/a | # Exit the loop when we've found the Tcl/Tk libraries |
|---|
| 489 | n/a | break |
|---|
| 490 | n/a | |
|---|
| 491 | n/a | # Now check for the header files |
|---|
| 492 | n/a | if tklib and tcllib: |
|---|
| 493 | n/a | # Check for the include files on Debian, where |
|---|
| 494 | n/a | # they're put in /usr/include/{tcl,tk}X.Y |
|---|
| 495 | n/a | debian_tcl_include = [ '/usr/include/tcl' + version ] |
|---|
| 496 | n/a | debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include |
|---|
| 497 | n/a | tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) |
|---|
| 498 | n/a | tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) |
|---|
| 499 | n/a | |
|---|
| 500 | n/a | if (tcllib is None or tklib is None and |
|---|
| 501 | n/a | tcl_includes is None or tk_includes is None): |
|---|
| 502 | n/a | # Something's missing, so give up |
|---|
| 503 | n/a | return |
|---|
| 504 | n/a | |
|---|
| 505 | n/a | # OK... everything seems to be present for Tcl/Tk. |
|---|
| 506 | n/a | |
|---|
| 507 | n/a | include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] |
|---|
| 508 | n/a | for dir in tcl_includes + tk_includes: |
|---|
| 509 | n/a | if dir not in include_dirs: |
|---|
| 510 | n/a | include_dirs.append(dir) |
|---|
| 511 | n/a | |
|---|
| 512 | n/a | # Check for various platform-specific directories |
|---|
| 513 | n/a | platform = self.get_platform() |
|---|
| 514 | n/a | if platform == 'sunos5': |
|---|
| 515 | n/a | include_dirs.append('/usr/openwin/include') |
|---|
| 516 | n/a | added_lib_dirs.append('/usr/openwin/lib') |
|---|
| 517 | n/a | elif os.path.exists('/usr/X11R6/include'): |
|---|
| 518 | n/a | include_dirs.append('/usr/X11R6/include') |
|---|
| 519 | n/a | added_lib_dirs.append('/usr/X11R6/lib') |
|---|
| 520 | n/a | elif os.path.exists('/usr/X11R5/include'): |
|---|
| 521 | n/a | include_dirs.append('/usr/X11R5/include') |
|---|
| 522 | n/a | added_lib_dirs.append('/usr/X11R5/lib') |
|---|
| 523 | n/a | else: |
|---|
| 524 | n/a | # Assume default location for X11 |
|---|
| 525 | n/a | include_dirs.append('/usr/X11/include') |
|---|
| 526 | n/a | added_lib_dirs.append('/usr/X11/lib') |
|---|
| 527 | n/a | |
|---|
| 528 | n/a | # Check for BLT extension |
|---|
| 529 | n/a | if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'BLT8.0'): |
|---|
| 530 | n/a | defs.append( ('WITH_BLT', 1) ) |
|---|
| 531 | n/a | libs.append('BLT8.0') |
|---|
| 532 | n/a | |
|---|
| 533 | n/a | # Add the Tcl/Tk libraries |
|---|
| 534 | n/a | libs.append('tk'+version) |
|---|
| 535 | n/a | libs.append('tcl'+version) |
|---|
| 536 | n/a | |
|---|
| 537 | n/a | if platform in ['aix3', 'aix4']: |
|---|
| 538 | n/a | libs.append('ld') |
|---|
| 539 | n/a | |
|---|
| 540 | n/a | # Finally, link with the X11 libraries |
|---|
| 541 | n/a | libs.append('X11') |
|---|
| 542 | n/a | |
|---|
| 543 | n/a | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], |
|---|
| 544 | n/a | define_macros=[('WITH_APPINIT', 1)] + defs, |
|---|
| 545 | n/a | include_dirs = include_dirs, |
|---|
| 546 | n/a | libraries = libs, |
|---|
| 547 | n/a | library_dirs = added_lib_dirs, |
|---|
| 548 | n/a | ) |
|---|
| 549 | n/a | self.extensions.append(ext) |
|---|
| 550 | n/a | |
|---|
| 551 | n/a | # XXX handle these, but how to detect? |
|---|
| 552 | n/a | # *** Uncomment and edit for PIL (TkImaging) extension only: |
|---|
| 553 | n/a | # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ |
|---|
| 554 | n/a | # *** Uncomment and edit for TOGL extension only: |
|---|
| 555 | n/a | # -DWITH_TOGL togl.c \ |
|---|
| 556 | n/a | # *** Uncomment these for TOGL extension only: |
|---|
| 557 | n/a | # -lGL -lGLU -lXext -lXmu \ |
|---|
| 558 | n/a | |
|---|
| 559 | n/a | def main(): |
|---|
| 560 | n/a | setup(name = 'Python standard library', |
|---|
| 561 | n/a | version = '%d.%d' % sys.version_info[:2], |
|---|
| 562 | n/a | cmdclass = {'build_ext':PyBuildExt}, |
|---|
| 563 | n/a | # The struct module is defined here, because build_ext won't be |
|---|
| 564 | n/a | # called unless there's at least one extension module defined. |
|---|
| 565 | n/a | ext_modules=[Extension('struct', ['structmodule.c'])], |
|---|
| 566 | n/a | |
|---|
| 567 | n/a | # Scripts to install |
|---|
| 568 | n/a | scripts = ['Tools/scripts/pydoc'] |
|---|
| 569 | n/a | ) |
|---|
| 570 | n/a | |
|---|
| 571 | n/a | # --install-platlib |
|---|
| 572 | n/a | if __name__ == '__main__': |
|---|
| 573 | n/a | sysconfig.set_python_build() |
|---|
| 574 | n/a | main() |
|---|