Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython.utils._process_posix: import pexpect only when needed #14312

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

mkoeppe
Copy link
Collaborator

@mkoeppe mkoeppe commented Jan 30, 2024

Delaying the import of pexpect to the first use.

This is needed to make import IPython work on Pyodide; see pyodide/pyodide#4452

@mkoeppe mkoeppe mentioned this pull request Jan 30, 2024
2 tasks
@hoodmane
Copy link
Contributor

I'd suggest adding a new file making a _process_emscripten:

def system(cmd):
    raise OSError("Not available")

def getoutput(cmd):
    raise OSError("Not available")

def check_pid(cmd):
    raise OSError("Not available")

def arg_split(s, posix=False, strict=True):
    """This one could be made to work but it's not clear if it would be useful..."""
    raise OSError("Not available")

and then apply this patch:

--- a/IPython/utils/process.py
+++ b/IPython/utils/process.py
@@ -15,6 +15,8 @@
     from ._process_win32 import system, getoutput, arg_split, check_pid
 elif sys.platform == 'cli':
     from ._process_cli import system, getoutput, arg_split, check_pid
+elif sys.platform == "emscripten":
+    from ._process_emscripten import system, getoutput, arg_split, check_pid
 else:
     from ._process_posix import system, getoutput, arg_split, check_pid

@Carreau Carreau added this to the 8.21 milestone Jan 31, 2024
@Carreau
Copy link
Member

Carreau commented Jan 31, 2024

I'm going to make a release soon, so I'm going to merge this, but +1 to extend with adding a _process_emscripten.py

@Carreau Carreau merged commit 4eab608 into ipython:main Jan 31, 2024
18 of 19 checks passed
@hoodmane
Copy link
Contributor

Thanks @Carreau and @mkoeppe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants