Merge lp:~sanelson/py3exiv2/bugfix_boost_python_build into lp:py3exiv2

Proposed by Sam Nelson
Status: Needs review
Proposed branch: lp:~sanelson/py3exiv2/bugfix_boost_python_build
Merge into: lp:py3exiv2
Diff against target: 308 lines (+169/-12)
7 files modified
.bzrignore (+0/-1)
py3exiv2/setup.py (+18/-1)
py3exiv2/src/pyexiv2/xmp.py (+2/-0)
py3exiv2/test/iptc.py (+1/-1)
py3exiv2/test/pickling.py (+118/-0)
py3exiv2/test/xmp.py (+2/-2)
setup.py (+28/-7)
To merge this branch: bzr merge lp:~sanelson/py3exiv2/bugfix_boost_python_build
Reviewer Review Type Date Requested Status
VinsS Pending
Review via email: mp+380864@code.launchpad.net

Commit message

Fix libboost_python3 library linking issues on Linux. Repair broken tests.

Description of the change

This branch represents a collection of fixes to:

1. Fix build issues on Linux when trying to find libboost_python3
2. Synchronize setup.py files
3. Update code and tests to fix a couple of minor test failures

To post a comment you must log in.

Unmerged revisions

109. By Sam Nelson

Fixed code and tests for NoneType TestXmpTag failing tests for xmp.py

108. By Sam Nelson

Fixed expected error type for test_set_value_non_repeatable()

107. By Sam Nelson

Added pickling.py back to repo from release package and removed from .bzrignore as this causes tests to fail

106. By Sam Nelson

Fixed linux libboost_python build issue and synchronized both setup.py scripts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2019-04-13 08:37:44 +0000
3+++ .bzrignore 2020-03-19 01:47:23 +0000
4@@ -1,7 +1,6 @@
5 DSCF0006.JPG
6 Cyrillic.jpg
7 Hebrew.jpg
8-pickling.py
9 test_py2.py
10 bytearray_vectorC++
11 data.txt
12
13=== modified file 'py3exiv2/setup.py'
14--- py3exiv2/setup.py 2019-05-28 08:18:03 +0000
15+++ py3exiv2/setup.py 2020-03-19 01:47:23 +0000
16@@ -21,6 +21,21 @@
17 with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
18 long_description = f.read()
19
20+def get_libboost_linux():
21+ """Returns the name of the lib libboost_python 3 on Linux
22+ adapted from get_libboost_name() in configure.py and get_libboost_osx() below
23+ """
24+ places = ['/usr/lib/*/', '/usr/local/lib/']
25+ for place in places:
26+ lib = place + "libboost_python3*.so"
27+ files = glob.glob(lib)
28+ for f in files:
29+ if not "-mt" in f:
30+ return os.path.basename(f).replace("lib", "").split(".")[0]
31+
32+ print("NOT FOUND", files)
33+ sys.exit()
34+
35 def get_libboost_osx():
36 places = ["/usr/local/lib/"]
37 for place in places:
38@@ -36,7 +51,9 @@
39 if platform.system() == "Darwin":
40 boostlib = get_libboost_osx()
41 print(boostlib)
42-
43+elif platform.system() == "Linux":
44+ boostlib = get_libboost_linux()
45+ print(boostlib)
46 else:
47 boostlib = 'boost_python3'
48
49
50=== modified file 'py3exiv2/src/pyexiv2/xmp.py'
51--- py3exiv2/src/pyexiv2/xmp.py 2019-05-28 08:00:12 +0000
52+++ py3exiv2/src/pyexiv2/xmp.py 2020-03-19 01:47:23 +0000
53@@ -402,6 +402,8 @@
54 value = str(value, 'utf-8')
55 except TypeError:
56 raise XmpValueError(value, type_)
57+ elif value is None:
58+ raise XmpValueError(value, type_)
59 return value
60
61 elif type_ == 'Thumbnail':
62
63=== modified file 'py3exiv2/test/iptc.py'
64--- py3exiv2/test/iptc.py 2016-08-12 10:59:38 +0000
65+++ py3exiv2/test/iptc.py 2020-03-19 01:47:23 +0000
66@@ -214,6 +214,6 @@
67 def test_set_value_non_repeatable(self):
68 tag = IptcTag('Iptc.Application2.ReleaseDate')
69 value = [datetime.date.today(), datetime.date.today()]
70- self.failUnlessRaises(KeyError, setattr, tag, 'value', value)
71+ self.failUnlessRaises(ValueError, setattr, tag, 'value', value)
72
73
74
75=== added file 'py3exiv2/test/pickling.py'
76--- py3exiv2/test/pickling.py 1970-01-01 00:00:00 +0000
77+++ py3exiv2/test/pickling.py 2020-03-19 01:47:23 +0000
78@@ -0,0 +1,118 @@
79+# -*- coding: utf-8 -*-
80+
81+# ******************************************************************************
82+#
83+# Copyright (C) 2010 Olivier Tilloy <olivier@tilloy.net>
84+# Copyright (C) 2015-2016 Vincent Vande Vyvre <vincent.vandevyvre@oqapy.eu>
85+#
86+# This file is part of the pyexiv2 distribution.
87+#
88+# pyexiv2 is free software; you can redistribute it and/or
89+# modify it under the terms of the GNU General Public License
90+# as published by the Free Software Foundation; either version 2
91+# of the License, or (at your option) any later version.
92+#
93+# pyexiv2 is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU General Public License for more details.
97+#
98+# You should have received a copy of the GNU General Public License
99+# along with pyexiv2; if not, write to the Free Software
100+# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
101+#
102+# Maintainer: Vincent Vande Vyvre <vincent.vandevyvre@oqapy.eu>
103+#
104+# ******************************************************************************
105+
106+from pyexiv2.exif import ExifTag
107+from pyexiv2.iptc import IptcTag
108+from pyexiv2.xmp import XmpTag
109+from pyexiv2.utils import make_fraction, FixedOffset
110+
111+import unittest
112+import pickle
113+import datetime
114+
115+
116+class TestPicklingTags(unittest.TestCase):
117+
118+ def test_pickle_exif_tag(self):
119+ tags = []
120+ tags.append(ExifTag('Exif.Image.DateTime',
121+ datetime.datetime(2010, 12, 22, 19, 21, 0)))
122+ tags.append(ExifTag('Exif.GPSInfo.GPSDateStamp', datetime.date.today()))
123+ tags.append(ExifTag('Exif.Image.Copyright', '(C) 2010 Santa Claus'))
124+ tags.append(ExifTag('Exif.GPSInfo.GPSVersionID', '0'))
125+ tags.append(ExifTag('Exif.Pentax.Temperature', '14'))
126+ tags.append(ExifTag('Exif.Photo.UserComment', 'foo bar baz'))
127+ tags.append(ExifTag('Exif.Image.BitsPerSample', 8))
128+ tags.append(ExifTag('Exif.Image.TimeZoneOffset', 7))
129+ tags.append(ExifTag('Exif.Image.ImageWidth', 7492))
130+ tags.append(ExifTag('Exif.OlympusCs.ManometerReading', 29))
131+ tags.append(ExifTag('Exif.Image.XResolution', make_fraction(7, 3)))
132+ tags.append(ExifTag('Exif.Image.BaselineExposure', make_fraction(-7, 3)))
133+ tags.append(ExifTag('Exif.Photo.ExifVersion', '0100'))
134+ for tag in tags:
135+ s = pickle.dumps(tag)
136+ t = pickle.loads(s)
137+ self.assert_(isinstance(t, ExifTag))
138+ self.assertEqual(t.key, tag.key)
139+ self.assertEqual(t.type, tag.type)
140+ self.assertEqual(t.name, tag.name)
141+ self.assertEqual(t.label, tag.label)
142+ self.assertEqual(t.description, tag.description)
143+ self.assertEqual(t.section_name, tag.section_name)
144+ self.assertEqual(t.section_description, tag.section_description)
145+ self.assertEqual(t.raw_value, tag.raw_value)
146+ self.assertEqual(t.value, tag.value)
147+ self.assertEqual(t.human_value, tag.human_value)
148+
149+ def test_pickle_iptc_tag(self):
150+ tags = []
151+ tags.append(IptcTag('Iptc.Envelope.FileFormat', [23]))
152+ tags.append(IptcTag('Iptc.Application2.Subject', ['foo', 'bar', 'baz']))
153+ tags.append(IptcTag('Iptc.Envelope.DateSent', [datetime.date.today()]))
154+ tags.append(IptcTag('Iptc.Envelope.TimeSent',
155+ [datetime.time(23, 37, 4, tzinfo=FixedOffset('+', 6, 0))]))
156+ tags.append(IptcTag('Iptc.Application2.Preview', ['01001101']))
157+ for tag in tags:
158+ s = pickle.dumps(tag)
159+ t = pickle.loads(s)
160+ self.assert_(isinstance(t, IptcTag))
161+ self.assertEqual(t.key, tag.key)
162+ self.assertEqual(t.type, tag.type)
163+ self.assertEqual(t.name, tag.name)
164+ self.assertEqual(t.title, tag.title)
165+ self.assertEqual(t.description, tag.description)
166+ self.assertEqual(t.photoshop_name, tag.photoshop_name)
167+ self.assertEqual(t.repeatable, tag.repeatable)
168+ self.assertEqual(t.record_name, tag.record_name)
169+ self.assertEqual(t.record_description, tag.record_description)
170+ self.assertEqual(t.raw_value, tag.raw_value)
171+ self.assertEqual(t.value, tag.value)
172+
173+ def test_pickle_xmp_tag(self):
174+ tags = []
175+ tags.append(XmpTag('Xmp.dc.subject', ['foo', 'bar', 'baz']))
176+ tags.append(XmpTag('Xmp.xmpRights.Marked', True))
177+ tags.append(XmpTag('Xmp.xmp.CreateDate', datetime.date.today()))
178+ tags.append(XmpTag('Xmp.xmpMM.SaveID', 34))
179+ tags.append(XmpTag('Xmp.dc.format', ('image', 'jpeg')))
180+ tags.append(XmpTag('Xmp.photoshop.CaptionWriter', 'John Doe'))
181+ tags.append(XmpTag('Xmp.dc.source', 'bleh'))
182+ tags.append(XmpTag('Xmp.xmpMM.DocumentID', 'http://example.com'))
183+ tags.append(XmpTag('Xmp.xmp.BaseURL', 'http://example.com'))
184+ tags.append(XmpTag('Xmp.xmpDM.videoPixelAspectRatio', make_fraction(5, 3)))
185+ for tag in tags:
186+ s = pickle.dumps(tag)
187+ t = pickle.loads(s)
188+ self.assert_(isinstance(t, XmpTag))
189+ self.assertEqual(t.key, tag.key)
190+ self.assertEqual(t.type, tag.type)
191+ self.assertEqual(t.name, tag.name)
192+ self.assertEqual(t.title, tag.title)
193+ self.assertEqual(t.description, tag.description)
194+ self.assertEqual(t.raw_value, tag.raw_value)
195+ self.assertEqual(t.value, tag.value)
196+
197
198=== modified file 'py3exiv2/test/xmp.py'
199--- py3exiv2/test/xmp.py 2016-08-12 10:59:38 +0000
200+++ py3exiv2/test/xmp.py 2020-03-19 01:47:23 +0000
201@@ -229,7 +229,7 @@
202 self.assertEqual(tag._convert_to_python('Python Software Foundation', 'ProperName'),
203 'Python Software Foundation')
204 # Invalid values
205- self.assertRaises(XmpValueError, tag._convert_to_python(None, 'ProperName'))
206+ self.assertRaises(XmpValueError, tag._convert_to_python, None, 'ProperName')
207
208 def test_convert_to_string_propername(self):
209 # Valid values
210@@ -249,7 +249,7 @@
211 self.assertEqual(tag._convert_to_python(b'Some text with exotic ch\xc3\xa0r\xc3\xa4ct\xc3\xa9r\xca\x90.', 'Text'),
212 'Some text with exotic chàräctérʐ.')
213 # Invalid values
214- self.assertRaises(XmpValueError, tag._convert_to_python(None, 'Text'))
215+ self.assertRaises(XmpValueError, tag._convert_to_python, None, 'Text')
216
217 def test_convert_to_string_text(self):
218 # Valid values
219
220=== modified file 'setup.py'
221--- setup.py 2019-05-28 08:00:12 +0000
222+++ setup.py 2020-03-19 01:47:23 +0000
223@@ -1,6 +1,8 @@
224 #!/usr/bin/python3
225 # -*- coding: utf-8 -*-
226
227+# Replacement setup.py for py3exiv2, that allows building on OSX
228+# https://gist.github.com/ndevenish/6410cab393bd8dec1b016061ddb5573b
229
230 import sys
231 import os
232@@ -12,13 +14,28 @@
233
234 from codecs import open
235 from os import path
236-]
237+
238 here = path.abspath(path.dirname(__file__))
239
240 # Get the long description from the relevant file
241 with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
242 long_description = f.read()
243
244+def get_libboost_linux():
245+ """Returns the name of the lib libboost_python 3 on Linux
246+ adapted from get_libboost_name() in configure.py and get_libboost_osx() below
247+ """
248+ places = ['/usr/lib/*/', '/usr/local/lib/']
249+ for place in places:
250+ lib = place + "libboost_python3*.so"
251+ files = glob.glob(lib)
252+ for f in files:
253+ if not "-mt" in f:
254+ return os.path.basename(f).replace("lib", "").split(".")[0]
255+
256+ print("NOT FOUND", files)
257+ sys.exit()
258+
259 def get_libboost_osx():
260 places = ["/usr/local/lib/"]
261 for place in places:
262@@ -34,13 +51,15 @@
263 if platform.system() == "Darwin":
264 boostlib = get_libboost_osx()
265 print(boostlib)
266-
267+elif platform.system() == "Linux":
268+ boostlib = get_libboost_linux()
269+ print(boostlib)
270 else:
271 boostlib = 'boost_python3'
272
273 setup(
274 name='py3exiv2',
275- version='0.1.0',
276+ version='0.7.1',
277 description='A Python3 binding to the library exiv2',
278 long_description=long_description,
279 url='https://launchpad.net/py3exiv2',
280@@ -55,22 +74,24 @@
281 'Topic :: Software Development',
282 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
283 'Programming Language :: C++',
284- 'Programming Language :: Python :: 3.2',
285 'Programming Language :: Python :: 3.3',
286 'Programming Language :: Python :: 3.4',
287+ 'Programming Language :: Python :: 3.5',
288+ 'Programming Language :: Python :: 3.6',
289+ 'Programming Language :: Python :: 3.7',
290+ 'Programming Language :: Python :: 3.8'
291 ],
292 keywords='exiv2 pyexiv2 EXIF IPTC XMP image metadata',
293 packages = find_packages('src'),
294 package_dir = {'': 'src'},
295 package_data={'':['src/*.cpp', 'src/*.hpp',]},
296- # cmdclass={'install': install}
297+ #cmdclass={'install': install},
298 ext_modules=[
299 Extension('libexiv2python',
300 ['src/exiv2wrapper.cpp', 'src/exiv2wrapper_python.cpp'],
301- include_dirs=[],
302- library_dirs=[],
303 libraries=[boostlib, 'exiv2'],
304 extra_compile_args=['-g']
305 )
306 ],
307 )
308+

Subscribers

People subscribed via source and target branches

to all changes: