Re:How To Package Your Python Code
by michaelhoffman on Sunday November 18, 2012 @06:56PM
(#4802157)
Adding spaces to make things line up is proscribed by the Python Style Guide. Which is entirely optional, but many people follow it.
I'm so glad Go removes these sort of nitpicky style problems with gofmt. At first I was bothered by how gofmt makes things line up like this, but now I prefer no style guide and a tool that formats stuff for you.
Python has a tool (aptly named "pep8") which provides similar functionality. It doesn't make the changes for you, but it's very specific about what you need to fix to comply with the style guide.
Autopep8 makes the changes for you.
Re:How To Package Your Python Code
by borntyping on Sunday November 18, 2012 @05:38PM
(#4801954)
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 .
You can use pkg_resources which comes with setuptools to look up the version number of your package in setup.py:
import pkg_resources
pkg_resources.get_distribution("PIL").version
Re:How To Package Your Python Code
by borntyping on Sunday November 18, 2012 @05:51PM
(#4801981)
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.
[1]: http://www.scotttorborg.com/python-packaging/minimal.html#cr...
[2]: https://github.com/gvalkov/harstats-graphite/blob/master/set...
[3]: https://github.com/gvalkov/jenkins-autojobs/blob/master/setu...
[4]: https://github.com/gvalkov/python-evdev/blob/master/setup.py