Skip to content

Commit

Permalink
Load and initialize CinderX for Python 3.12
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alex Malyshev authored and facebook-github-bot committed Jul 31, 2024
1 parent 93d4169 commit 6c50c37
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -625,6 +637,7 @@ def main():
sethelper()
if not sys.flags.isolated:
enablerlcompleter()
init_cinder()
execsitecustomize()
if ENABLE_USER_SITE:
execusercustomize()
Expand Down

0 comments on commit 6c50c37

Please sign in to comment.