Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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; 'programmer': 0.03; 'subject:Python': 0.06; 'distutils': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Function': 0.09; 'subject:files': 0.09; 'subject:script': 0.09; 'violates': 0.09; 'subject:How': 0.10; 'python': 0.11; 'conforming': 0.16; 'filesystem': 0.16; 'finney': 0.16; 'hierarchy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subdirectory': 0.16; 'subject:?)': 0.16; 'subject:program': 0.16; 'subject:where': 0.16; 'files.': 0.16; 'ignore': 0.16; 'looked': 0.18; 'separate': 0.22; 'install': 0.23; 'installation': 0.23; 'header:User- Agent:1': 0.23; 'lets': 0.24; "shouldn't": 0.24; 'decide': 0.24; 'header:X-Complaints-To:1': 0.27; 'installed': 0.27; 'chris': 0.29; 'feature': 0.29; "doesn't": 0.30; 'locations': 0.30; 'specified': 0.30; 'facility': 0.31; 'location,': 0.31; 'wright': 0.31; 'writes:': 0.31; 'this.': 0.32; 'url:python': 0.33; 'subject:the': 0.34; 'subject: (': 0.35; 'common': 0.35; 'there': 0.35; 'described': 0.36; 'subject:data': 0.36; 'url:org': 0.36; 'so,': 0.37; 'operating': 0.37; 'system,': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; "couldn't": 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'today.': 0.61; 'url:3': 0.61; 'simply': 0.61; "you're": 0.61; 'skip:\xe2 10': 0.65; 'christmas': 0.74; 'intending': 0.84; 'subject:find': 0.84; '8bit%:33': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: How to find where data files are installed for my Python program (was: Function for the path of the script?) Date: Sun, 27 Oct 2013 15:28:28 +1100 References: <00704f33-7e7f-4ccf-b28b-69776d2e237d@googlegroups.com> <526C7FEF.7020206@islandtraining.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:n///ZeaAfSE7LYRhBu2bKOGTEqU= 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382848122 news.xs4all.nl 15913 [2001:888:2000:d::a6]:38925 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57714 Chris Angelico writes: > It's very common to want to know what directory you're in - it's a > good way to find data files. That's a naive way to do it (though it's often good enough, for a program only used on one system). For programs intending to be used across many systems, the data files often shouldn't be placed in the same directory as the program. On systems conforming to the Filesystem Hierarchy Standard, it's forbidden: programs go in a platform-specific location , while platform-independent data files go in a separate location . The ‘package_data’ feature of Distutils (originally from Setuptools) doesn't help with this. The specified files are simply installed in a subdirectory of the platform-specific program location, which violates the FHS as described above. So, what facility is there in Python to: * allow the operating system to set separate installation locations for the program versus the data files; and * allow the program to interrogate the operating system for where its data files are installed in a way that lets the programmer ignore the specifics of each operating system, while leaving it up to the system administrator to decide to place data files separate from program files at install time? -- \ “I still have my Christmas Tree. I looked at it today. Sure | `\ enough, I couldn't see any forests.” —Steven Wright | _o__) | Ben Finney