Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > distribute and reference static content in a python package

Reply
Thread Tools

distribute and reference static content in a python package

 
 
Vince Forgetta
Guest
Posts: n/a
 
      02-02-2012
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A new script which creates Python 3.3 venvs with Distribute and pipinstalled in them Vinay Sajip Python 0 01-30-2013 08:09 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
how to distribute python extensions independently of python Travis Python 0 02-12-2009 05:38 PM
Hey, How Do I Distribute my New Completed Python Project? steven@lczmsoft.com Python 3 03-01-2005 12:50 AM
How to properly package/distribute a pure python module? Matt Shomphe Python 3 07-29-2003 09:54 PM



Advertisments