packaging a python project and associated graphics files

Discussion in 'Python' started by Rajarshi Guha, Oct 3, 2005.

  1. 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,
    Rajarshi Guha, Oct 3, 2005
    #1
    1. Advertising

  2. Rajarshi Guha

    Mike Meyer Guest

    Rajarshi Guha <> writes:

    > 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
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Oct 3, 2005
    #2
    1. Advertising

  3. Rajarshi Guha

    Robert Kern Guest

    Rajarshi Guha wrote:
    > 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


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
    Robert Kern, Oct 4, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tina
    Replies:
    1
    Views:
    303
    Ken Dopierala Jr.
    Oct 31, 2004
  2. Replies:
    1
    Views:
    354
    Muhammad Naveed Yaseen
    Mar 10, 2007
  3. Tina

    packaging a project into a component

    Tina, Oct 31, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    122
  4. Tina

    Packaging a project into a component

    Tina, Oct 31, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    104
  5. Nicholas Cole

    Packaging a private project

    Nicholas Cole, Dec 16, 2013, in forum: Python
    Replies:
    1
    Views:
    73
    Thomas Heller
    Dec 17, 2013
Loading...

Share This Page