-
Notifications
You must be signed in to change notification settings - Fork 375
Closed
Description
I have some use cases where we would like to launch the hy repl from inside of IPython
import hy
hy.REPL(locals = locals()).run()works inside of python
% python
Python 3.12.9 (main, Feb 4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hy
>>> hy.REPL(locals = locals()).run()
Hy 1.0.0 (Afternoon Review) using CPython(main) 3.12.9 on Darwin
=> (print "hello world")
hello world
=> ^D
now exiting REPL...
0
>>> ^D
fails in ipython
% ipython
Python 3.12.9 (main, Feb 4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.31.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import hy
...: hy.REPL(locals = locals()).run()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[1], line 2
1 import hy
----> 2 hy.REPL(locals = locals()).run()
File ~/py.env/lib/python3.12/site-packages/hy/repl.py:408, in REPL.run(self)
402 "Start running the REPL. Return 0 when done."
404 sentinel = []
405 saved_values = (
406 getattr(sys, "ps1", sentinel),
407 getattr(sys, "ps2", sentinel),
--> 408 builtins.quit,
409 builtins.exit,
410 builtins.help,
411 )
412 try:
413 sys.ps1 = self.ps1
AttributeError: module 'builtins' has no attribute 'quit'
repro from head
deactivate
mkdir hylang-repl
cd hylang-repl
python3 -m venv hyrepl.env
source hyrepl.env/bin/activate
pip install -U pip setuptools wheel
pip install ipython
pip install git+https://github.com/hylang/hy.git@master
% pip freeze
asttokens==3.0.0
decorator==5.2.1
executing==2.2.0
funcparserlib==1.0.1
hy @ git+https://github.com/hylang/hy.git@de884a5d9a4033a695673b9289a847977037b4cf
ipython==9.0.2
ipython_pygments_lexers==1.1.1
jedi==0.19.2
matplotlib-inline==0.1.7
parso==0.8.4
pexpect==4.9.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.1
pyperclip==1.9.0
setuptools==78.1.0
stack-data==0.6.3
traitlets==5.14.3
wcwidth==0.2.13
wheel==0.45.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels