[Python-Dev] Set program name through exec -a or environment variable

tritium-list at sdamon.com tritium-list at sdamon.com
Sat Mar 18 22:48:40 EDT 2017


https://pypi.python.org/pypi/setproctitle

 

 

From: Python-Dev [mailto:python-dev-bounces+tritium-list=sdamon.com at python.org] On Behalf Of Freddy Rietdijk
Sent: Saturday, March 18, 2017 9:15 AM
To: Python-Dev <python-dev at python.org>
Subject: [Python-Dev] Set program name through exec -a or environment variable

 

Hi,

 

I would like to know if you're open to supporting `exec -a` or an environment variable for setting `argv[0]`, and have some pointers as to where that should be implemented.

 

On Nixpkgs we typically use wrappers to set environment variables like PATH or PYTHONPATH for individual programs. Consider a program named `prog`. We move the original program `prog` to `.prog-wrapped` and then create a wrapper `prog` that does `exec -a prog .prog-wrapped`. 

 

Unfortunately `exec -a` does not work with Python. The process is still named `.prog-wrapped` (although that's not really a problem) but worse, `sys.argv[0]` is also `.prog-wrapped`. Currently we inject some code in programs that sets `sys.argv=[0] = "prog" but this is fragile and I would prefer to get rid of this.

 

Kind regards,

 

Frederik

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170318/c874d12f/attachment.html>


More information about the Python-Dev mailing list