Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66758

Re: Cross-platform way to get default directory for binary files like console scripts?

Path csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'interpreter': 0.05; 'binary': 0.07; 'problem:': 0.07; 'executable': 0.09; 'path)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'runs': 0.10; 'python': 0.11; '#python': 0.16; 'context:': 0.16; 'path.': 0.16; 'piotr': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:default': 0.16; 'virtualenv.': 0.16; 'wrote:': 0.18; "python's": 0.19; 'header:User-Agent:1': 0.23; 'directory.': 0.24; 'script.': 0.24; 'subject:like': 0.24; 'environment': 0.24; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'directory,': 0.31; 'talked': 0.31; 'way?': 0.31; 'file': 0.32; 'run': 0.32; 'quite': 0.32; '(including': 0.33; 'there': 0.35; 'activate': 0.36; 'consistent': 0.36; 'shorter': 0.36; 'subject:?': 0.36; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'skip:. 10': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'solve': 0.60; "you're": 0.61; 'within': 0.65; 'natural': 0.68; 'default': 0.69; 'subject:get': 0.81; 'accompany': 0.84; 'activated': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: Cross-platform way to get default directory for binary files like console scripts?
Date Thu, 20 Feb 2014 10:11:15 -0500
References <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 18.189.35.65
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7187.1392909097.18130.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392909098 news.xs4all.nl 2856 [2001:888:2000:d::a6]:43584
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66758

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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