python module hacking

This commit is contained in:
John Cupitt 2010-05-05 15:22:04 +00:00
parent daf074e950
commit 27fcca7ef9
4 changed files with 98 additions and 23 deletions

15
TODO
View File

@ -1,7 +1,20 @@
- convert_saveable for other writers: tiff, ppm, csv, rad etc. - convert_saveable for other writers: tiff, ppm, csv, rad etc.
the tiff writer could use more im_check_ things - im_magick2vips() needs testing with Joe's odd BMPs
- IM_LIBDIR is "" by default, what's the logic guess_libdir uses? we need to
duplicate that in python I guess
test
python setup.py build_ext
python setup.py build
python setup.py install
- the tiff writer could use more im_check_ things
test pfm write test pfm write

View File

@ -574,6 +574,10 @@ VIPS_INCLUDES="$PNG_INCLUDES $TIFF_INCLUDES $ZIP_INCLUDES $JPEG_INCLUDES $FFTW_I
# need -lstdc++ for (eg.) the C++ format loaders # need -lstdc++ for (eg.) the C++ format loaders
VIPS_LIBS="$MAGICK_LIBS $PNG_LIBS $TIFF_LIBS $ZIP_LIBS $JPEG_LIBS $GTHREAD_LIBS $REQUIRED_LIBS $PANGOFT2_LIBS $FFTW3_LIBS $FFTW_LIBS $LCMS_LIBS $LIBOIL_LIBS $OPENEXR_LIBS $MATIO_LIBS $EXIF_LIBS -lstdc++ -lm" VIPS_LIBS="$MAGICK_LIBS $PNG_LIBS $TIFF_LIBS $ZIP_LIBS $JPEG_LIBS $GTHREAD_LIBS $REQUIRED_LIBS $PANGOFT2_LIBS $FFTW3_LIBS $FFTW_LIBS $LCMS_LIBS $LIBOIL_LIBS $OPENEXR_LIBS $MATIO_LIBS $EXIF_LIBS -lstdc++ -lm"
# we need this to generate paths in swig/python/setup.py.in
AC_SUBST(top_srcdir)
AC_SUBST(IM_LIBDIR)
AC_SUBST(VIPS_CFLAGS) AC_SUBST(VIPS_CFLAGS)
AC_SUBST(VIPS_INCLUDES) AC_SUBST(VIPS_INCLUDES)
AC_SUBST(VIPS_LIBS) AC_SUBST(VIPS_LIBS)
@ -625,6 +629,7 @@ AC_OUTPUT([
tools/scripts/shrink_width tools/scripts/shrink_width
swig/Makefile swig/Makefile
swig/vipsCC/Makefile swig/vipsCC/Makefile
swig/python/setup.py
man/Makefile man/Makefile
doc/Makefile doc/Makefile
doc/reference/Makefile doc/reference/Makefile
@ -637,6 +642,7 @@ AC_MSG_RESULT([
native win32: $vips_os_win32 native win32: $vips_os_win32
native OS X: $vips_os_darwin native OS X: $vips_os_darwin
open files in binary mode: $vips_binary_open open files in binary mode: $vips_binary_open
enable debug: $enable_debug
build C++ components: $enable_cxx build C++ components: $enable_cxx
evaluate with threads: $enable_threads evaluate with threads: $enable_threads
make symlinks for commands in bin: $enable_links make symlinks for commands in bin: $enable_links

View File

@ -1,22 +0,0 @@
#!/usr/bin/python
from distutils.core import setup, Extension
module1 = Extension ('VImage', sources = ['vimagemodule.cxx'], include_dirs =
['home/john/vips/include'])
module2 = Extension ('VMask', sources = ['vmaskmodule.cxx'], include_dirs =
['home/john/vips/include'])
module3 = Extension ('VDisplay', sources = ['vdisplaymodule.cxx'],
include_dirs = ['home/john/vips/include'])
module4 = Extension ('VError', sources = ['verrormodule.cxx'], include_dirs =
['home/john/vips/include'])
setup (name = 'vips7',
version = '7.21.3',
description = 'vips-7.x image processing library',
author = 'John Cupitt',
author_email = 'jcupitt@gmail.com',
url = 'http://www.vips.ecs.soton.ac.uk',
ext_package = 'vips7',
ext_modules = [module1, module2, module3, module4])

78
swig/python/setup.py.in Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/python
import re
import sys
from distutils.core import setup, Extension
# We pick up configure's stuff here. Sadly distutils needs this broken out
# into separate includes, libs and defines, argh
configure_flags = '@VIPS_CFLAGS@ @VIPS_INCLUDES@ @VIPS_LIBS@ -I@top_srcdir@/libvips/include'
# Parse compiler flags into these categories, yuk!
configure_macros = []
configure_include_dirs = []
configure_library_dirs = []
configure_libs = []
configure_options = []
for flag in configure_flags.split():
match = re.match ('-D(.*)(=(.*))?', flag)
if match:
key = match.group (1)
if match.group (2):
value = match.group (2)
else:
value = 1
configure_macros += [(key, value)]
continue
match = re.match ('-I(.*)', flag)
if match:
configure_include_dirs += [match.group (1)]
continue
match = re.match ('-L(.*)', flag)
if match:
configure_library_dirs += [match.group (1)]
continue
match = re.match ('-l(.*)', flag)
if match:
configure_libs += [match.group (1)]
continue
match = re.match ('-(.*)', flag)
if match:
configure_options += [flag]
continue
print '%s: unknown configure option!' % flag
sys.exit (1)
def make_extension (name, source):
return Extension (name,
sources = [source],
define_macros = configure_macros,
include_dirs = configure_include_dirs,
libraries = configure_libs,
library_dirs = configure_library_dirs,
extra_compile_args = configure_options,
extra_link_args = configure_options,
runtime_library_dirs= ['@IM_LIBDIR@'])
module1 = make_extension ('_VImage', 'vimagemodule.cpp')
module2 = make_extension ('_VMask', 'vmaskmodule.cpp')
module3 = make_extension ('_VError', 'verrormodule.cpp')
module4 = make_extension ('_VDisplay', 'vdisplaymodule.cpp')
setup (name = 'vipsCC',
version = '7.20.7',
description = 'vips-7.x image processing library',
author = 'John Cupitt',
author_email = 'jcupitt@gmail.com',
url = 'http://www.vips.ecs.soton.ac.uk',
ext_package = 'vipsCC',
ext_modules = [module1, module2, module3, module4],
py_modules = ['VImage','VMask','VDisplay','VError'])