views:

82

answers:

2

I tried to package a django app today. It's a big baby, and with the setup file, I have to manually write all packages and sub packages in the 'package' parameter. Then I have to find a way to copy fixtures, htmls / Css / image files, documentations, etc.

It's a terrible way to work. We are computer scientists, we automatize, doing this makes no sense.

And what when I change my app structure ? I have to rewrite the setup.py.

Is there a better way ? Some tool to automate that ? I can't believe a language than value developer time like Python makes packaging such a chore.

I want to be able to eventually install the app using a simple pip install. I know about build out, but it's not much simpler, and is not pip friendly.

+2  A: 

At the very least if you use setuptools (an alternative to the stdlib's distutils) you get an awesome function called find_packages() which when ran from the package root returns a list of package names in dot-notation suitable for the packages parameter.

Here is an example:

# setup.py

from setuptools import find_packages, setup

setup(
    #...
    packages=find_packages(exclude='tests'),
    #...
)

p.s. Packaging sucks in every language and every system. It sucks no matter how you slice it.

jathanism
+1, thanks for the tips.
e-satis
Do you have such a tip for satic files such as po, html/css and doc that I have to include manually as well ? Maybe setuptools.findall ? If you do, I accept your anwser.
e-satis
You can specify those using the `package_data` (http://docs.python.org/distutils/setupscript.html#installing-package-data) or `data_files`.(http://docs.python.org/distutils/setupscript.html#installing-additional-files) parameters. For the example, if `data_files` is set to `[('share/mypackage', ['test.html'])]`, upon installation `test.html` will be copied into `/usr/share/mypackage` (assuming your prefix is `/usr/share`).
jathanism
A: 

I think the tool you are looking for is Buildout. There lots of places where you can learn more about it, from SlideShare to Pycon videos.

Other similar or related tools which you might want to check out include virtualenv, Fabric, and PIP.

ewall
Can you pip install something packaged with buildout ? I don't want to provide a package that need more that a pip install in a virtualenv.
e-satis
Searched. Yes you can. But my, buildout is everything but easy to use. It's huge, with spare documentation and based on text file instead of python files.
e-satis
I can't disagree with your description, I think you're spot on. I just don't know what else to recommend that fits any better :(
ewall