[python-uk] Suggestions / best practices for deployment
Nick Murdoch
nick at nivan.net
Wed May 15 12:38:52 CEST 2013
A very quick rundown of my process:
* Custom script to build and send to a packages server:
- deleting things like Cythoned files and generated .so files which setup.py likes to try to avoid recompiling even if you want it to.
- setup.py build_ext
- setup.py sdist -d dist.$TEMP
- scp dist.$TEMP/*.tar.gz $packageserver:/path/to/packages
* Packages server is basically a www directory with a frilly directory listing for the packages sent to it. A regular directory listing is fine. This is for easy_install/pip's find_links setting.
* I deploy things in virtualenvs on Debian/Ubuntu because of the requirement for different versions of packages (CherryPy 2/3 springs to mind) and I don't like setuptools' way of handling multiple versions. However, virtualenv has a big problem with point upgrades to python, so it requires some extra time each time python gets upgraded. I tend to create a dedicated user that owns the virtualenv and that the app will run as.
* Currently using easy_install but going to bite the bullet and move to pip at some point...
- easy_install -UZf http://$packageserver/mypackages/ MyPackage
- add a dud -i (before MyPackage) to avoid polling pypi which can be pointless and (very) slow.
* Restart/reload apache (or your service if not using mod_python or mod_wsgi)
I much prefer mod_wsgi-compatible frameworks (I think all of them now, but I'm stuck with some old TurboGears 1.x projects!) since reloading apache takes care of everything. My main gripe with mod_wsgi is that it's a bit fiddly to write the deployment.wsgi if you're not familiar with it or your framework doesn't provide a way of generating one.
Hope that helps,
Nick
On Wed, May 15, 2013 at 10:57:16AM +0100, Harry Percival wrote:
> Dear UK Python chums,
>
> some of you probably know I'm writing a book about TDD for O'Reilly. I'm
> looking for some help with the (first) chapter on deployment.
>
> http://www.obeythetestinggoat.com/what-to-say-about-deployment.html
>
> What do you use for deployment? Do you have any kind of automated scripts?
> How do you manage virtualenvs, the database, apache/uwsgi config... What do
> you think might work as a sort of "best practice lite" for a simple site
> for beginners? (django, sqlite database, static files)
>
> --
> ------------------------------
> Harry J.W. Percival
> ------------------------------
> Twitter: @hjwp
> Mobile: +44 (0) 78877 02511
> Skype: harry.percival
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> http://mail.python.org/mailman/listinfo/python-uk
More information about the python-uk
mailing list