# HG changeset patch # User Ludovic Chabant # Date 2014-12-24 03:54:48 # Node ID 6bc1702e73335a1d3dadcd5d19adfbb32107bc1c # Parent e8b09f920fe6b6c607b9f6a8c2416e2674578720 setup: don't fail when Python doesn't have the cygwinccompiler package Some Python installations like the ones available from the optware project for the Synology DiskStation NASes don't have that package, which means running the setup script will crash and exit right away. Instead, we now just use an empty/fake class for the HackedMingw32CCompiler, which we likely won't use anyway. diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -76,7 +76,7 @@ from distutils.command.build_py import b from distutils.command.install_lib import install_lib from distutils.command.install_scripts import install_scripts from distutils.spawn import spawn, find_executable -from distutils import cygwinccompiler, file_util +from distutils import file_util from distutils.errors import CCompilerError, DistutilsExecError from distutils.sysconfig import get_python_inc, get_config_var from distutils.version import StrictVersion @@ -509,19 +509,28 @@ else: extra_link_args=osutil_ldflags, depends=common_depends)) -# the -mno-cygwin option has been deprecated for years -Mingw32CCompiler = cygwinccompiler.Mingw32CCompiler +try: + from distutils import cygwinccompiler + + # the -mno-cygwin option has been deprecated for years + compiler = cygwinccompiler.Mingw32CCompiler -class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler): - def __init__(self, *args, **kwargs): - Mingw32CCompiler.__init__(self, *args, **kwargs) - for i in 'compiler compiler_so linker_exe linker_so'.split(): - try: - getattr(self, i).remove('-mno-cygwin') - except ValueError: - pass + class HackedMingw32CCompiler(cygwinccompiler.Mingw32CCompiler): + def __init__(self, *args, **kwargs): + compiler.__init__(self, *args, **kwargs) + for i in 'compiler compiler_so linker_exe linker_so'.split(): + try: + getattr(self, i).remove('-mno-cygwin') + except ValueError: + pass -cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler + cygwinccompiler.Mingw32CCompiler = HackedMingw32CCompiler +except ImportError: + # the cygwinccompiler package is not available on some Python + # distributions like the ones from the optware project for Synology + # DiskStation boxes + class HackedMingw32CCompiler(object): + pass packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo', 'help/*.txt',