prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.23k stars 280 forks source link

ptipython does not have get_ipython() during execution of PYTHONSTARTUP files #350

Open wookayin opened 4 years ago

wookayin commented 4 years ago

With PYTHONSTARTUP=~/.pythonrc.py, ptipython executes ~/.pythonrc.py (if exists) during startup as vanilla python,ipython does, but during executing ~/.pythonrc.py there is no get_ipython() available. Because of this, we cannot run some ipython-specific startup commands (e.g., registering custom magics).

Please note that in the vanilla ipython, get_ipython() exists in the namespace even during PYTHONSTARTUP files.

wookayin commented 1 year ago

Bumping up -- Any idea or updates here?

wookayin commented 1 year ago

Similar to #126. #448 adds a support of ipython profile directory, but it doesn't respect PYTHONSTARTUP and --interactive (which were added in 2016 much eariler than #448, bdd69773f0913bd5a771e66ca957002b94bf473f).

Execution of startup paths (including PYTHONSTARTUP) must be done inside an ipython shell, not in exec outside embed(). I am going to write a PR soon.