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: 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 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 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On 20 February 2014 14:27, Piotr Dobrogost wrote: > Is there cross-platform way to get default directory for binary files (co= nsole 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 interpr= eter used to run this script. Please note that the script may be run from w= ithin virtualenv which had not been activated - ./venv/bin/python our_scrip= t.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 =3D 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