Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "'python": 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'setup.py': 0.09; 'subject:files': 0.09; 'way:': 0.09; 'api': 0.11; 'python': 0.11; 'question.': 0.14; '2.7.2': 0.16; 'after,': 0.16; 'benjamin': 0.16; 'none.': 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; 'thursday,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thanks.': 0.20; '>>>': 0.22; 'import': 0.22; 'install': 0.23; 'header:User-Agent:1': 0.23; 'subject:like': 0.24; 'script': 0.25; 'right.': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'wondering': 0.29; 'am,': 0.29; "doesn't": 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; '4.0': 0.31; "skip:' 40": 0.31; 'yes.': 0.31; 'compatible': 0.32; '(e.g.': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'info': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'apple': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'advanced': 0.63; 'places': 0.64; 'more': 0.64; 'different': 0.65; '20,': 0.68; 'default': 0.69; 'subject:get': 0.81; '4.2.1': 0.84; 'oscar': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Cross-platform way to get default directory for binary files like console scripts? Date: Thu, 20 Feb 2014 10:42:54 -0500 References: <405ad1dc-691e-4c71-adfd-c19c599ad555@googlegroups.com> <991f7bda-7313-4192-9e56-410a454b79d8@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: <991f7bda-7313-4192-9e56-410a454b79d8@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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392910988 news.xs4all.nl 2873 [2001:888:2000:d::a6]:37232 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66763 On 2/20/14 10:34 AM, Piotr Dobrogost wrote: > On Thursday, February 20, 2014 4:22:53 PM UTC+1, Oscar Benjamin wrote: >> >> 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 ...'? > >> Yes. > >> 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). > > Right. > >> You can find the default location in this roundabout way: >> >> (...) >> >> In [5]: c.install_scripts >> Out[5]: '/usr/local/bin' > > I think this is pretty much what I'm after, thanks. > I'm wondering if there's some API to get this info as what you showed is really roundabout way to achieve the goal... As roundabout and advanced as that code is, it doesn't give the right answer for me. It returns None. On my Mac, after activating a virtualenv: Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from distutils.command.install import install >>> from distutils.dist import Distribution >>> c = install(Distribution()) >>> c.install_scripts >>> c.install_scripts is None True >>> sys.executable '/usr/local/virtualenvs/studygroup/bin/python' >>> os.listdir(os.path.dirname(sys.executable)) ['activate', 'activate.csh', 'activate.fish', 'activate_this.py', 'easy_install', 'easy_install-2.7', 'pip', 'pip-2.7', 'python', 'python2', 'python2.7'] >>> -- Ned Batchelder, http://nedbatchelder.com