Skip to content

Commit

Permalink
Also check for _cinderx in 3.12/Lib/site.py
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alex Malyshev authored and facebook-github-bot committed Aug 2, 2024
1 parent 6c50c37 commit f001f97
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f001f97

Please sign in to comment.