Skip to content

Comments

WIP: Feature/save user session venv (solves #879)#880

Open
markdoerr wants to merge 5 commits intognome-terminator:masterfrom
markdoerr:feature/save-user-session-venv
Open

WIP: Feature/save user session venv (solves #879)#880
markdoerr wants to merge 5 commits intognome-terminator:masterfrom
markdoerr:feature/save-user-session-venv

Conversation

@markdoerr
Copy link
Contributor

Additionally to the current working directory, it would be nice to also store the python virtual environment that is currently used in the config file and re-activate it on Session restore.

This solves #879

@markdoerr
Copy link
Contributor Author

Hi terminator developers,

I just need to figure out, how to get the virtual environment of a current terminal.

prefix = getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
     if prefix != sys.prefix: # session is in a virtual environment
         return sys.prefix

cannot work in this case, as we would need to run a python program within the current shell.

Do you know, if this information is kept somewhere in the shell / process ? (it should, since command prompts also show the current venv)

@markdoerr markdoerr changed the title WIP: Feature/save user session venv (#879) WIP: Feature/save user session venv (solves #879) Feb 4, 2024
@mattrose
Copy link
Member

Can you fix the conflicts from your version change? Then I think I can merge this in. This is getting really close to adding functionality that is not strictly part of the terminal emulator process, but I think I'll allow it.

To really add venv functionality, you could look at adding venv to the layout editor as well. Add it as an extra parameter to the layouts.

I'm worried that this is getting into "Python IDE" territory, but I'm allowing it as this is what a lot of people are actually using it for.

@markdoerr
Copy link
Contributor Author

markdoerr commented Feb 19, 2024

Hi @mattrose, I can fully understand your concerns
( when I started this branch, I also thought about it ;), but as it is a python based application and many people use python, it is worth having this feature included).
So thanks for supporting this PR ! :)

There is one "game-stopper" preventing me from finallising the pull request (next to my time limitations):
I have not found an elegant, pythonic way to get hold of the name / path of the current virtual environment of a terminator window:
to my understanding of terminator, this information is hold only by the shell running in the window.
Is there a generic interface, I could use to query the shell for the python environment ? How can i run this code snippet shown above ?
Do you have any idea ? Thanks, mark

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.

2 participants