# HG changeset patch # User Ludovic Chabant # Date 1419393288 28800 # 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 -r e8b09f920fe6 -r 6bc1702e7333 setup.py --- a/setup.py Sun Dec 28 23:50:08 2014 +0100 +++ b/setup.py Tue Dec 23 19:54:48 2014 -0800 @@ -76,7 +76,7 @@ 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 @@ 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',