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


Groups > comp.lang.python > #19806

distribute and reference static content in a python package

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <vince.forgetta@mail.mcgill.ca>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python': 0.08; 'setup.py': 0.09; 'subject:reference': 0.09; 'subject:python': 0.10; 'exception': 0.12; 'package.': 0.12; 'library': 0.13; '"python': 0.15; 'skip:" 40': 0.15; 'docs/': 0.16; 'example).': 0.16; 'pythonic': 0.16; 'subject:package': 0.16; 'advance': 0.17; '(i.e.': 0.17; 'help.': 0.18; 'css': 0.23; 'static': 0.24; 'structure': 0.25; '(in': 0.26; 'module': 0.26; 'html,': 0.28; '(e.g.': 0.30; 'specified': 0.30; 'modules': 0.32; 'thanks': 0.32; 'named': 0.33; 'to:addr:python-list': 0.33; 'there': 0.33; 'hi,': 0.34; 'copied': 0.34; 'identical': 0.34; '...': 0.35; 'install': 0.35; 'link,': 0.36; 'reference': 0.37; 'but': 0.37; 'using': 0.37; 'created': 0.38; 'url:org': 0.39; 'received:ca': 0.39; 'doing': 0.39; 'to:addr:python.org': 0.40; 'more': 0.61; 'share': 0.66; 'content,': 0.67; 'images,': 0.67; 'so:': 0.84; 'subject:content': 0.84; 'fonts': 0.91
Subject distribute and reference static content in a python package
From Vince Forgetta <vincenzo.forgetta@mail.mcgill.ca>
To <python-list@python.org>
Date Thu, 2 Feb 2012 13:42:44 -0500
Content-Type text/plain; charset="UTF-8"
X-Mailer Evolution 3.2.2 (3.2.2-1.fc16)
Content-Transfer-Encoding 7bit
MIME-Version 1.0
X-PMX-Version 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.24.143620
X-McGill-WhereFrom Internal
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5371.1328208556.27778.python-list@python.org> (permalink)
Lines 56
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328208556 news.xs4all.nl 6915 [2001:888:2000:d::a6]:41883
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19806

Show key headers only | View raw


Hi,

I have developed a python program that contains multiple python modules
and static content in the form of fonts (pil,pbm and tff files),  html,
images, css and javascript.

I want to share the program with others as a python package. I have
followed the instructions at 

http://guide.python-distribute.org/creation.html

I have created an identical structure (apart from directory naming) as
specified in the link, with the exception of a "static" directory within
the module directory (towelstuff in the example). Within this directory
are sub-directories named "css", "html", "images", "fonts" and "js".

TowelStuff/
    bin/
        run.py
    CHANGES.txt
    docs/
    LICENSE.txt
    MANIFEST.in
    README.txt
    setup.py
    towelstuff/
        __init__.py
        module1.py
        module2.py
        static/
            images/someimage.png
            css/
            html/
            js/
            fonts/


When the user install the program using "python setup.py install", the
modules (in towelstuff) are copied to the common python library path
(e.g. /usr/lib/python2.7/site-packages/), but the static content is not
(understandably).

What is common method to distribute static content, and how to I make
reference to it in my python program?

For programs in TowelStuff/bin (i.e. run.py), I currently make reference
to the static content like so:

sys.path[0] + "../towelstuff/static/images/someimage.png"

I am sure there is a more pythonic way of doing this ...

Thanks in advance for the help.

Vince

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


Thread

distribute and reference static content in a python package Vince Forgetta <vincenzo.forgetta@mail.mcgill.ca> - 2012-02-02 13:42 -0500

csiph-web