From f001f97783c3479eee16300d1c119a9d31122f12 Mon Sep 17 00:00:00 2001 From: Alex Malyshev Date: Fri, 2 Aug 2024 09:13:52 -0700 Subject: [PATCH] Also check for _cinderx in 3.12/Lib/site.py Summary: cinder_binary( name = "foo", py_version = "3.12", ... ) will pull in `cinderx`, but not the inner `_cinderx` C++ extension, so it will fail to initialize. The `_cinderx` module isn't ready to be built without an explicit `cinderx.use_3_12=true` buckconfig value, so we can't bundle it in yet. The easiest way to get out of this hole is to also check for the existence of the `_cinderx` module. python_binary( name = "foo", py_version = "3.12", ... ) is fine on the other hand. It doesn't pull in `cinderx`. Differential Revision: D60594172 fbshipit-source-id: 4ad6834d5baf720419d95dc99436d1c4a772ce3d --- Lib/site.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/site.py b/Lib/site.py index 711b868ec2d..232c802af74 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -602,7 +602,14 @@ def execusercustomize(): def init_cinder(): import importlib.util - if importlib.util.find_spec("cinderx") is None: + + # `cinderx` is the Python module in fbcode/cinderx/PythonLib which wraps the + # `_cinderx` C++ extension in fbcode/cinderx/_cinderx.cpp. Both need to be + # available to load CinderX. + if ( + importlib.util.find_spec("cinderx") is None + or importlib.util.find_spec("_cinderx") is None + ): return try: import cinderx