packaging a python project and associated graphics files

R

Rajarshi Guha

Hi, I've been trying to package a python project and I'm a little confused
about how I distribute some PNG's that the program uses as icons.

Using distutils I can set the data_files argument of setup() and get my
data files located in, say, /usr/local/mydata.

However when I write my code, it would seem that I have to hardcode the
above path. But this would mean that while working on the code I would
need to have it 'installed' on my system (or else actually make the above
directory).

This seems a little unwieldy. How do people handle this situation?

Thanks,
 
M

Mike Meyer

Rajarshi Guha said:
Hi, I've been trying to package a python project and I'm a little confused
about how I distribute some PNG's that the program uses as icons.

Using distutils I can set the data_files argument of setup() and get my
data files located in, say, /usr/local/mydata.

However when I write my code, it would seem that I have to hardcode the
above path. But this would mean that while working on the code I would
need to have it 'installed' on my system (or else actually make the above
directory).

This seems a little unwieldy. How do people handle this situation?

With symlinks from the installed location to the source tree.

<mike
 
R

Robert Kern

Rajarshi said:
Hi, I've been trying to package a python project and I'm a little confused
about how I distribute some PNG's that the program uses as icons.

Using distutils I can set the data_files argument of setup() and get my
data files located in, say, /usr/local/mydata.

However when I write my code, it would seem that I have to hardcode the
above path. But this would mean that while working on the code I would
need to have it 'installed' on my system (or else actually make the above
directory).

This seems a little unwieldy. How do people handle this situation?

I recommend packaging the files in the package itself. With Python 2.4,
you can make distutils do this with the package_data argument to
setup(). You can find your files by looking at the __file__ variable in
any of your modules.

Also, take a look at PythonEggs and pkg_resources.

http://peak.telecommunity.com/DevCenter/PythonEggs
http://peak.telecommunity.com/DevCenter/PkgResources

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top