Skip to content

Commit

Permalink
fix install with libvips <= 8.5
Browse files Browse the repository at this point in the history
only use vips_image_get_fields() on 8.5 and later

thanks rebkwok

see: https://github.com/jcupitt/pyvips/issues/33
  • Loading branch information
jcupitt committed Mar 1, 2018
1 parent bc5cce8 commit bc35d3c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# master

## Version 2.1.2 (1 March 2018)

* only use get_fields on libvips 8.5+ [rebkwok]

## Version 2.1.1 (25 February 2018)

* switch to sdist
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# The short X.Y version.
version = u'2.1'
# The full version, including alpha/beta/rc tags.
release = u'2.1.1'
release = u'2.1.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 5 additions & 1 deletion pyvips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@

if not API_mode:
import decls

major = vips_lib.vips_version(0)
minor = vips_lib.vips_version(1)
features = {
# at_least_libvips(8, 5):
'8.5+': major > 8 or (major == 8 and minor >= 5),
# at_least_libvips(8, 6):
'8.6+': major > 8 or (major == 8 and minor >= 6)
'8.6+': major > 8 or (major == 8 and minor >= 6),
}

ffi.cdef(decls.cdefs(features))

from .error import *
Expand Down
9 changes: 7 additions & 2 deletions pyvips/decls.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def cdefs(features):
void vips_image_set (VipsImage* image,
const char* name, GValue* value);
int vips_image_remove (VipsImage* image, const char* name);
char** vips_image_get_fields (VipsImage* image);
char* vips_filename_get_filename (const char* vips_filename);
char* vips_filename_get_options (const char* vips_filename);
Expand Down Expand Up @@ -294,6 +293,12 @@ def cdefs(features):
'''

# at_least_libvips(8, 5):
if _enabled(features, '8.5+'):
code += '''
char** vips_image_get_fields (VipsImage* image);
'''

# at_least_libvips(8, 6):
if _enabled(features, '8.6+'):
code += '''
Expand All @@ -308,7 +313,7 @@ def cdefs(features):
if _enabled(features, 'api'):
code += '''
int vips_init (const char* argv0);
int vips_version( int flag );
int vips_version (int flag);
'''

return code
Expand Down
4 changes: 3 additions & 1 deletion pyvips/pyvips_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
features = {
# in API mode
'api': True,
# at_least_libvips(8, 5):
'8.5+': pkgconfig.installed('vips', '>= 8.5'),
# at_least_libvips(8, 6):
'8.6+': pkgconfig.installed('vips', '>= 8.6')
'8.6+': pkgconfig.installed('vips', '>= 8.6'),
}

import decls
Expand Down
2 changes: 1 addition & 1 deletion pyvips/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# this is execfile()d into setup.py imported into __init__.py
__version__ = '2.1.1'
__version__ = '2.1.2'

__all__ = ['__version__']
18 changes: 10 additions & 8 deletions pyvips/vimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,17 @@ def get_fields(self):
"""

array = vips_lib.vips_image_get_fields(self.pointer)
names = []
i = 0
while array[i] != ffi.NULL:
name = _to_string(ffi.string(array[i]))
names.append(name)
glib_lib.g_free(array[i])
i += 1
glib_lib.g_free(array)

if at_least_libvips(8, 5):
array = vips_lib.vips_image_get_fields(self.pointer)
i = 0
while array[i] != ffi.NULL:
name = _to_string(ffi.string(array[i]))
names.append(name)
glib_lib.g_free(array[i])
i += 1
glib_lib.g_free(array)

return names

Expand Down

0 comments on commit bc35d3c

Please sign in to comment.