[Gdal-dev] Setup scripts for Python (win32 and Linux-rpm).

Cherkashin Evgeny eugeneai at icc.ru
Fri Feb 7 03:18:18 EST 2003


Hi, Frank and all!

I've reworked the setup.py script according to Your needs and convenience.
Now:
1. There should be no __init__.py in the pymod directory.
2. setup.py and MANIFEST.in sould be placed and run from the source root.
3. The script is not intended to be the sdist (source distribution) 
creator, but binary packages for Linux (rpm) and win32.
4. MANIFEST.in is used only to produce temporal source RPM package.

How to use:
1. Compile the GDAL library as regular.
2. issue in the source root:
win32: python setup.py bdist_wininst
Linux: python setup.py bdist_rpm
Source RPM will contain libgdal.1.1.so and all the includes (everything 
for building the python module) and should be ignored.
Consider the source distribution the original gdal sources with the 
files included.

The usage of the package now is as regular just "import gdal, ogr, osr" 
no prefix needed.

Gud luck,
Evgeny Cherkashin

Frank, place the attached files in the source root and, please, correct 
URL keyword in the setup.py.
-------------- next part --------------
#!/usr/bin/env python

import string
from distutils.core import setup, Extension
import os, os.path, glob

#
# debug
#
#import sys
#sys.argv.append("build")

f=open(os.path.join("VERSION"))
v=f.read()
f.close()
del f

version=v.strip()
dllversion=version.replace(".","")
soversion=v[:3]

SOURCES=glob.glob(os.path.join("pymod","*.c*"))
print SOURCES
INCLUDE_DIRS=[os.path.join("core"), os.path.join("port"), os.path.join("ogr"), os.path.join("pymod"), ] # only necessary
LIBRARY_DIRS = ["."]

INCLUDE_FILES = [
	glob.glob(os.path.join("core", "*.h")),
	glob.glob(os.path.join("port", "*.h")),
	glob.glob(os.path.join("alg", "*.h")),
	glob.glob(os.path.join("ogr", "*.h")), 
	glob.glob(os.path.join("ogr", "ogrsf_frmts", "*.h")),
	glob.glob(os.path.join("pymod", "*.h"))
]

IF=[]
for i in INCLUDE_FILES:
	IF.extend(i)
INCLUDE_FILES=IF
del IF

HTML_FILES=glob.glob(os.path.join("html", "*"))

#HTML_FILES.remove(os.path.join("html", ".cvsignore"))

#print INCLUDE_FILES

if os.name=="nt":
	DLL="gdal%s.dll" % dllversion
	DATA_FILES=[
		("", [DLL]),
#		("libs", [os.path.join("gdal_i.lib"), os.path.join("pymod","_gdal.lib")]),
		("libs", [os.path.join("gdal_i.lib")]),
	]
	LIBRARIES = ["gdal_i"]
	EXTRA_LINK_ARGS=[]
else:
	DATA_FILES=[
		("lib", ['libgdal.%s.so' % soversion]),
	]
	LIBRARIES = []
	#EXTRA_LINK_ARGS=[os.path.join("gdal.a")]
	LIBRARIES = ["gdal.%s" % soversion]
	EXTRA_LINK_ARGS=[]
	
DATA_FILES.append(("include", INCLUDE_FILES))
DATA_FILES.append((os.path.join("doc","gdal"), HTML_FILES))

setup (name = "Pyhton_GDAL",
       version = version,
       description = "Geospatial Data Abstraction Library: Python Bindings",
       author = "Frank Warmerdam",
       #packager = "Evgeniy Cherkashin",
       author_email = "warmerda at home.com",
       #packager_email = "eugeneai at icc.ru",
       url = "http://www.remotesensing.org/.../gdal/",	# I've forgot the rest
       packages = [''],
       package_dir = {'': 'pymod'},
       extra_path = "gdal",
       ext_modules = [Extension('_gdal',
			sources = SOURCES,
			include_dirs = INCLUDE_DIRS,
			libraries = LIBRARIES,
			library_dirs = LIBRARY_DIRS,
			extra_link_args=EXTRA_LINK_ARGS,
			),
		],
		data_files = DATA_FILES
	)

-------------- next part --------------
recursive-include pymod *.py *.cpp *.c *.h *.i
recursive-include html *
recursive-include core *.h
recursive-include port *.h
recursive-include alg *.h
recursive-include ogr *.h
recursive-include frmts *.h
include VERSION
include setup.py
include MAINFEST.in
include *gdal*.so
include *gdal*.lib
include *gdal*.dll



More information about the Gdal-dev mailing list