--- a/swig/python/setup.py.in
+++ b/swig/python/setup.py.in
@@ -29,14 +29,12 @@
     if os.environ['CXX'].strip().startswith('ccache ') and os.environ['CXX'].strip()[len('ccache '):].find(' ') < 0:
         os.environ['CXX'] = os.environ['CXX'].strip()[len('ccache '):]
     else:
-        print('WARNING: "CXX=%s" was defined in the environment and contains more than one word. Unsetting it since that is incompatible of setuptools' % os.environ['CXX'])
-        del os.environ['CXX']
+        os.environ['CXX'] = os.environ['CXX'].split(' ', 1)[0]
 if 'CC' in os.environ and os.environ['CC'].strip().find(' ') >= 0:
     if os.environ['CC'].strip().startswith('ccache ') and os.environ['CC'].strip()[len('ccache '):].find(' ') < 0:
         os.environ['CC'] = os.environ['CC'].strip()[len('ccache '):]
     else:
-        print('WARNING: "CC=%s" was defined in the environment and contains more than one word. Unsetting it since that is incompatible of setuptools' % os.environ['CC'])
-        del os.environ['CC']
+        os.environ['CC'] = os.environ['CC'].split(' ', 1)[0]
 
 # ---------------------------------------------------------------------------
 # Switches
