aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py')
-rw-r--r--.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py b/.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py
new file mode 100644
index 00000000..c3d23128
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py
@@ -0,0 +1,45 @@
+"""
+Temporary shim module to indirect the bits of distutils we need from setuptools/distutils while providing useful
+error messages beyond `No module named 'distutils' on Python >= 3.12, or when setuptools' vendored distutils is broken.
+
+This is a compromise to avoid a hard-dep on setuptools for Python >= 3.12, since many users don't need runtime compilation support from CFFI.
+"""
+import sys
+
+try:
+ # import setuptools first; this is the most robust way to ensure its embedded distutils is available
+ # (the .pth shim should usually work, but this is even more robust)
+ import setuptools
+except Exception as ex:
+ if sys.version_info >= (3, 12):
+ # Python 3.12 has no built-in distutils to fall back on, so any import problem is fatal
+ raise Exception("This CFFI feature requires setuptools on Python >= 3.12. The setuptools module is missing or non-functional.") from ex
+
+ # silently ignore on older Pythons (support fallback to stdlib distutils where available)
+else:
+ del setuptools
+
+try:
+ # bring in just the bits of distutils we need, whether they really came from setuptools or stdlib-embedded distutils
+ from distutils import log, sysconfig
+ from distutils.ccompiler import CCompiler
+ from distutils.command.build_ext import build_ext
+ from distutils.core import Distribution, Extension
+ from distutils.dir_util import mkpath
+ from distutils.errors import DistutilsSetupError, CompileError, LinkError
+ from distutils.log import set_threshold, set_verbosity
+
+ if sys.platform == 'win32':
+ try:
+ # FUTURE: msvc9compiler module was removed in setuptools 74; consider removing, as it's only used by an ancient patch in `recompiler`
+ 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
+
+ # anything older, just let the underlying distutils import error fly
+ raise Exception("This CFFI feature requires distutils. Please install the distutils or setuptools package.") from ex
+
+del sys