Message343654
Using os.execl you can open a new bash shell (eg, using python to process some env before opening a new shell.
$ echo $SHLVL
1
$ ~/.pyenv/versions/3.6.4/bin/python3
Python 3.6.4 (default, Feb 5 2018, 16:53:35)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.execl('/bin/bash', '')
$ echo $SHLVL
2
Doing the above works with just /bin/bash no arguments. (notice SHLVL incrementing)
But providing your own custom --init-file or --rcfile, doesn't.
eg - /bin/bashrc --rcfile <path to a venv activate file>
$ echo $SHLVL
1
$ ~/.pyenv/versions/3.6.4/bin/python3
Python 3.6.4 (default, Feb 5 2018, 16:53:35)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.execl('/bin/bash', '--rcfile','/users/me/venv/bin/activate')
$ echo $SHLVL
1
this can be replicated in Python 3.5 to 3.7
can be worked-around if using a wrapper.sh file with:
#! /bin/bash
exec /bin/bash --rcfile /users/me/venv/bin/activate
and running this file in os.execl() instead. |
|
Date |
User |
Action |
Args |
2019-05-27 16:06:15 | siming85 | set | recipients:
+ siming85 |
2019-05-27 16:06:15 | siming85 | set | messageid: <1558973175.26.0.897834780365.issue37066@roundup.psfhosted.org> |
2019-05-27 16:06:15 | siming85 | link | issue37066 messages |
2019-05-27 16:06:14 | siming85 | create | |
|