From 4283a20e431d76c30b79b77d4ac987912dafe490 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Sat, 12 Aug 2023 11:14:34 +0200 Subject: [PATCH] Improve swig detection code - do not use deprecated distutils - Check for swig only for the "build" but not "clean" action. "make clean" will work even if swig is not installed - Use exit() instead of sys.exit() --- setup.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index ee46e12e..eaeb5e0c 100755 --- a/setup.py +++ b/setup.py @@ -30,10 +30,10 @@ import subprocess import sys from sysconfig import get_platform +from shutil import which from setuptools import setup, Extension from setuptools.command.build_py import build_py -from distutils.spawn import find_executable platform_include_dirs = [] @@ -65,11 +65,6 @@ except: platform_include_dirs = ['/usr/include/PCSC', '/usr/local/include/PCSC'] -if find_executable("swig") is None: - print("Install swig and try again") - print("") - sys.exit(1) - VERSION_INFO = (2, 0, 7, 0) VERSION_STR = '%i.%i.%i' % VERSION_INFO[:3] VERSION_ALT = '%i,%01i,%01i,%04i' % VERSION_INFO @@ -78,6 +73,10 @@ class BuildPyBuildExtFirst(build_py): """Workaround substitude `build_py` command for SWIG""" def run(self): + if which("swig") is None: + print("Install swig and try again") + print("") + exit(1) # Run build_ext first so that SWIG generated files are included self.run_command('build_ext') return build_py.run(self)