This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author siming85
Recipients siming85
Date 2019-05-27.16:06:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558973175.26.0.897834780365.issue37066@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-05-27 16:06:15siming85setrecipients: + siming85
2019-05-27 16:06:15siming85setmessageid: <1558973175.26.0.897834780365.issue37066@roundup.psfhosted.org>
2019-05-27 16:06:15siming85linkissue37066 messages
2019-05-27 16:06:14siming85create