Skip to content

Commit

Permalink
Improve swig detection code
Browse files Browse the repository at this point in the history
- 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()
  • Loading branch information
LudovicRousseau committed Aug 12, 2023
1 parent 5f3a828 commit 4283a20
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4283a20

Please sign in to comment.