[mapserver-users] PythonMapscript Installation under Windows
Michael Schulz
mschulz at webgis.de
Fri Oct 11 07:48:38 PDT 2002
Hi Norman, Dear List,
thanks to your hints, it seems we finally succeeded in buidling python
mapscript on w2000 with python 2.1.3, swig 1.3.15, msvc7. We had to make
one more change to the setup.py (changing the name of the module from
"MapScript" to "mapscript").
Then another error came up: the function "snprintf" (in mapscript.i) is
obviously not existing for msvc, we used "vsnprintf" instead.
Now the linker kept complaining about multiple defined symbols, using
/NODEFAULTLIB to no avail. So we added /FORCE and it worked - well, not
nice, but who cares?
We haven't done any testing. But import mapscript and mapscript.MS_VERSION
work - we'll dig deeper next week. Thanks for your help. I have attached
the last setup.py that worked for us under windows 2000.
Cheers, Michael
Norman Vine schrieb:
> Try changing your setup.py lines
>
> ## from ##
>
> # 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()
>
> ## to ##
>
> # 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()
>
> ## AND from ##
>
> # Description of the modules and packages in the distribution
> packages = ['mapscript'],
> ext_modules =
> [Extension('MapScriptc', ['mapscript_wrap.c'],
>
> ## to ##
>
> # Description of the modules and packages in the distribution
> packages = ['mapscript'],
> ext_modules = [
> Extension('_mapscript', ['mapscript_wrap.c'],
>
> This is due to naming conventions change recent swig distributions
>
> Please let us know if this works !
>
> Norman
setup.py:
---------------------------------------------------------------
#! /usr/bin/env python
# Distutils setup for UMN Mapserver mapscript v.3.5
# Norman Vine 11/10/2001
# On cygwin this will require my Distutils mods available @
# http://www.vso.cape.com/~nhv/files/python/mydistutils.txt
# Should work as is on 'Unix' like systems
# needs testing on Windows compilers other then Cygwin
# 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
__revision__ = "$Id: mapscript_setup.py,v 1.5 2001/11/10 15:22:02 nhv Exp
$"
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
import os,sys
from os import path
noisy=1
swig_cmd = ["d:\ms\swig-1.3.15\swig",
"-python",
"-shadow",
"-D__WIN32__",
"-module",
"mapscript",
"-o",
"./mapscript_wrap.c",
"../mapscript.i" ]
try:
spawn(swig_cmd, verbose=noisy)
except:
print "\nSwig Error"
raise sys.exit()
# 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("D:\ms\mapserver-3.6.2")
local_dir="D:\ms"
freetype="freetype\lib"
png_dir="lpng124"
proj="proj\src"
tiff="tiff-v3.5.7\libtiff"
oracle_inc="d:\oracle\ora81\oci\include"
oracle_lib="d:\oracle\ora81\oci\lib\msvc"
regex_dir="regex-0.12"
jpeg="jpeg-6b"
setup (# Distribution meta-data
name = "pyMapScript",
version = "3.6",
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('_mapscript', ['mapscript_wrap.c'],
extra_link_args=['/NODEFAULTLIB:libcd','/FORCE'],
define_macros=[('TIFF_STATIC',),('JPEG_STATIC',),('ZLIB_STATIC',),
('IGNORE_MISSING_DATA',),('USE_EPPL',),('USE_PROJ',),('USE_PROJ_API_H',),
('USE_WMS',),('USE_WMS_LYR',),('USE_TIFF',),('USE_JPEG',),('USE_GD_PNG',),('USE_GD_GIF',),('USE_GD_JPEG',),
('USE_GD_WBMP',),('USE_GDAL',),('USE_ORACLESPATIAL',)],
include_dirs=[ms_dir,
path.join(local_dir,gd_dir),
path.join(local_dir,freetype),
path.join(local_dir,tiff),
path.join(local_dir,oracle_inc),
path.join(local_dir,proj),
path.join(local_dir,jpeg),
path.join(local_dir,regex_dir)],
library_dirs=[ms_dir,
path.join(local_dir,gd_dir),
path.join(local_dir,freetype),
path.join(local_dir,tiff),
path.join(local_dir,oracle_lib),
path.join(local_dir,proj),
path.join(local_dir,jpeg),
path.join(local_dir,png_dir)],
extra_objects=[path.join(ms_dir,'mapserver.lib'),
path.join(local_dir,'gdal\ogr\ogrsf_frmts\ogrsf_frmts.lib'),
path.join(local_dir,'gdal\gdal.lib'),
path.join(local_dir,'gdal\ogr\ogr.lib'),
path.join(local_dir,'gdal\port\cpl.lib')],
libraries=['gd','freetype','libpng','libjpeg','proj','zlib','oci'],),
]
)
----------------------------------------------------------------------
--
-----------------------------------------------------------
Michael Schulz in medias res
Dipl.-Geologe Gesellschaft für
Informationstechnologie mbH
Sautierstr. 38, 79104 Freiburg
0761 55695-95 (Fax 96)
mschulz at webgis.de www.webgis.de
More information about the MapServer-users
mailing list