11# python-exiv2 - Python interface to libexiv2
22# http://github.com/jim-easterbrook/python-exiv2
3- # Copyright (C) 2021-25 Jim Easterbrook jim@jim-easterbrook.me.uk
3+ # Copyright (C) 2021-26 Jim Easterbrook jim@jim-easterbrook.me.uk
44#
55# This program is free software: you can redistribute it and/or modify
66# it under the terms of the GNU General Public License as published by
@@ -73,6 +73,7 @@ def get_mod_src_dir(exiv2_version):
7373packages = ['exiv2' , 'exiv2.examples' ]
7474package_dir = {'exiv2.examples' : 'examples' }
7575package_data = {'exiv2.examples' : ['*.py' , '*.rst' ]}
76+ extra_link_args = []
7677
7778if 'EXIV2_ROOT' in os .environ :
7879 # use local copy of libexiv2
@@ -83,29 +84,39 @@ def get_mod_src_dir(exiv2_version):
8384 print ('ERROR: Include files not found' )
8485 sys .exit (1 )
8586 include_dirs = [path ]
86- # library files
87- packages .append ('exiv2.lib' )
87+ # find library files
8888 if platform == 'linux' :
8989 path = os .path .join (exiv2_root , 'lib64' )
9090 if not os .path .exists (path ):
9191 path = os .path .join (exiv2_root , 'lib' )
92- library_dirs = [path ]
93- package_dir ['exiv2.lib' ] = path
94- package_data ['exiv2.lib' ] = [x for x in os .listdir (path )
95- if re .fullmatch (r'libexiv2\.so\.\d+' , x )]
92+ files = [x for x in os .listdir (path )
93+ if re .fullmatch (r'libexiv2\.so\.\d+' , x )]
9694 elif platform == 'darwin' :
9795 path = os .path .join (exiv2_root , 'lib' )
98- library_dirs = [path ]
99- package_dir ['exiv2.lib' ] = path
100- package_data ['exiv2.lib' ] = [x for x in os .listdir (path )
101- if re .fullmatch (r'libexiv2\.\d+\.dylib' , x )]
96+ files = [x for x in os .listdir (path )
97+ if re .fullmatch (r'libexiv2\.\d+\.dylib' , x )]
10298 elif platform in ('win32' , 'mingw' ):
103- library_dirs = [os .path .join (exiv2_root , 'lib' )]
104- package_dir ['exiv2.lib' ] = os .path .join (exiv2_root , 'bin' )
105- package_data ['exiv2.lib' ] = ['*.dll' ]
106- if not os .path .isdir (package_dir ['exiv2.lib' ]):
99+ path = os .path .join (exiv2_root , 'lib' )
100+ files = '*.dll'
101+ if not os .path .isdir (path ):
107102 print ('ERROR: Library files not found' )
108103 sys .exit (1 )
104+ library_dirs = [path ]
105+ if 'CIBUILDWHEEL' in os .environ :
106+ # include library files in "system" libraries to be renamed
107+ if platform in ('linux' , 'darwin' ):
108+ extra_link_args = ['-Wl,-rpath,{}' .format (os .path .abspath (path ))]
109+ else :
110+ # add library files to package data
111+ packages .append ('exiv2.lib' )
112+ package_dir ['exiv2.lib' ] = path
113+ package_data ['exiv2.lib' ] = files
114+ if platform == 'linux' :
115+ extra_link_args = ['-Wl,-rpath,$ORIGIN/lib' ]
116+ elif platform == 'darwin' :
117+ extra_link_args = ['-Wl,-rpath,@loader_path/lib' ]
118+ elif platform in ('win32' , 'mingw' ):
119+ package_dir ['exiv2.lib' ] = os .path .join (exiv2_root , 'bin' )
109120 # locale files
110121 path = os .path .join (exiv2_root , 'share' , 'locale' )
111122 if not os .path .isdir (path ):
@@ -121,12 +132,6 @@ def get_mod_src_dir(exiv2_version):
121132 # get exiv2 version from include files
122133 exiv2_version = get_version (include_dirs [0 ])
123134 mod_src_dir = get_mod_src_dir (exiv2_version )
124- if platform == 'linux' :
125- extra_link_args = ['-Wl,-rpath,$ORIGIN/lib' ]
126- elif platform == 'darwin' :
127- extra_link_args = ['-Wl,-rpath,@loader_path/lib' ]
128- else :
129- extra_link_args = []
130135else :
131136 # use installed libexiv2
132137 exiv2_version = pkg_config ('exiv2' , 'modversion' )
0 commit comments