Skip to content

Commit

Permalink
Handle distutils without distutils.msvc9compiler.MSVCCompiler class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshilliard committed Aug 29, 2024
1 parent 9ba9c1e commit 547b8f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/cffi/_shimmed_dist_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from distutils.log import set_threshold, set_verbosity

if sys.platform == 'win32':
from distutils.msvc9compiler import MSVCCompiler
try:
from distutils.msvc9compiler import MSVCCompiler
except ImportError:
MSVCCompiler = None
except Exception as ex:
if sys.version_info >= (3, 12):
raise Exception("This CFFI feature requires setuptools on Python >= 3.12. Please install the setuptools package.") from ex
Expand Down
5 changes: 3 additions & 2 deletions src/cffi/recompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,8 +1484,9 @@ def _patch_for_embedding(patchlist):
if sys.platform == 'win32':
# we must not remove the manifest when building for embedding!
from cffi._shimmed_dist_utils import MSVCCompiler
_patch_meth(patchlist, MSVCCompiler, '_remove_visual_c_ref',
lambda self, manifest_file: manifest_file)
if MSVCCompiler is not None:
_patch_meth(patchlist, MSVCCompiler, '_remove_visual_c_ref',
lambda self, manifest_file: manifest_file)

if sys.platform == 'darwin':
# we must not make a '-bundle', but a '-dynamiclib' instead
Expand Down

0 comments on commit 547b8f6

Please sign in to comment.