Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66758
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Subject | Re: Cross-platform way to get default directory for binary files like console scripts? |
| Date | 2014-02-20 10:11 -0500 |
| References | <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7187.1392909097.18130.python-list@python.org> (permalink) |
On 2/20/14 9:27 AM, Piotr Dobrogost wrote: > Hi! > > Is there cross-platform way to get default directory for binary files (console scripts for instance) the same way one can use sys.executable to get path to the Python's interpreter in cross-platform way? > > Context: > There's Python script which runs various tools like pip using subprocess and we would like to make sure we run tools that accompany Python's interpreter used to run this script. Please note that the script may be run from within virtualenv which had not been activated - ./venv/bin/python our_script.py > > > Regards, > Piotr Dobrogost > Hi Piotr, we talked about this briefly in #python this morning. I still don't quite understand why you are averse to activating the virtualenv. It is designed to solve precisely this problem: create an environment that uses the natural OS tools (including PATH) to produce a consistent environment that works the way tools expect. If you don't activate the virtualenv, then you can look for your Python executable using sys.executable, and see if the file you want to run is in that same directory. I have no idea under what conditions that is the right or wrong answer, and I don't know what to do if the file you're looking for isn't in that directory. Perhaps the shorter answer is, look in the Python executable directory, then look in the directories on PATH. -- Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Cross-platform way to get default directory for binary files like console scripts? Piotr Dobrogost <p@google-groups-2014.dobrogost.net> - 2014-02-20 06:27 -0800
Re: Cross-platform way to get default directory for binary files like console scripts? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-20 10:11 -0500
Re: Cross-platform way to get default directory for binary files like console scripts? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-20 15:22 +0000
Re: Cross-platform way to get default directory for binary files like console scripts? Piotr Dobrogost <p@google-groups-2014.dobrogost.net> - 2014-02-20 07:34 -0800
Re: Cross-platform way to get default directory for binary files like console scripts? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-20 10:42 -0500
Re: Cross-platform way to get default directory for binary files like console scripts? Piotr Dobrogost <p@google-groups-2014.dobrogost.net> - 2014-02-20 07:55 -0800
Re: Cross-platform way to get default directory for binary files like console scripts? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-20 15:44 +0000
Re: Cross-platform way to get default directory for binary files like console scripts? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-20 15:55 +0000
Re: Cross-platform way to get default directory for binary files like console scripts? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-20 11:26 -0500
Re: Cross-platform way to get default directory for binary files like console scripts? Piotr Dobrogost <p@google-groups-2014.dobrogost.net> - 2014-02-21 06:12 -0800
csiph-web