Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python': 0.08; 'problem:': 0.09; '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; 'received:209.85.161.174': 0.16; 'received:mail- gx0-f174.google.com': 0.16; 'subject:package': 0.16; 'wrote:': 0.16; 'advance': 0.17; '(i.e.': 0.17; 'help.': 0.18; 'appropriate': 0.22; 'assume': 0.22; 'header:In-Reply-To:1': 0.22; '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; 'thu,': 0.32; 'modules': 0.32; 'thanks': 0.32; 'named': 0.33; 'to:addr:python-list': 0.33; 'there': 0.33; 'hi,': 0.34; 'received:209.85.161': 0.34; 'copied': 0.34; 'identical': 0.34; '...': 0.35; 'install': 0.35; 'url:python': 0.36; 'link,': 0.36; 'reference': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'created': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'received:209': 0.39; 'doing': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'more': 0.61; 'share': 0.66; 'content,': 0.67; 'images,': 0.67; '-0500,': 0.84; '13:42': 0.84; 'so:': 0.84; 'subject:content': 0.84; 'fonts': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:subject:from:to:date:in-reply-to:references:content-type :x-mailer:content-transfer-encoding:mime-version; bh=cump+1E4fIbi/mj/wP4Ob+rJ5L8kzgN0nosDXwjGbeE=; b=wHq345NMACRSLRY7pm/rLSUKlDHuVVOl6goXVYXH67g+INVI6Jzwl3E9yft9DQHWmb r5gPIz+WvZ6/A2yd4ui7LDaafK4PMCcJFPAa3uC7k1secx8KxPNj9USHeVCE+DZvxCqw OvK+5gLhlIGd9548j2YZdRpztEdb/sbP/LToA= Subject: Re: distribute and reference static content in a python package From: Vince Forgetta To: python-list@python.org Date: Thu, 02 Feb 2012 14:09:26 -0500 In-Reply-To: <1328208164.15687.17.camel@muon> References: <1328208164.15687.17.camel@muon> 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-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328209775 news.xs4all.nl 6964 [2001:888:2000:d::a6]:40470 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19807 I assume this is an appropriate solution to my problem: http://docs.python.org/distutils/setupscript.html#installing-additional-files On Thu, 2012-02-02 at 13:42 -0500, Vince Forgetta wrote: > 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