You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and if the optional_feature is installed after this module is imported, the module would still behave as though it's not installed. A good example of this can be found in koenvo/pyodide-http#33 (comment) for the SSL module.
A solution is to minimize the import of modules before the installation, but it's not always possible in downstream applications.
We could raise this issue with CPython but it's unlikely that would want to make this feature detection more dynamic, instead of pre-determined at import time.
The other alternative is to have a list of modules that do this and reload them (if they are already imported and present in sys.modules) when such an optional stdlib module is installed. For instance, looking, at
rg -U "try:\n\s+import ssl" cpython/Lib
gives some idea of the impacted modules. This dependency tree could probably be determined automatically by parsing the code.
It would help, but probably not address more complex dependencies as outlined in the above-linked issue.
The text was updated successfully, but these errors were encountered:
Thanks for opening the issue @rth. Dealing with optional stdlib modules is indeed quite tricky... not sure reloading can solve the complex dependencies that you mentioned but it is worth trying.
The stdlib modules have some number of optional components that we also allow to be optionally installed.
Unfortunately, CPython does not operate under the assumption that such modules can be installed at runtime. Modules would have a
and if the optional_feature is installed after this module is imported, the module would still behave as though it's not installed. A good example of this can be found in koenvo/pyodide-http#33 (comment) for the SSL module.
A solution is to minimize the import of modules before the installation, but it's not always possible in downstream applications.
We could raise this issue with CPython but it's unlikely that would want to make this feature detection more dynamic, instead of pre-determined at import time.
The other alternative is to have a list of modules that do this and reload them (if they are already imported and present in
sys.modules
) when such an optional stdlib module is installed. For instance, looking, atrg -U "try:\n\s+import ssl" cpython/Lib
gives some idea of the impacted modules. This dependency tree could probably be determined automatically by parsing the code.
It would help, but probably not address more complex dependencies as outlined in the above-linked issue.
The text was updated successfully, but these errors were encountered: