[mapserver-users] Python Mapscript MS 3.6.1

Norman Vine nhv at cape.com
Sun Jul 14 07:34:49 EDT 2002


 Vinko Vrsalovic writes:
>
>On Thu, Jul 11, 2002 at 08:15:36AM -0400, Frank Warmerdam wrote:
>
>> I have also committed Norman Vine's setup.py script to CVS though I find
it
>> takes quite a bit of hand editing to build and install for different sets
of
>> build options.  It would be nice for it to pick up more information about
the
>> MapServer build from the configure output at some point, but that isn't
>> high on my priority list.
>
>
>Yes, i totally agree, i may give it a try

the attached setup.py works for me with Cygwin picking up the
'configuration' automagically  :-)

Note my use of the 'extra_objects' field < see # comment in script >

Cheers

Norman
-------------- next part --------------
#! /usr/bin/env python
# Distutils setup for UMN Mapserver mapscript v.3.7
# Norman Vine 7/13/2002

# Should work as is on 'Unix' like systems

# To Install
# build mapserver
# Copy this file to $MAPSERVER_SRC / mapscript / python
# invoke as ./setup.py install

# should work on any python version with Distutils

from distutils.core import setup, Extension
from distutils.spawn import spawn
from distutils.dir_util import mkpath
from distutils.file_util import copy_file
from distutils.sysconfig import parse_makefile,expand_makefile_vars
from string import split

import os
from os import path

noisy=1
swig_cmd = ["swig",
            "-python",
            "-shadow",
#            "-opt",
            "-DPYTHON",
            "-DUSE_GD_PNG",
            "-DUSE_GD_JPEG",
            "-module",
            "mapscript",
            "-o",
            "./mapscript_wrap.c",
            "../mapscript.i" ]
            
spawn(swig_cmd, verbose=noisy)

# make package directory and package __init__ script
mkpath("mapscript")
init_file=open(path.join("mapscript","__init__.py"),"w")
init_file.write("from mapscript import *\n")
init_file.close()

copy_file("mapscript.py", path.join("mapscript","mapscript.py"), verbose=noisy)

# change to reflect the gd version you are using
gd_dir="gd-1.8.4"
ms_dir=path.join("..","..")
local_dir="/usr/local"

# parse mapserver Makefile using distutils to determine configured libs
DICT = parse_makefile(path.join(ms_dir,"Makefile"))
tmp = split(DICT[expand_makefile_vars("LDFLAGS",DICT)])
lib_list = []
for lib in tmp:
    if lib[1:2] == 'l':
        if lib == '-lmap':
            continue
        lib_list.append(lib[2:])

setup (# Distribution meta-data
       name = "pymapscript",
       version = "3.7",
       description = "pre release",
       author = "Steve Lime",
       author_email = "steve.lime at dnr.state.mn.us",
       url = "http://mapserver.gis.umn.edu/",

       # Description of the modules and packages in the distribution
       packages = ['mapscript'],
       ext_modules = 
           [Extension('mapscriptc', ['mapscript_wrap.c'],
                      define_macros=[('TIFF_STATIC',None),('JPEG_STATIC',None),('ZLIB_STATIC',None),
                          ('IGNORE_MISSING_DATA',None),('USE_EPPL',None),('USE_PROJ',None),('USE_PROJ_API_H',None),
                          ('USE_WMS',None),('USE_TIFF',None),('USE_JPEG',None),('USE_GD_PNG',None),('USE_GD_JPEG',None),
                          ('USE_GD_WBMP',None),('USE_GDAL',None),('USE_POSTGIS',None)],
                      include_dirs=[ms_dir,
#                          path.join(ms_dir,gd_dir),
#                          path.join(ms_dir,"gdft"),
#                          path.join(local_dir,'include/freetype'),
                          path.join(local_dir,'include')
                                    ],
                      library_dirs=[ms_dir,
#                          path.join(ms_dir,gd_dir),
#                          path.join(ms_dir,"gdft"),
                          '/lib',
                          path.join(local_dir,'lib')],
                      # link order matters with Cygwin
                      extra_objects=[path.join(ms_dir,'libmap.a'),'/usr/local/lib/ogr.a'],
                      libraries = lib_list, ), ]
      )


More information about the mapserver-users mailing list