1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
# $Id: setup.py,v 1.19 2006/05/31 14:48:31 hobu Exp $
#
# setup.py file for MapScript
#
# BUILD
# python setup.py build
#
# INSTALL (usually as root)
# python setup.py install
from distutils.core import setup, Extension
from distutils import sysconfig
import sys
import os.path
import string
# Function needed to make unique lists.
def unique(list):
dict = {}
for item in list:
dict[item] = ''
return dict.keys()
# Should be created by the mapserver build process.
mapscriptvars = "../../mapscriptvars"
# Open and read lines from mapscriptvars.
try:
fp = open(mapscriptvars, "r")
except IOError, e:
raise IOError, '%s. %s' % (e, "Has MapServer been made?")
ms_install_dir = fp.readline()
ms_macros = fp.readline()
ms_includes = fp.readline()
ms_libraries_pre = fp.readline()
ms_extra_libraries = fp.readline()
# Get mapserver version from mapscriptvars, which contains a line like
#
# MS_VERSION "4.x.y"
ms_version = '4.4' # the default
ms_version_line = fp.readline()
if ms_version_line:
ms_version = ms_version_line.split()[2]
ms_version = ms_version.replace('"', '')
# Distutils wants a list of library directories and
# a seperate list of libraries. Create both lists from
# lib_opts list.
lib_opts = string.split(ms_libraries_pre)
lib_dirs = [x[2:] for x in lib_opts if x[:2] == "-L"]
lib_dirs = unique(lib_dirs)
lib_dirs = lib_dirs + string.split(ms_install_dir)
libs = []
extras = []
for x in lib_opts:
if x[:2] == '-l':
libs.append( x[2:] )
if x[-4:] == '.lib' or x[-4:] == '.LIB':
dir, lib = os.path.split(x)
libs.append( lib[:-4] )
if len(dir) > 0:
lib_dirs.append( dir )
if x[-2:] == '.a':
extras.append(x)
libs = unique(libs)
# if we're msvc, just link against the stub lib
# and be done with it
if sys.platform == 'win32':
libs = ['mapserver_i','gd']
lib_dirs = unique(lib_dirs)
# Create list of macros used to create mapserver.
ms_macros = string.split(ms_macros)
macros = [(x[2:], None) for x in ms_macros]
# Create list of include directories to create mapserver.
include_dirs = [sysconfig.get_python_inc()]
ms_includes = string.split(ms_includes)
for item in ms_includes:
if item[:2] == '-I' or item[:2] == '/I':
if item[2:] not in include_dirs:
include_dirs.append( item[2:] )
# Here is the distutils setup function that does all the magic.
# Uncomment lines below if using static gd
#extras.append("-static")
#extras.append("-lgd")
setup(name = "mapscript",
version = ms_version,
description = "Python interface to MapServer",
author = "MapServer Project",
url = "http://mapserver.gis.umn.edu/",
ext_modules = [Extension("_mapscript",
["mapscript_wrap.c", "pygdioctx/pygdioctx.c"],
include_dirs = include_dirs,
library_dirs = lib_dirs,
libraries = libs,
define_macros = macros,
extra_link_args = extras,
)
],
py_modules = ["mapscript"]
)
|