diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
index 70afc58c32d3619ca2161eb3fc9d6d30a57e53f7_bWVyY3VyaWFsL2RlbWFuZGltcG9ydC5weQ==..2205d00b6d2b0d8abefd5034337f7eb58a970710_bWVyY3VyaWFsL2RlbWFuZGltcG9ydC5weQ== 100644
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -164,6 +164,8 @@
     '_ssl', # conditional imports in the stdlib, issue1964
     'rfc822',
     'mimetools',
+    # setuptools 8 expects this module to explode early when not on windows
+    'distutils.msvc9compiler'
     ]
 
 def isenabled():
diff --git a/tests/test-demandimport.py b/tests/test-demandimport.py
index 70afc58c32d3619ca2161eb3fc9d6d30a57e53f7_dGVzdHMvdGVzdC1kZW1hbmRpbXBvcnQucHk=..2205d00b6d2b0d8abefd5034337f7eb58a970710_dGVzdHMvdGVzdC1kZW1hbmRpbXBvcnQucHk= 100644
--- a/tests/test-demandimport.py
+++ b/tests/test-demandimport.py
@@ -1,6 +1,16 @@
 from mercurial import demandimport
 demandimport.enable()
 
+import os
+if os.name != 'nt':
+    try:
+        import distutils.msvc9compiler
+        print ('distutils.msvc9compiler needs to be an immediate '
+               'importerror on non-windows platforms')
+        distutils.msvc9compiler
+    except ImportError:
+        pass
+
 import re
 
 rsub = re.sub