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


Groups > comp.lang.python > #53818

Installing resource data files and finding them

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'base.': 0.05; '(using': 0.07; 'distutils': 0.07; 'purpose.': 0.07; 'think,': 0.07; 'cc:addr:googlegroups.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'similar,': 0.09; 'subject:files': 0.09; 'violates': 0.09; 'python': 0.11; 'filesystem': 0.16; 'finney': 0.16; 'hard-code': 0.16; 'hierarchy': 0.16; 'modules,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'run-time.': 0.16; 'thereby': 0.16; 'files.': 0.16; 'appropriate': 0.16; 'code.': 0.18; 'library': 0.18; 'all,': 0.19; "python's": 0.19; 'appears': 0.22; 'code,': 0.22; 'python?': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'people,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:X-Complaints-To:1': 0.27; 'installed': 0.27; 'correct': 0.29; "doesn't": 0.30; 'specified': 0.30; 'code': 0.31; 'assumes': 0.31; 'enforce': 0.31; 'libraries': 0.31; 'option.': 0.31; 'allows': 0.31; 'option': 0.32; 'run': 0.32; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'belong': 0.36; 'subject:data': 0.36; 'url:org': 0.36; 'should': 0.36; 'application': 0.37; 'skip:- 20': 0.37; 'system,': 0.38; 'ben': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'resource': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; '8bit%:47': 0.60; 'new': 0.61; 'url:3': 0.61; 'such': 0.63; 'different': 0.65; 'skip:\xe2 10': 0.65; '8bit%:43': 0.74; 'discover': 0.82; 'discovered': 0.83; 'alongside': 0.84; 'sony': 0.84; 'upstream': 0.84; '8bit%:33': 0.91; 'skip:\xe2 30': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Installing resource data files and finding them
Followup-To gmane.comp.python.packaging
Date Sat, 07 Sep 2013 16:03:26 +1000
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 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:A9UMgfLK+RyYVFAqZiUqDRyYHo0=
Cc the-fellowship-of-the-packaging@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.140.1378533833.5461.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378533833 news.xs4all.nl 15903 [2001:888:2000:d::a6]:44671
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53818

Followups directed to: gmane.comp.python.packaging

Show key headers only | View raw


Howdy all,

How do I package a Python application with its resource files separate
from the Python modules, such that the resource files can be discovered
by the Python code when it runs?


I am working on an existing Python application code base. The
application currently assumes that its resource files will be installed
to the same location as the python modules (using the Distutils
‘package_data’ option).

But this violates the Filesystem Hierarchy Standard used on GNU+Linux
<URL:http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html>. By that
standard, platform-independent resources belong in ‘/usr/share/…’, while
platform-dependent code libraries belong in ‘/usr/lib/…’.

Currently the upstream Python code uses ‘os.path.dirname(__file__)’ and
similar, to discover the location of the resource files. It thereby
assumes that the resource files are installed to the same location as
the Python code. The Distutils ‘package_data’ option appears to enforce
this, and I can't find any way for the files to be installed to a
different place using that option.

The Distutils ‘data_files’ option doesn't seem suitable for this
purpose. It allows the location to be specified (using ‘python
./setup.py --data-files=FOODIR’),, but there appears to be no way for
the application to know what location was specified later.

I will need to change both the build configuration and the application
code, so that instead it allows the resource files to be installed to an
appropriate location on the target system, and seeks the data files in
the correct location when run later.


Of course, the code should continue to work on systems that don't
conform to the FHS and allow resource data files to live alongside
platform code, so I can't just hard-code the new location.

I had hoped to use Python's standard library (Distutils? Distribute?
Something else?) to access the resources once installed to the correct
location. This needs to allow the choice of location to be made at
install-time, but discovered by the application at run-time.

Is there a way to do that, or is this a problem still unsolved in
Python?

-- 
 \        “Most people, I think, don't even know what a rootkit is, so |
  `\     why should they care about it?” —Thomas Hesse, Sony BMG, 2006 |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Installing resource data files and finding them Ben Finney <ben+python@benfinney.id.au> - 2013-09-07 16:03 +1000

csiph-web