From 6c50c377ca266b58083c4541cb1835f02b9771fa Mon Sep 17 00:00:00 2001 From: Alex Malyshev Date: Wed, 31 Jul 2024 09:35:42 -0700 Subject: [PATCH] Load and initialize CinderX for Python 3.12 Summary: Loads and initializes the CinderX module as part of Lib/site.py. If the module can't be found, such as when CinderX isn't bundled with the installation, then silently nothing happens. Failures that bubble up to the top-level CinderX module are no longer suppressed. The suppression that does need to be added is to the _static module, as that's not initializing successfully right now. I have no idea if this is what we had in mind for initializing CinderX for 3.12. I believe our plan was to make it more explicit and only load when users added the extension as a dependency to their TARGETS rules. But in the meantime this helps us run tests. Reviewed By: jbower-fb Differential Revision: D60384976 fbshipit-source-id: fe28752e967d7562012031540188279d044d66a3 --- Lib/site.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/site.py b/Lib/site.py index 4d72942230e..711b868ec2d 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -600,6 +600,18 @@ def execusercustomize(): (err.__class__.__name__, err)) +def init_cinder(): + import importlib.util + if importlib.util.find_spec("cinderx") is None: + return + try: + import cinderx + + cinderx.init() + except Exception as e: + raise RuntimeError("Failed to initialize CinderX module") from e + + def main(): """Add standard site-specific directories to the module search path. @@ -625,6 +637,7 @@ def main(): sethelper() if not sys.flags.isolated: enablerlcompleter() + init_cinder() execsitecustomize() if ENABLE_USER_SITE: execusercustomize()