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


Groups > comp.lang.python > #66760

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!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
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; "'python": 0.09; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'setup.py': 0.09; 'subject:files': 0.09; 'way:': 0.09; 'runs': 0.10; 'cc:addr :python-list': 0.11; 'python': 0.11; 'question.': 0.14; '[4]:': 0.16; 'cc:name:python list': 0.16; 'context:': 0.16; 'piotr': 0.16; 'subject: \n ': 0.16; 'subject:default': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'pfxlen:0': 0.19; "python's": 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'install': 0.23; 'script.': 0.24; 'subject:like': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'way?': 0.31; 'run': 0.32; '(e.g.': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'files': 0.38; 'skip:. 10': 0.39; 'sure': 0.39; 'how': 0.40; 'places': 0.64; 'different': 0.65; 'within': 0.65; 'default': 0.69; 'subject:get': 0.81; 'accompany': 0.84; 'activated': 0.84; 'oscar': 0.84; 'to:addr:p': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=nIxS5uluo69nFMWQU5ZCrAFm4SQdGwsfkvSqKkaIFzg=; b=fLJAAA45mz9NbXDZQyPjRxVigUYsgP/GfDpgKPoOsLmeJExL+L1/gXGARfD+uB0703 u3rACM+owOBuo7tnlY+1JVkKu6qZe2Q5dydxB9IqQ+af01jfLlRsVohO7V6Afnh5tZLC oZ+onG6aO0kjLKJhjqok0RBit+u/9fktyetiyVKt+ntbL/AIy4zuJUKHq3N/lJ98/kCY aYRyl3AdHRiX8SGfotQsmOFh8YtCkWbl7fcn1D37NSQ5LnJ6O5oTeryzt1RcOUPcDXf9 ftzHjP00Sa9BCqF9J796NEs0gbjLhbW6uiZxQhbRHsTUBoAML26MyWJDLtIY0wKDx4ea x0KA==
X-Received by 10.52.84.102 with SMTP id x6mr1076935vdy.49.1392909793221; Thu, 20 Feb 2014 07:23:13 -0800 (PST)
MIME-Version 1.0
In-Reply-To <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com>
References <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Thu, 20 Feb 2014 15:22:53 +0000
Subject Re: Cross-platform way to get default directory for binary files like console scripts?
To Piotr Dobrogost <p@google-groups-2014.dobrogost.net>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc Python List <python-list@python.org>
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.7188.1392909800.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392909801 news.xs4all.nl 2926 [2001:888:2000:d::a6]:50276
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66760

Show key headers only | View raw


On 20 February 2014 14:27, Piotr Dobrogost
<p@google-groups-2014.dobrogost.net> wrote:
> 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

I'm not sure if I understand the question. Are you trying to find
where a script would go if it had been installed as a result of
'python setup.py install' or 'pip install ...'? If so there are
different places it could go depending not only on the system but also
how the packages were installed (e.g. --user).

You can find the default location in this roundabout way:

In [1]: from distutils.command.install import install

In [2]: from distutils.dist import Distribution

In [3]: c = install(Distribution())

In [4]: c.finalize_
c.finalize_options  c.finalize_other    c.finalize_unix

In [4]: c.finalize_options()

In [5]: c.insta
c.install_base       c.install_headers    c.install_lib
c.install_path_file  c.install_platlib    c.install_scripts
c.install_usersite
c.install_data       c.install_layout     c.install_libbase
c.install_platbase   c.install_purelib    c.install_userbase

In [5]: c.install_scripts
Out[5]: '/usr/local/bin'


Oscar

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