Python 3.73 cannot install py3exiv2

Vincent Vande Vyvre vincent.vande.vyvre at telenet.be
Thu May 2 05:50:59 EDT 2019


Le 1/05/19 à 15:12, Ken Martell a écrit :
> I’m a retired aerospace engineer. I’m a Windows 10 user & have zero experience with Python. My goal is to learn, get this working & run lens distortion correction routines using Python. I’ve tried or many hours and read as much as I can but cannot get the py3exiv2 module to install. Other needed modules installed fine. It appears the Python version 2 of evix2 is needed as a dependent for the version 3 but neither pip or pip3 will install old or new. Sorry for taking your time but I’m a newbie just trying to help my fellow photographers correct  lens distortion problems in post-processing as well as my own.
>
> Any help much appreciated!
>
> Thank you
> Ken Martell
>
>
>
> Sent from Mail for Windows 10
>
>

The package available on PyPI is for *nix machines.

I don't have access to a Windows machine nor the knowledge to build an 
executable for Windows.

But, recently an user send me how it has successfully compiled py3exiv2 
for Windows.



Hello Vincent,

  I’ve run through the trouble of building py3exiv2 on Windows and was 
successful in doing so,

therefore I’d like to present you the steps I’ve taken to get there, so 
that you can alter setup.py and give some instructions on how to install 
it on Windows.

This is a copy of his mail:
-----------------------------------------------------------------------------------
  The key part in making this work is 
https://github.com/Microsoft/vcpkg, it has both exiv2 and boost-python.

Here’s what I did:

  [INSTALLING PYEXIV3 ON WINDOWS]
- install GIT-2.21.0-64-bit.exe
- install VSCodeUserSetup-x64-1.33.1.exe
- clone vcpkg, note the folder name
     $ git clone https://github.com/Microsoft/vcpkg.git
- install vcpkg by running .\bootstrap-vcpkg.bat
- run vcpkg.exe install boost-python:x64-windows
- run vcpkg.exe install exiv2:x64-windows
- make sure to add /installed/x64-windows/bin to the PATH (for dll import)
- get the pyexiv2 sources from here: http://py3exiv2.tuxfamily.org/downloads
- replace setup.py with my version
- set the environment variable VCPKG to the folder where you installed it
- run pip install -e <py3exiv2-folder>

I’ve attached my modified version of setup.py. It’s very rough since I 
don’t know much about setuptools at all, but it essentially involves 
bypassing `get_libboost_name` which fails completely on windows and 
using the environment variable VCPGK that has to be set by the user to 
point at the vcpkg directory. There’s probably a cleaner way of doing 
this, like accepting a command line argument. But again, I have no idea 
how setuptools handles this so hopefully you can clean it up a bit. 
`boost_python37-vc140-mt` is also completely hardcoded, you’d probably 
have to modify `get_libboost_name` to work on Windows.

  While I’m at this, I’ve noticed the lack of support for custom xmp 
tags. For now I’ve resorted to abusing various IPTC Tags for my purpose, 
but that’s a rather terrible solution. I’d appreciate it if you could 
prioritize adding that feature in the future.

  with best regards,

Vic

setup.py

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import os
import glob
import subprocess

from setuptools import setup, find_packages, Extension

from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
     long_description = f.read()

def get_libboost_name():
     """Returns the name of the lib libboost_python 3

     """
     # libboost libs are provided without .pc files, so we can't use 
pkg-config
     places = ('/usr/lib/', '/usr/local/lib/', '/usr/')
     for place in places:
         cmd = ['find', place, '-name', 'libboost_python*']
         rep = subprocess.Popen(cmd, 
stdout=subprocess.PIPE).communicate()[0]
         if not rep:
             continue

         # rep is type bytes
         libs = rep.decode(sys.getfilesystemencoding()).split('\n')
         for l in libs:
             _, l = os.path.split(l)
             if '.so' in l:
                 l = l.split('.so')[0]
                 # Assume there's no longer python2.3 in the wild
                 if '3' in l[-2:]:
                     return l.replace('libboost', 'boost')

if os.name == 'nt':
     basep = os.environ["VCPKG"] + r"\installed\x64-windows"
     os.environ["INCLUDE"] = basep + r"\include"
     libboost = basep + r"\lib\boost_python37-vc140-mt"
     libexiv = basep + r"\lib\exiv2"
     extra_compile_args = []
else:
     libboost = get_libboost_name()
     extra_compile_args = []
     libexiv = 'exiv2'

setup(
     name='py3exiv2',
     version='0.7.0',
     description='A Python3 binding to the library exiv2',
     long_description=long_description,
     url='https://launchpad.net/py3exiv2',
     author='Vincent Vande Vyvre',
     author_email='vincent.vandevyvre at oqapy.eu',
     license='GPL-3',

     # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
     classifiers=[
         'Development Status :: 5 - Production/Stable',
         'Intended Audience :: Developers',
         'Topic :: Software Development',
         'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
         'Programming Language :: C++',
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: 3.7',
         'Programming Language :: Python :: 3.8'
     ],
     keywords='exiv2 pyexiv2 EXIF IPTC XMP image metadata',
     packages = find_packages('src'),
     package_dir = {'': 'src'},
     package_data={'':['src/*.cpp', 'src/*.hpp',]},
     #cmdclass={'install': install}
     ext_modules=[
     Extension('libexiv2python',
         ['src/exiv2wrapper.cpp', 'src/exiv2wrapper_python.cpp'],
         include_dirs=[],
         library_dirs=[],
         libraries=[libboost, libexiv],
         extra_compile_args=extra_compile_args
         )
     ],
)
--------------------------------------------------------------------------------

Vincent




More information about the Python-list mailing list