2001-01-26 17:56:58 -04:00
|
|
|
# Autodetecting setup.py script for building the Python extensions
|
|
|
|
#
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-26 17:56:58 -04:00
|
|
|
__version__ = "$Revision$"
|
|
|
|
|
2002-01-23 11:07:46 -04:00
|
|
|
import sys, os, getopt, imp
|
2001-01-17 11:23:23 -04:00
|
|
|
from distutils import sysconfig
|
2001-02-23 12:32:32 -04:00
|
|
|
from distutils import text_file
|
2001-01-26 14:03:24 -04:00
|
|
|
from distutils.errors import *
|
2001-01-17 11:23:23 -04:00
|
|
|
from distutils.core import Extension, setup
|
|
|
|
from distutils.command.build_ext import build_ext
|
2001-05-21 17:29:27 -03:00
|
|
|
from distutils.command.install import install
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# This global variable is used to hold the list of modules to be disabled.
|
|
|
|
disabled_module_list = []
|
|
|
|
|
2002-01-16 11:26:48 -04:00
|
|
|
def add_dir_to_list(dirlist, dir):
|
|
|
|
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
|
|
|
|
1) 'dir' is not already in 'dirlist'
|
|
|
|
2) 'dir' actually exists, and is a directory."""
|
|
|
|
if os.path.isdir(dir) and dir not in dirlist:
|
|
|
|
dirlist.insert(0, dir)
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
def find_file(filename, std_dirs, paths):
|
|
|
|
"""Searches for the directory where a given file is located,
|
|
|
|
and returns a possibly-empty list of additional directories, or None
|
|
|
|
if the file couldn't be found at all.
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
'filename' is the name of a file, such as readline.h or libcrypto.a.
|
|
|
|
'std_dirs' is the list of standard system directories; if the
|
|
|
|
file is found in one of them, no additional directives are needed.
|
|
|
|
'paths' is a list of additional locations to check; if the file is
|
|
|
|
found in one of them, the resulting list will contain the directory.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Check the standard locations
|
|
|
|
for dir in std_dirs:
|
|
|
|
f = os.path.join(dir, filename)
|
|
|
|
if os.path.exists(f): return []
|
|
|
|
|
|
|
|
# Check the additional directories
|
|
|
|
for dir in paths:
|
|
|
|
f = os.path.join(dir, filename)
|
|
|
|
if os.path.exists(f):
|
|
|
|
return [dir]
|
|
|
|
|
|
|
|
# Not found anywhere
|
2001-01-17 11:23:23 -04:00
|
|
|
return None
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
def find_library_file(compiler, libname, std_dirs, paths):
|
|
|
|
filename = compiler.library_filename(libname, lib_type='shared')
|
|
|
|
result = find_file(filename, std_dirs, paths)
|
|
|
|
if result is not None: return result
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
filename = compiler.library_filename(libname, lib_type='static')
|
|
|
|
result = find_file(filename, std_dirs, paths)
|
|
|
|
return result
|
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
def module_enabled(extlist, modname):
|
|
|
|
"""Returns whether the module 'modname' is present in the list
|
|
|
|
of extensions 'extlist'."""
|
|
|
|
extlist = [ext for ext in extlist if ext.name == modname]
|
|
|
|
return len(extlist)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-08-05 19:31:19 -03:00
|
|
|
def find_module_file(module, dirlist):
|
|
|
|
"""Find a module in a set of possible folders. If it is not found
|
|
|
|
return the unadorned filename"""
|
|
|
|
list = find_file(module, [], dirlist)
|
|
|
|
if not list:
|
|
|
|
return module
|
|
|
|
if len(list) > 1:
|
|
|
|
self.announce("WARNING: multiple copies of %s found"%module)
|
|
|
|
return os.path.join(list[0], module)
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
class PyBuildExt(build_ext):
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
def build_extensions(self):
|
|
|
|
|
|
|
|
# Detect which modules should be compiled
|
|
|
|
self.detect_modules()
|
|
|
|
|
|
|
|
# Remove modules that are present on the disabled list
|
|
|
|
self.extensions = [ext for ext in self.extensions
|
|
|
|
if ext.name not in disabled_module_list]
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# Fix up the autodetected modules, prefixing all the source files
|
|
|
|
# with Modules/ and adding Python's include directory to the path.
|
|
|
|
(srcdir,) = sysconfig.get_config_vars('srcdir')
|
|
|
|
|
2001-01-24 13:18:21 -04:00
|
|
|
# Figure out the location of the source code for extension modules
|
|
|
|
moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
|
2001-01-17 11:23:23 -04:00
|
|
|
moddir = os.path.normpath(moddir)
|
|
|
|
srcdir, tail = os.path.split(moddir)
|
|
|
|
srcdir = os.path.normpath(srcdir)
|
|
|
|
moddir = os.path.normpath(moddir)
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-08-05 19:31:19 -03:00
|
|
|
moddirlist = [moddir]
|
|
|
|
incdirlist = ['./Include']
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-08-05 19:31:19 -03:00
|
|
|
# Platform-dependent module source and include directories
|
|
|
|
platform = self.get_platform()
|
2001-12-05 11:54:29 -04:00
|
|
|
if platform == 'darwin':
|
2001-08-05 19:31:19 -03:00
|
|
|
# Mac OS X also includes some mac-specific modules
|
|
|
|
macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
|
|
|
|
moddirlist.append(macmoddir)
|
|
|
|
incdirlist.append('./Mac/Include')
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-02-28 18:49:26 -04:00
|
|
|
# Fix up the paths for scripts, too
|
|
|
|
self.distribution.scripts = [os.path.join(srcdir, filename)
|
|
|
|
for filename in self.distribution.scripts]
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
for ext in self.extensions[:]:
|
2001-08-05 19:31:19 -03:00
|
|
|
ext.sources = [ find_module_file(filename, moddirlist)
|
2001-01-17 11:23:23 -04:00
|
|
|
for filename in ext.sources ]
|
2001-08-05 19:31:19 -03:00
|
|
|
ext.include_dirs.append( '.' ) # to get config.h
|
|
|
|
for incdir in incdirlist:
|
|
|
|
ext.include_dirs.append( os.path.join(srcdir, incdir) )
|
2001-01-18 14:44:20 -04:00
|
|
|
|
2001-01-19 12:58:21 -04:00
|
|
|
# If a module has already been built statically,
|
2001-01-18 14:44:20 -04:00
|
|
|
# don't build it here
|
2001-01-19 12:58:21 -04:00
|
|
|
if ext.name in sys.builtin_module_names:
|
2001-01-18 14:44:20 -04:00
|
|
|
self.extensions.remove(ext)
|
2001-01-18 16:39:34 -04:00
|
|
|
|
2001-02-23 12:32:32 -04:00
|
|
|
# Parse Modules/Setup to figure out which modules are turned
|
2002-01-23 11:04:41 -04:00
|
|
|
# on in the file.
|
2001-02-23 12:32:32 -04:00
|
|
|
input = text_file.TextFile('Modules/Setup', join_lines=1)
|
|
|
|
remove_modules = []
|
|
|
|
while 1:
|
|
|
|
line = input.readline()
|
|
|
|
if not line: break
|
|
|
|
line = line.split()
|
|
|
|
remove_modules.append( line[0] )
|
|
|
|
input.close()
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-02-23 12:32:32 -04:00
|
|
|
for ext in self.extensions[:]:
|
|
|
|
if ext.name in remove_modules:
|
|
|
|
self.extensions.remove(ext)
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-18 16:39:34 -04:00
|
|
|
# When you run "make CC=altcc" or something similar, you really want
|
|
|
|
# those environment variables passed into the setup.py phase. Here's
|
|
|
|
# a small set of useful ones.
|
|
|
|
compiler = os.environ.get('CC')
|
|
|
|
linker_so = os.environ.get('LDSHARED')
|
|
|
|
args = {}
|
|
|
|
# unfortunately, distutils doesn't let us provide separate C and C++
|
|
|
|
# compilers
|
|
|
|
if compiler is not None:
|
2001-08-10 05:56:17 -03:00
|
|
|
(ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT')
|
|
|
|
args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared
|
2001-01-18 16:39:34 -04:00
|
|
|
if linker_so is not None:
|
2001-10-08 10:18:37 -03:00
|
|
|
args['linker_so'] = linker_so
|
2001-01-18 16:39:34 -04:00
|
|
|
self.compiler.set_executables(**args)
|
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
build_ext.build_extensions(self)
|
|
|
|
|
2001-01-26 14:03:24 -04:00
|
|
|
def build_extension(self, ext):
|
|
|
|
|
|
|
|
try:
|
|
|
|
build_ext.build_extension(self, ext)
|
|
|
|
except (CCompilerError, DistutilsError), why:
|
|
|
|
self.announce('WARNING: building of extension "%s" failed: %s' %
|
|
|
|
(ext.name, sys.exc_info()[1]))
|
2001-05-21 17:48:09 -03:00
|
|
|
return
|
2001-11-01 10:44:15 -04:00
|
|
|
# Workaround for Mac OS X: The Carbon-based modules cannot be
|
|
|
|
# reliably imported into a command-line Python
|
|
|
|
if 'Carbon' in ext.extra_link_args:
|
2002-01-23 11:04:41 -04:00
|
|
|
self.announce(
|
|
|
|
'WARNING: skipping import check for Carbon-based "%s"' %
|
|
|
|
ext.name)
|
|
|
|
return
|
2002-01-23 11:07:46 -04:00
|
|
|
ext_filename = os.path.join(
|
|
|
|
self.build_lib,
|
|
|
|
self.get_ext_filename(self.get_ext_fullname(ext.name)))
|
2001-05-21 17:48:09 -03:00
|
|
|
try:
|
2002-01-23 11:07:46 -04:00
|
|
|
imp.load_dynamic(ext.name, ext_filename)
|
2002-02-16 14:23:30 -04:00
|
|
|
except ImportError, why:
|
|
|
|
|
|
|
|
if 1:
|
2002-03-01 10:16:31 -04:00
|
|
|
self.announce('*** WARNING: renaming "%s" since importing it'
|
2002-02-16 14:23:30 -04:00
|
|
|
' failed: %s' % (ext.name, why))
|
|
|
|
assert not self.inplace
|
2002-03-01 10:16:31 -04:00
|
|
|
basename, tail = os.path.splitext(ext_filename)
|
|
|
|
newname = basename + "_failed" + tail
|
|
|
|
if os.path.exists(newname): os.remove(newname)
|
|
|
|
os.rename(ext_filename, newname)
|
2002-02-16 14:23:30 -04:00
|
|
|
|
|
|
|
# XXX -- This relies on a Vile HACK in
|
|
|
|
# distutils.command.build_ext.build_extension(). The
|
|
|
|
# _built_objects attribute is stored there strictly for
|
|
|
|
# use here.
|
2002-03-25 10:20:09 -04:00
|
|
|
# If there is a failure, _built_objects may not be there,
|
|
|
|
# so catch the AttributeError and move on.
|
|
|
|
try:
|
|
|
|
for filename in self._built_objects:
|
|
|
|
os.remove(filename)
|
|
|
|
except AttributeError:
|
|
|
|
self.announce('unable to remove files (ignored)')
|
2002-02-16 14:23:30 -04:00
|
|
|
else:
|
|
|
|
self.announce('*** WARNING: importing extension "%s" '
|
|
|
|
'failed: %s' % (ext.name, why))
|
2001-12-06 18:59:54 -04:00
|
|
|
|
2001-01-23 23:31:07 -04:00
|
|
|
def get_platform (self):
|
2001-01-24 04:00:28 -04:00
|
|
|
# Get value of sys.platform
|
|
|
|
platform = sys.platform
|
|
|
|
if platform[:6] =='cygwin':
|
|
|
|
platform = 'cygwin'
|
2001-02-06 19:37:23 -04:00
|
|
|
elif platform[:4] =='beos':
|
|
|
|
platform = 'beos'
|
2001-12-05 11:54:29 -04:00
|
|
|
elif platform[:6] == 'darwin':
|
|
|
|
platform = 'darwin'
|
2001-01-23 23:31:07 -04:00
|
|
|
|
2001-01-24 04:00:28 -04:00
|
|
|
return platform
|
2001-01-23 23:31:07 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
def detect_modules(self):
|
2001-01-24 04:00:28 -04:00
|
|
|
# Ensure that /usr/local is always used
|
2002-01-16 11:26:48 -04:00
|
|
|
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
|
|
|
|
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
|
|
|
|
|
|
|
add_dir_to_list(self.compiler.library_dirs,
|
|
|
|
sysconfig.get_config_var("LIBDIR"))
|
|
|
|
add_dir_to_list(self.compiler.include_dirs,
|
|
|
|
sysconfig.get_config_var("INCLUDEDIR"))
|
2001-01-18 14:44:20 -04:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
try:
|
|
|
|
have_unicode = unicode
|
|
|
|
except NameError:
|
|
|
|
have_unicode = 0
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# lib_dirs and inc_dirs are used to search for files;
|
|
|
|
# if a file is found in one of those directories, it can
|
|
|
|
# be assumed that no additional -I,-L directives are needed.
|
|
|
|
lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
|
2002-01-23 11:04:41 -04:00
|
|
|
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
2001-01-17 11:23:23 -04:00
|
|
|
exts = []
|
|
|
|
|
2001-01-24 04:00:28 -04:00
|
|
|
platform = self.get_platform()
|
2002-02-13 21:25:37 -04:00
|
|
|
(srcdir,) = sysconfig.get_config_vars('srcdir')
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-24 04:00:28 -04:00
|
|
|
# Check for MacOS X, which doesn't need libm.a at all
|
|
|
|
math_libs = ['m']
|
2001-12-05 11:54:29 -04:00
|
|
|
if platform in ['darwin', 'beos']:
|
2001-01-24 04:00:28 -04:00
|
|
|
math_libs = []
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following modules are all pretty straightforward, and compile
|
|
|
|
# on pretty much any POSIXish platform.
|
|
|
|
#
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# Some modules that are normally always on:
|
|
|
|
exts.append( Extension('regex', ['regexmodule.c', 'regexpr.c']) )
|
|
|
|
exts.append( Extension('pcre', ['pcremodule.c', 'pypcre.c']) )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-10-12 18:00:48 -03:00
|
|
|
exts.append( Extension('_hotshot', ['_hotshot.c']) )
|
2001-02-01 01:26:54 -04:00
|
|
|
exts.append( Extension('_weakref', ['_weakref.c']) )
|
2001-01-17 11:59:25 -04:00
|
|
|
exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# array objects
|
|
|
|
exts.append( Extension('array', ['arraymodule.c']) )
|
|
|
|
# complex math library functions
|
2001-01-23 18:21:11 -04:00
|
|
|
exts.append( Extension('cmath', ['cmathmodule.c'],
|
|
|
|
libraries=math_libs) )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# math library functions, e.g. sin()
|
2001-01-23 18:21:11 -04:00
|
|
|
exts.append( Extension('math', ['mathmodule.c'],
|
|
|
|
libraries=math_libs) )
|
2001-01-17 11:23:23 -04:00
|
|
|
# fast string operations implemented in C
|
|
|
|
exts.append( Extension('strop', ['stropmodule.c']) )
|
|
|
|
# time operations and variables
|
2001-01-23 18:21:11 -04:00
|
|
|
exts.append( Extension('time', ['timemodule.c'],
|
|
|
|
libraries=math_libs) )
|
2001-01-17 11:23:23 -04:00
|
|
|
# operator.add() and similar goodies
|
|
|
|
exts.append( Extension('operator', ['operator.c']) )
|
|
|
|
# access to the builtin codecs and codec registry
|
|
|
|
exts.append( Extension('_codecs', ['_codecsmodule.c']) )
|
2001-02-02 08:12:44 -04:00
|
|
|
# Python C API test module
|
2001-02-03 23:09:53 -04:00
|
|
|
exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
# static Unicode character database
|
2001-08-17 15:39:25 -03:00
|
|
|
if have_unicode:
|
|
|
|
exts.append( Extension('unicodedata', ['unicodedata.c']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
# access to ISO C locale support
|
|
|
|
exts.append( Extension('_locale', ['_localemodule.c']) )
|
|
|
|
|
|
|
|
# Modules with some UNIX dependencies -- on by default:
|
|
|
|
# (If you have a really backward UNIX, select and socket may not be
|
|
|
|
# supported...)
|
|
|
|
|
|
|
|
# fcntl(2) and ioctl(2)
|
|
|
|
exts.append( Extension('fcntl', ['fcntlmodule.c']) )
|
|
|
|
# pwd(3)
|
|
|
|
exts.append( Extension('pwd', ['pwdmodule.c']) )
|
|
|
|
# grp(3)
|
|
|
|
exts.append( Extension('grp', ['grpmodule.c']) )
|
|
|
|
# posix (UNIX) errno values
|
|
|
|
exts.append( Extension('errno', ['errnomodule.c']) )
|
|
|
|
# select(2); not on ancient System V
|
|
|
|
exts.append( Extension('select', ['selectmodule.c']) )
|
|
|
|
|
|
|
|
# The md5 module implements the RSA Data Security, Inc. MD5
|
2001-12-06 18:24:47 -04:00
|
|
|
# Message-Digest Algorithm, described in RFC 1321. The
|
|
|
|
# necessary files md5c.c and md5.h are included here.
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
|
|
|
|
|
|
|
|
# The sha module implements the SHA checksum algorithm.
|
|
|
|
# (NIST's Secure Hash Algorithm.)
|
|
|
|
exts.append( Extension('sha', ['shamodule.c']) )
|
|
|
|
|
|
|
|
# Helper module for various ascii-encoders
|
|
|
|
exts.append( Extension('binascii', ['binascii.c']) )
|
|
|
|
|
|
|
|
# Fred Drake's interface to the Python parser
|
|
|
|
exts.append( Extension('parser', ['parsermodule.c']) )
|
|
|
|
|
2002-04-04 13:52:50 -04:00
|
|
|
# cStringIO and cPickle
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('cStringIO', ['cStringIO.c']) )
|
|
|
|
exts.append( Extension('cPickle', ['cPickle.c']) )
|
|
|
|
|
|
|
|
# Memory-mapped files (also works on Win32).
|
|
|
|
exts.append( Extension('mmap', ['mmapmodule.c']) )
|
|
|
|
|
|
|
|
# Lance Ellinghaus's modules:
|
|
|
|
# enigma-inspired encryption
|
|
|
|
exts.append( Extension('rotor', ['rotormodule.c']) )
|
|
|
|
# syslog daemon interface
|
|
|
|
exts.append( Extension('syslog', ['syslogmodule.c']) )
|
|
|
|
|
|
|
|
# George Neville-Neil's timing module:
|
|
|
|
exts.append( Extension('timing', ['timingmodule.c']) )
|
|
|
|
|
|
|
|
#
|
2001-01-18 16:39:34 -04:00
|
|
|
# Here ends the simple stuff. From here on, modules need certain
|
|
|
|
# libraries, are platform-specific, or present other surprises.
|
2001-01-17 11:23:23 -04:00
|
|
|
#
|
|
|
|
|
|
|
|
# Multimedia modules
|
|
|
|
# These don't work for 64-bit platforms!!!
|
|
|
|
# These represent audio samples or images as strings:
|
|
|
|
|
2001-01-24 04:00:28 -04:00
|
|
|
# Disabled on 64-bit platforms
|
2001-01-17 11:23:23 -04:00
|
|
|
if sys.maxint != 9223372036854775807L:
|
|
|
|
# Operations on audio samples
|
|
|
|
exts.append( Extension('audioop', ['audioop.c']) )
|
|
|
|
# Operations on images
|
|
|
|
exts.append( Extension('imageop', ['imageop.c']) )
|
|
|
|
# Read SGI RGB image files (but coded portably)
|
|
|
|
exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
|
|
|
|
|
|
|
|
# readline
|
2001-01-26 14:23:02 -04:00
|
|
|
if self.compiler.find_library_file(lib_dirs, 'readline'):
|
|
|
|
readline_libs = ['readline']
|
2001-08-16 17:30:18 -03:00
|
|
|
if self.compiler.find_library_file(lib_dirs,
|
|
|
|
'ncurses'):
|
|
|
|
readline_libs.append('ncurses')
|
|
|
|
elif self.compiler.find_library_file(lib_dirs +
|
2001-01-26 14:23:02 -04:00
|
|
|
['/usr/lib/termcap'],
|
|
|
|
'termcap'):
|
|
|
|
readline_libs.append('termcap')
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('readline', ['readline.c'],
|
2001-01-26 14:03:24 -04:00
|
|
|
library_dirs=['/usr/lib/termcap'],
|
2001-01-26 14:23:02 -04:00
|
|
|
libraries=readline_libs) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-08-16 17:30:18 -03:00
|
|
|
# crypt module.
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
if self.compiler.find_library_file(lib_dirs, 'crypt'):
|
|
|
|
libs = ['crypt']
|
|
|
|
else:
|
|
|
|
libs = []
|
|
|
|
exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
|
|
|
|
|
|
|
|
# socket(2)
|
2002-02-16 14:23:30 -04:00
|
|
|
exts.append( Extension('_socket', ['socketmodule.c']) )
|
|
|
|
# Detect SSL support for the socket module (via _ssl)
|
2001-01-18 14:44:20 -04:00
|
|
|
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
|
2001-01-19 12:58:21 -04:00
|
|
|
['/usr/local/ssl/include',
|
|
|
|
'/usr/contrib/ssl/include/'
|
|
|
|
]
|
2001-01-18 14:44:20 -04:00
|
|
|
)
|
|
|
|
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
|
2001-01-19 12:58:21 -04:00
|
|
|
['/usr/local/ssl/lib',
|
|
|
|
'/usr/contrib/ssl/lib/'
|
|
|
|
] )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
if (ssl_incs is not None and
|
|
|
|
ssl_libs is not None):
|
2002-02-16 14:23:30 -04:00
|
|
|
exts.append( Extension('_ssl', ['_ssl.c'],
|
2001-01-18 14:44:20 -04:00
|
|
|
include_dirs = ssl_incs,
|
2001-01-24 04:00:28 -04:00
|
|
|
library_dirs = ssl_libs,
|
2002-02-16 14:23:30 -04:00
|
|
|
libraries = ['ssl', 'crypto']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# Modules that provide persistent dictionary-like semantics. You will
|
|
|
|
# probably want to arrange for at least one of them to be available on
|
|
|
|
# your machine, though none are defined by default because of library
|
|
|
|
# dependencies. The Python module anydbm.py provides an
|
|
|
|
# implementation independent wrapper for these; dumbdbm.py provides
|
|
|
|
# similar functionality (but slower of course) implemented in Python.
|
|
|
|
|
|
|
|
# The standard Unix dbm module:
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform not in ['cygwin']:
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
|
|
|
|
exts.append( Extension('dbm', ['dbmmodule.c'],
|
|
|
|
libraries = ['ndbm'] ) )
|
2001-10-21 19:14:44 -03:00
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db1'):
|
|
|
|
exts.append( Extension('dbm', ['dbmmodule.c'],
|
|
|
|
libraries = ['db1'] ) )
|
2001-01-23 23:31:07 -04:00
|
|
|
else:
|
|
|
|
exts.append( Extension('dbm', ['dbmmodule.c']) )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
|
|
|
|
exts.append( Extension('gdbm', ['gdbmmodule.c'],
|
|
|
|
libraries = ['gdbm'] ) )
|
|
|
|
|
|
|
|
# Berkeley DB interface.
|
|
|
|
#
|
|
|
|
# This requires the Berkeley DB code, see
|
|
|
|
# ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
|
|
|
|
#
|
|
|
|
# Edit the variables DB and DBPORT to point to the db top directory
|
|
|
|
# and the subdirectory of PORT where you built it.
|
|
|
|
#
|
2001-09-13 12:05:08 -03:00
|
|
|
# (See http://pybsddb.sourceforge.net/ for an interface to
|
|
|
|
# Berkeley DB 3.x.)
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-02-23 12:27:48 -04:00
|
|
|
dblib = []
|
2001-11-24 05:28:42 -04:00
|
|
|
if self.compiler.find_library_file(lib_dirs, 'db-3.2'):
|
|
|
|
dblib = ['db-3.2']
|
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db-3.1'):
|
2001-08-21 01:23:21 -03:00
|
|
|
dblib = ['db-3.1']
|
2001-10-21 19:14:44 -03:00
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db3'):
|
|
|
|
dblib = ['db3']
|
2001-08-21 01:23:21 -03:00
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db2'):
|
|
|
|
dblib = ['db2']
|
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db1'):
|
|
|
|
dblib = ['db1']
|
|
|
|
elif self.compiler.find_library_file(lib_dirs, 'db'):
|
2001-02-23 12:27:48 -04:00
|
|
|
dblib = ['db']
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-02-23 12:27:48 -04:00
|
|
|
db185_incs = find_file('db_185.h', inc_dirs,
|
|
|
|
['/usr/include/db3', '/usr/include/db2'])
|
|
|
|
db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
|
|
|
|
if db185_incs is not None:
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('bsddb', ['bsddbmodule.c'],
|
2001-02-23 12:27:48 -04:00
|
|
|
include_dirs = db185_incs,
|
|
|
|
define_macros=[('HAVE_DB_185_H',1)],
|
|
|
|
libraries = dblib ) )
|
|
|
|
elif db_inc is not None:
|
|
|
|
exts.append( Extension('bsddb', ['bsddbmodule.c'],
|
|
|
|
include_dirs = db_inc,
|
|
|
|
libraries = dblib) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# The mpz module interfaces to the GNU Multiple Precision library.
|
2001-01-24 04:00:28 -04:00
|
|
|
# You need to ftp the GNU MP library.
|
2001-01-17 11:23:23 -04:00
|
|
|
# This was originally written and tested against GMP 1.2 and 1.3.2.
|
|
|
|
# It has been modified by Rob Hooft to work with 2.0.2 as well, but I
|
2001-12-17 13:24:43 -04:00
|
|
|
# haven't tested it recently, and it definitely doesn't work with
|
|
|
|
# GMP 4.0. For more complete modules, refer to
|
|
|
|
# http://gmpy.sourceforge.net and
|
|
|
|
# http://www.egenix.com/files/python/mxNumber.html
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-10-03 16:59:30 -03:00
|
|
|
# A compatible MP library unencumbered by the GPL also exists. It was
|
2001-01-17 11:23:23 -04:00
|
|
|
# posted to comp.sources.misc in volume 40 and is widely available from
|
|
|
|
# FTP archive sites. One URL for it is:
|
|
|
|
# ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z
|
|
|
|
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'gmp')):
|
|
|
|
exts.append( Extension('mpz', ['mpzmodule.c'],
|
|
|
|
libraries = ['gmp'] ) )
|
|
|
|
|
|
|
|
|
|
|
|
# Unix-only modules
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform not in ['mac', 'win32']:
|
2001-01-17 11:23:23 -04:00
|
|
|
# Steen Lumholt's termios module
|
|
|
|
exts.append( Extension('termios', ['termios.c']) )
|
|
|
|
# Jeremy Hylton's rlimit interface
|
2001-09-17 13:19:16 -03:00
|
|
|
exts.append( Extension('resource', ['resource.c']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-02-20 22:38:24 -04:00
|
|
|
# Sun yellow pages. Some systems have the functions in libc.
|
2001-02-27 16:54:23 -04:00
|
|
|
if platform not in ['cygwin']:
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'nsl')):
|
|
|
|
libs = ['nsl']
|
|
|
|
else:
|
|
|
|
libs = []
|
|
|
|
exts.append( Extension('nis', ['nismodule.c'],
|
|
|
|
libraries = libs) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# Curses support, requring the System V version of curses, often
|
2001-01-24 04:00:28 -04:00
|
|
|
# provided by the ncurses library.
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform == 'sunos4':
|
2001-02-28 15:49:57 -04:00
|
|
|
inc_dirs += ['/usr/5include']
|
2001-01-17 11:23:23 -04:00
|
|
|
lib_dirs += ['/usr/5lib']
|
|
|
|
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
|
|
|
|
curses_libs = ['ncurses']
|
|
|
|
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
|
|
|
libraries = curses_libs) )
|
2001-12-06 18:24:47 -04:00
|
|
|
elif (self.compiler.find_library_file(lib_dirs, 'curses')
|
|
|
|
and platform != 'darwin'):
|
2002-01-23 11:04:41 -04:00
|
|
|
# OSX has an old Berkeley curses, not good enough for
|
|
|
|
# the _curses module.
|
2001-01-17 11:23:23 -04:00
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
|
|
|
|
curses_libs = ['curses', 'terminfo']
|
|
|
|
else:
|
|
|
|
curses_libs = ['curses', 'termcap']
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
|
|
|
libraries = curses_libs) )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# If the curses module is enabled, check for the panel module
|
2001-12-06 11:57:16 -04:00
|
|
|
if (module_enabled(exts, '_curses') and
|
2001-01-17 11:23:23 -04:00
|
|
|
self.compiler.find_library_file(lib_dirs, 'panel')):
|
|
|
|
exts.append( Extension('_curses_panel', ['_curses_panel.c'],
|
|
|
|
libraries = ['panel'] + curses_libs) )
|
2001-01-24 04:00:28 -04:00
|
|
|
|
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# Lee Busby's SIGFPE modules.
|
|
|
|
# The library to link fpectl with is platform specific.
|
|
|
|
# Choose *one* of the options below for fpectl:
|
|
|
|
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform == 'irix5':
|
2001-01-17 11:23:23 -04:00
|
|
|
# For SGI IRIX (tested on 5.3):
|
|
|
|
exts.append( Extension('fpectl', ['fpectlmodule.c'],
|
|
|
|
libraries=['fpe']) )
|
2001-01-18 14:44:20 -04:00
|
|
|
elif 0: # XXX how to detect SunPro?
|
2001-12-06 18:24:47 -04:00
|
|
|
# For Solaris with SunPro compiler (tested on Solaris 2.5
|
|
|
|
# with SunPro C 4.2): (Without the compiler you don't have
|
|
|
|
# -lsunmath.)
|
2001-01-17 11:23:23 -04:00
|
|
|
#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# For other systems: see instructions in fpectlmodule.c.
|
|
|
|
#fpectl fpectlmodule.c ...
|
|
|
|
exts.append( Extension('fpectl', ['fpectlmodule.c']) )
|
|
|
|
|
|
|
|
|
|
|
|
# Andrew Kuchling's zlib module.
|
|
|
|
# This require zlib 1.1.3 (or later).
|
|
|
|
# See http://www.cdrom.com/pub/infozip/zlib/
|
2001-04-15 12:16:12 -03:00
|
|
|
zlib_inc = find_file('zlib.h', [], inc_dirs)
|
|
|
|
if zlib_inc is not None:
|
|
|
|
zlib_h = zlib_inc[0] + '/zlib.h'
|
|
|
|
version = '"0.0.0"'
|
|
|
|
version_req = '"1.1.3"'
|
|
|
|
fp = open(zlib_h)
|
|
|
|
while 1:
|
|
|
|
line = fp.readline()
|
|
|
|
if not line:
|
|
|
|
break
|
|
|
|
if line.find('#define ZLIB_VERSION', 0) == 0:
|
|
|
|
version = line.split()[2]
|
|
|
|
break
|
|
|
|
if version >= version_req:
|
|
|
|
if (self.compiler.find_library_file(lib_dirs, 'z')):
|
|
|
|
exts.append( Extension('zlib', ['zlibmodule.c'],
|
|
|
|
libraries = ['z']) )
|
2001-01-17 11:23:23 -04:00
|
|
|
|
|
|
|
# Interface to the Expat XML parser
|
|
|
|
#
|
|
|
|
# Expat is written by James Clark and must be downloaded separately
|
|
|
|
# (see below). The pyexpat module was written by Paul Prescod after a
|
2002-02-11 19:27:45 -04:00
|
|
|
# prototype by Jack Jansen. Source of Expat 1.95.2 is included
|
|
|
|
# in Modules/expat. Usage of a system shared libexpat.so/expat.dll
|
|
|
|
# is only advised if that has the same or newer version and was
|
|
|
|
# build using the same defines.
|
|
|
|
if sys.byteorder == "little":
|
|
|
|
xmlbo = "12"
|
2001-01-18 14:44:20 -04:00
|
|
|
else:
|
2002-02-11 19:27:45 -04:00
|
|
|
xmlbo = "21"
|
2002-02-13 21:25:37 -04:00
|
|
|
expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
|
2002-02-11 19:27:45 -04:00
|
|
|
exts.append(Extension('pyexpat',
|
|
|
|
sources = [
|
|
|
|
'pyexpat.c',
|
|
|
|
'expat/xmlparse.c',
|
|
|
|
'expat/xmlrole.c',
|
|
|
|
'expat/xmltok.c',
|
|
|
|
],
|
|
|
|
define_macros = [
|
|
|
|
('HAVE_EXPAT_H',None),
|
|
|
|
('XML_NS', '1'),
|
|
|
|
('XML_DTD', '1'),
|
|
|
|
('XML_BYTE_ORDER', xmlbo),
|
|
|
|
('XML_CONTEXT_BYTES','1024'),
|
|
|
|
],
|
2002-02-13 21:25:37 -04:00
|
|
|
include_dirs = [expatinc]
|
2002-02-11 19:27:45 -04:00
|
|
|
))
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2002-01-23 11:04:41 -04:00
|
|
|
# Dynamic loading module
|
2002-01-01 16:18:30 -04:00
|
|
|
dl_inc = find_file('dlfcn.h', [], inc_dirs)
|
|
|
|
if dl_inc is not None:
|
2002-01-23 11:04:41 -04:00
|
|
|
exts.append( Extension('dl', ['dlmodule.c']) )
|
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# Platform-specific libraries
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform == 'linux2':
|
2001-01-17 11:23:23 -04:00
|
|
|
# Linux-specific modules
|
|
|
|
exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
|
|
|
|
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform == 'sunos5':
|
2001-01-24 04:00:28 -04:00
|
|
|
# SunOS specific modules
|
2001-01-17 11:23:23 -04:00
|
|
|
exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-12-05 11:54:29 -04:00
|
|
|
if platform == 'darwin':
|
2001-08-05 19:31:19 -03:00
|
|
|
# Mac OS X specific modules. These are ported over from MacPython
|
|
|
|
# and still experimental. Some (such as gestalt or icglue) are
|
|
|
|
# already generally useful, some (the GUI ones) really need to
|
|
|
|
# be used from a framework.
|
2001-09-04 18:33:12 -03:00
|
|
|
#
|
|
|
|
# I would like to trigger on WITH_NEXT_FRAMEWORK but that isn't
|
|
|
|
# available here. This Makefile variable is also what the install
|
|
|
|
# procedure triggers on.
|
|
|
|
frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR')
|
2002-03-07 05:58:56 -04:00
|
|
|
exts.append( Extension('gestalt', ['gestaltmodule.c'],
|
2002-03-25 10:20:09 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('MacOS', ['macosmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('icglue', ['icgluemodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-12-06 18:24:47 -04:00
|
|
|
exts.append( Extension('macfs',
|
|
|
|
['macfsmodule.c',
|
|
|
|
'../Python/getapplbycreator.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2002-03-07 05:58:56 -04:00
|
|
|
exts.append( Extension('_CF', ['cf/_CFmodule.c'],
|
|
|
|
extra_link_args=['-framework', 'CoreFoundation']) )
|
|
|
|
exts.append( Extension('_Res', ['res/_Resmodule.c'],
|
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Snd', ['snd/_Sndmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-09-04 18:33:12 -03:00
|
|
|
if frameworkdir:
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('Nav', ['Nav.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_AE', ['ae/_AEmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_App', ['app/_Appmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-12-12 19:03:17 -04:00
|
|
|
exts.append( Extension('_CarbonEvt', ['carbonevt/_CarbonEvtmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-12-13 09:41:36 -04:00
|
|
|
exts.append( Extension('_CG', ['cg/_CGmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'ApplicationServices',
|
2001-12-13 09:41:36 -04:00
|
|
|
'-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Cm', ['cm/_Cmmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Drag', ['drag/_Dragmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Icn', ['icn/_Icnmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_List', ['list/_Listmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Menu', ['menu/_Menumodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Qd', ['qd/_Qdmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-09-04 18:33:12 -03:00
|
|
|
exts.append( Extension('_Qt', ['qt/_Qtmodule.c'],
|
2001-12-06 18:24:47 -04:00
|
|
|
extra_link_args=['-framework', 'QuickTime',
|
|
|
|
'-framework', 'Carbon']) )
|
2002-01-21 19:10:36 -04:00
|
|
|
exts.append( Extension('_Scrap', ['scrap/_Scrapmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_TE', ['te/_TEmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
2001-12-09 19:08:54 -04:00
|
|
|
# As there is no standardized place (yet) to put user-installed
|
|
|
|
# Mac libraries on OSX you should put a symlink to your Waste
|
|
|
|
# installation in the same folder as your python source tree.
|
|
|
|
# Or modify the next two lines:-)
|
|
|
|
waste_incs = find_file("WASTE.h", [], ["../waste/C_C++ Headers"])
|
|
|
|
waste_libs = find_library_file(self.compiler, "WASTE", [],
|
|
|
|
["../waste/Static Libraries"])
|
|
|
|
if waste_incs != None and waste_libs != None:
|
2002-01-23 11:04:41 -04:00
|
|
|
exts.append( Extension('waste',
|
2001-12-09 19:08:54 -04:00
|
|
|
['waste/wastemodule.c',
|
|
|
|
'Mac/Wastemods/WEObjectHandlers.c',
|
|
|
|
'Mac/Wastemods/WETabHooks.c',
|
|
|
|
'Mac/Wastemods/WETabs.c'
|
|
|
|
],
|
|
|
|
include_dirs = waste_incs + ['Mac/Wastemods'],
|
|
|
|
library_dirs = waste_libs,
|
|
|
|
libraries = ['WASTE'],
|
|
|
|
extra_link_args = ['-framework', 'Carbon'],
|
|
|
|
) )
|
2001-10-31 08:11:48 -04:00
|
|
|
exts.append( Extension('_Win', ['win/_Winmodule.c'],
|
2002-01-23 11:04:41 -04:00
|
|
|
extra_link_args=['-framework', 'Carbon']) )
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
self.extensions.extend(exts)
|
|
|
|
|
|
|
|
# Call the method for detecting whether _tkinter can be compiled
|
|
|
|
self.detect_tkinter(inc_dirs, lib_dirs)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
|
|
|
|
def detect_tkinter(self, inc_dirs, lib_dirs):
|
2001-01-17 11:23:23 -04:00
|
|
|
# The _tkinter module.
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# Assume we haven't found any of the libraries or include files
|
2001-07-24 03:54:01 -03:00
|
|
|
# The versions with dots are used on Unix, and the versions without
|
|
|
|
# dots on Windows, for detection by cygwin.
|
2001-01-18 14:44:20 -04:00
|
|
|
tcllib = tklib = tcl_includes = tk_includes = None
|
2001-07-24 03:54:01 -03:00
|
|
|
for version in ['8.4', '84', '8.3', '83', '8.2',
|
|
|
|
'82', '8.1', '81', '8.0', '80']:
|
2002-01-23 11:04:41 -04:00
|
|
|
tklib = self.compiler.find_library_file(lib_dirs,
|
|
|
|
'tk' + version )
|
|
|
|
tcllib = self.compiler.find_library_file(lib_dirs,
|
|
|
|
'tcl' + version )
|
|
|
|
if tklib and tcllib:
|
2001-01-17 11:23:23 -04:00
|
|
|
# Exit the loop when we've found the Tcl/Tk libraries
|
|
|
|
break
|
2001-01-18 14:44:20 -04:00
|
|
|
|
2001-01-24 04:00:28 -04:00
|
|
|
# Now check for the header files
|
2001-01-18 14:44:20 -04:00
|
|
|
if tklib and tcllib:
|
|
|
|
# Check for the include files on Debian, where
|
|
|
|
# they're put in /usr/include/{tcl,tk}X.Y
|
2001-02-06 18:15:27 -04:00
|
|
|
debian_tcl_include = [ '/usr/include/tcl' + version ]
|
2001-12-06 18:24:47 -04:00
|
|
|
debian_tk_include = [ '/usr/include/tk' + version ] + \
|
|
|
|
debian_tcl_include
|
2001-02-06 18:15:27 -04:00
|
|
|
tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
|
|
|
|
tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
|
2001-01-18 14:44:20 -04:00
|
|
|
|
|
|
|
if (tcllib is None or tklib is None and
|
|
|
|
tcl_includes is None or tk_includes is None):
|
|
|
|
# Something's missing, so give up
|
|
|
|
return
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# OK... everything seems to be present for Tcl/Tk.
|
|
|
|
|
|
|
|
include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
|
|
|
|
for dir in tcl_includes + tk_includes:
|
|
|
|
if dir not in include_dirs:
|
|
|
|
include_dirs.append(dir)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# Check for various platform-specific directories
|
2001-01-23 23:31:07 -04:00
|
|
|
platform = self.get_platform()
|
|
|
|
if platform == 'sunos5':
|
2001-01-18 14:44:20 -04:00
|
|
|
include_dirs.append('/usr/openwin/include')
|
|
|
|
added_lib_dirs.append('/usr/openwin/lib')
|
|
|
|
elif os.path.exists('/usr/X11R6/include'):
|
|
|
|
include_dirs.append('/usr/X11R6/include')
|
|
|
|
added_lib_dirs.append('/usr/X11R6/lib')
|
|
|
|
elif os.path.exists('/usr/X11R5/include'):
|
|
|
|
include_dirs.append('/usr/X11R5/include')
|
|
|
|
added_lib_dirs.append('/usr/X11R5/lib')
|
|
|
|
else:
|
2001-01-24 04:00:28 -04:00
|
|
|
# Assume default location for X11
|
2001-01-18 14:44:20 -04:00
|
|
|
include_dirs.append('/usr/X11/include')
|
|
|
|
added_lib_dirs.append('/usr/X11/lib')
|
|
|
|
|
2001-09-18 17:32:13 -03:00
|
|
|
# If Cygwin, then verify that X is installed before proceeding
|
|
|
|
if platform == 'cygwin':
|
|
|
|
x11_inc = find_file('X11/Xlib.h', [], inc_dirs)
|
|
|
|
if x11_inc is None:
|
|
|
|
# X header files missing, so give up
|
|
|
|
return
|
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# Check for BLT extension
|
2001-12-06 18:24:47 -04:00
|
|
|
if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
|
|
|
|
'BLT8.0'):
|
2001-01-18 14:44:20 -04:00
|
|
|
defs.append( ('WITH_BLT', 1) )
|
|
|
|
libs.append('BLT8.0')
|
|
|
|
|
|
|
|
# Add the Tcl/Tk libraries
|
2001-01-24 04:00:28 -04:00
|
|
|
libs.append('tk'+version)
|
2001-01-18 14:44:20 -04:00
|
|
|
libs.append('tcl'+version)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-23 23:31:07 -04:00
|
|
|
if platform in ['aix3', 'aix4']:
|
2001-01-18 14:44:20 -04:00
|
|
|
libs.append('ld')
|
|
|
|
|
2001-07-24 03:54:01 -03:00
|
|
|
# Finally, link with the X11 libraries (not appropriate on cygwin)
|
|
|
|
if platform != "cygwin":
|
|
|
|
libs.append('X11')
|
2001-01-18 14:44:20 -04:00
|
|
|
|
|
|
|
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
|
|
|
define_macros=[('WITH_APPINIT', 1)] + defs,
|
|
|
|
include_dirs = include_dirs,
|
|
|
|
libraries = libs,
|
|
|
|
library_dirs = added_lib_dirs,
|
|
|
|
)
|
|
|
|
self.extensions.append(ext)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-18 14:44:20 -04:00
|
|
|
# XXX handle these, but how to detect?
|
2001-01-17 11:23:23 -04:00
|
|
|
# *** Uncomment and edit for PIL (TkImaging) extension only:
|
2001-01-24 04:00:28 -04:00
|
|
|
# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
|
2001-01-17 11:23:23 -04:00
|
|
|
# *** Uncomment and edit for TOGL extension only:
|
2001-01-24 04:00:28 -04:00
|
|
|
# -DWITH_TOGL togl.c \
|
2001-01-17 11:23:23 -04:00
|
|
|
# *** Uncomment these for TOGL extension only:
|
2001-01-24 04:00:28 -04:00
|
|
|
# -lGL -lGLU -lXext -lXmu \
|
2001-01-17 11:23:23 -04:00
|
|
|
|
2001-05-21 17:29:27 -03:00
|
|
|
class PyBuildInstall(install):
|
|
|
|
# Suppress the warning about installation into the lib_dynload
|
|
|
|
# directory, which is not in sys.path when running Python during
|
|
|
|
# installation:
|
|
|
|
def initialize_options (self):
|
|
|
|
install.initialize_options(self)
|
|
|
|
self.warn_dir=0
|
2002-01-23 11:04:41 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
def main():
|
2001-05-21 17:48:09 -03:00
|
|
|
# turn off warnings when deprecated modules are imported
|
|
|
|
import warnings
|
|
|
|
warnings.filterwarnings("ignore",category=DeprecationWarning)
|
2001-01-17 11:23:23 -04:00
|
|
|
setup(name = 'Python standard library',
|
2001-01-17 17:58:00 -04:00
|
|
|
version = '%d.%d' % sys.version_info[:2],
|
2001-05-21 17:29:27 -03:00
|
|
|
cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
|
2001-01-17 11:23:23 -04:00
|
|
|
# The struct module is defined here, because build_ext won't be
|
|
|
|
# called unless there's at least one extension module defined.
|
2001-02-28 16:56:49 -04:00
|
|
|
ext_modules=[Extension('struct', ['structmodule.c'])],
|
|
|
|
|
|
|
|
# Scripts to install
|
|
|
|
scripts = ['Tools/scripts/pydoc']
|
2001-01-17 11:23:23 -04:00
|
|
|
)
|
2001-01-24 04:00:28 -04:00
|
|
|
|
2001-01-17 11:23:23 -04:00
|
|
|
# --install-platlib
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sysconfig.set_python_build()
|
|
|
|
main()
|