Taking a quick look through this it looks pretty good! I find that beginners have tons of trouble navigating the slightly tricky waters that is packaging in Python, so more resources is great. One thing I think is missing is to point out not to use setuptools, but to use the less broken, more maintained, drop in replacement distribute ( http://guide.python-distribute.org/ ). That website also has some further informa…
How To Package Your Python Code
11–20 of 36 posts
Re: How To Package Your Python Code
#12Are setuptools suitable for packaging the whole web application (for example in Django) together with html/js/css files, configs for uwsgi and some management scripts? I once tried to do something like this and failed and I had an impression that setuptools are not really intended for such things, but mainly for packaging plain Python modules. Is this a right impression? If yes, what is a good way to package the whol…
Re: How To Package Your Python Code
#13Re: How To Package Your Python Code
#14Are setuptools suitable for packaging the whole web application (for example in Django) together with html/js/css files, configs for uwsgi and some management scripts? I once tried to do something like this and failed and I had an impression that setuptools are not really intended for such things, but mainly for packaging plain Python modules. Is this a right impression? If yes, what is a good way to package the whol…
A good rule of thumb is that if you have defined access points for others to consume your code with (command line tools, Python modules, or Setuptools entry points), it's a good idea to make a Python package like this. Otherwise, skip it.
Re: How To Package Your Python Code
#15Earlier quoted context omitted.
Because the only difference there is neater indentation, which you could do using the keywords method. Additionally, there's no point checking that the script is the main file, as there's only ever one use-case for the script, and that's to call setuptools.
It actually comes in handy if you're using Sphinx and don't want to maintain release and version in conf.py separately from the version in setup.py . There's no reasons why the data should be consumable only by setuptools .
import pkg_resources
pkg_resources.get_distribution("PIL").versionRe: How To Package Your Python Code
#16I've wondered why using a dictionary to initialize setuptools.setup() isn't more advocated in such guides. I understand this is superficial, but imho, this looks much clearer than the author's suggestion [1]: from setuptools import setup kw = { 'name' : 'funniest', 'version' : '0.1', 'description' : 'The funniest joke in the world', 'url' : 'http://github.com/storborg/funniest', 'author' : 'Flying Circus', 'author_em…
Re: How To Package Your Python Code
#17Re: How To Package Your Python Code
#18Earlier quoted context omitted.
It actually comes in handy if you're using Sphinx and don't want to maintain release and version in conf.py separately from the version in setup.py . There's no reasons why the data should be consumable only by setuptools .
I put the version information inside the package, then anything with access to the package (which both setup.py and sphinx have) can access it - quite useful for doing things like checking the version number from the REPL, for instance.
Re: How To Package Your Python Code
#19I've wondered why using a dictionary to initialize setuptools.setup() isn't more advocated in such guides. I understand this is superficial, but imho, this looks much clearer than the author's suggestion [1]: from setuptools import setup kw = { 'name' : 'funniest', 'version' : '0.1', 'description' : 'The funniest joke in the world', 'url' : 'http://github.com/storborg/funniest', 'author' : 'Flying Circus', 'author_em…
Adding spaces to make things line up is proscribed by the Python Style Guide. Which is entirely optional, but many people follow it. http://www.python.org/dev/peps/pep-0008/#pet-peeves