<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Fischer dot Name &#187; installation</title>
	<atom:link href="http://www.davidfischer.name/tag/installation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidfischer.name</link>
	<description>Some Things to Some People</description>
	<lastBuildDate>Thu, 15 Jul 2010 21:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Why You Should Be Using Pip and Virtualenv</title>
		<link>http://www.davidfischer.name/2010/04/why-you-should-be-using-pip-and-virtualenv/</link>
		<comments>http://www.davidfischer.name/2010/04/why-you-should-be-using-pip-and-virtualenv/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 07:00:35 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[virtualenv]]></category>

		<guid isPermaLink="false">http://www.davidfischer.name/?p=467</guid>
		<description><![CDATA[In a previous post, I]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://www.davidfischer.name/2010/01/extending-distutils-for-repeatable-builds/">previous post</a>, I promised to write about <a href="http://pip.openplans.org/">Pip</a> and <a href="http://virtualenv.openplans.org/">Virtualenv</a> and I&#8217;m now finally making good. Others have <a href="http://www.b-list.org/weblog/2008/dec/15/pip/">done</a> this <a href="http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/">before</a>, but I think I have a little to add. If you develop a Python module and you don&#8217;t test it with virtualenv, don&#8217;t make your next release until you do.</p>
<h5>Configuring the environment</h5>
<p>Virtualenv creates a Python environment that is segregated from your system wide Python installation.  In this way, you can test your module without any external packages mucking up the result, add different versions of dependency packages and generally verify the exact set of requirements for your package.</p>
<p>To create the virtual environment:</p>
<pre>% virtualenv --no-site-packages testarea</pre>
<p>This creates a directory <span style="font-family: monospace">testarea/</span> that contains directories for installing modules and a Python executable. Using the virtual environment:</p>
<pre>% cd testarea
% source bin/activate</pre>
<p>Sourcing activate will set environment variables so that only modules installed under <span style="font-family: monospace">testarea/</span> are used. After setting up the environment, any desired packages can be installed (from <a href="http://pypi.python.org">pypi</a>):</p>
<pre>(testarea) % pip install rpc4django</pre>
<p>Packages can also be uninstalled, specific versions can be installed or packages can be installed from the file system, URLs or directly from source control:</p>
<pre>(testarea) % pip uninstall rpc4django
(testarea) % pip install rpc4django==0.1.6</pre>
<p>Pip is worth using over easy_install for its uninstall capabilities alone, but I should mention that pip is actively maintained while setuptools is mostly dead.</p>
<p>When you&#8217;re done with the virtual environment, simply deactivate it:</p>
<pre>(testarea) % deactivate</pre>
<h5>Do it for the tests</h5>
<p><a href="http://www.davidfischer.name/wp-content/uploads/2010/04/virtualenv_testing.png" rel="lightbox[467]"><img src="/wp-content/uploads/2010/04/virtualenv_testing-300x229.png" alt="Testing with virtualenv" title="Testing with virtualenv and pip" width="300" height="229" style="border: 1px solid black; margin: 5px; width: 300px; float: right;" /></a><br />
While the segregated environment that virtualenv provides is extremely well suited to getting the correct environment up and running, it is just as well suited to testing your application under a variety of different package configurations. With pip and virtualenv, testing your application under three different versions of Django is a snap and it doesn&#8217;t affect your system environment in the slightest. </p>
<h5>Dependencies made easy</h5>
<p>My favorite feature of pip is the ability to create a requirements file based on a set of packages installed in your virtual environment (or your global site-packages). Creating a requirements file can be done automatically using the <span style="font-family: monospace">freeze</span> command for pip:</p>
<pre>(testarea) % pip freeze > requirements.txt
(testarea) % more requirements.txt
Django==1.1.1
rpc4django==0.1.7
wsgiref==0.1.2</pre>
<p>Wsgiref will always appear in pip&#8217;s output. It is a <a href="http://docs.python.org/library/wsgiref.html">standard library</a> package that includes <a href="http://guide.python-distribute.org/installation.html#listing-installed-packages">package metadata</a>. The requirements file is used as follows:</p>
<pre>% pip install -r requirements.txt</pre>
<p>The requirements file can be version controlled both to aid in installation and to capture the exact versions of your dependencies directly where they are used rather than after the fact in documentation that can easily become out of date. The requirements file can be used to rebuild a virtual environment or to deploy a virtual environment into the machine&#8217;s site-packages. Pip and virtualenv are exceptionally easy to use and there&#8217;s really no excuse for a Python packager not to use them. </p>
<p><strong>Note:</strong> I&#8217;m working on a fairly large sized application for work. When it is finished, I will release a post-mortem that will also function as an update to my post about <a href="http://www.davidfischer.name/2009/07/packaging-and-sharing-django-applications/">packaging and distributing</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidfischer.name/2010/04/why-you-should-be-using-pip-and-virtualenv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Distutils for Repeatable Builds</title>
		<link>http://www.davidfischer.name/2010/01/extending-distutils-for-repeatable-builds/</link>
		<comments>http://www.davidfischer.name/2010/01/extending-distutils-for-repeatable-builds/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 07:28:11 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[distutils]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[pypi]]></category>

		<guid isPermaLink="false">http://www.davidfischer.name/?p=373</guid>
		<description><![CDATA[Distutils is Python&#8217;s built-in mechanism]]></description>
			<content:encoded><![CDATA[<p><a href="http://docs.python.org/distutils/index.html">Distutils</a> is Python&#8217;s built-in mechanism for packaging and installing Python modules. It is very convenient for packaging up your source code, scripts and other files and creating a distribution to be uploaded to <a href="http://pypi.python.org/pypi">pypi</a> as I&#8217;ve mentioned <a href="http://www.davidfischer.name/2009/07/packaging-and-sharing-django-applications/">before</a>. Distutils was <a href="http://www.timecastle.net/static/1-python-distutils.pdf">discussed</a> (pdf) at PyCon last year and it looks like there are efforts <a href="http://tarekziade.wordpress.com/2010/01/07/possible-new-features-for-distutils-2-7/">afoot</a> to improve it to add some much needed features like unittesting and <a href="http://www.python.org/dev/peps/pep-0390/">metadata</a>. Add-on packages like <a href="http://pip.openplans.org/">pip</a> add additional features like uninstallation and dependency management but nothing guarantees that your users have it. Although Python&#8217;s packaging and distribution model beats PHP&#8217;s hands down, there is still a lot of room for improvement to make it seamless.</p>
<h5>Release management</h5>
<p>In essence, these issues and enhancements boil down to making release management easier. When releasing your package, you want to make sure that it contains all the appropriate files, is tested and can be installed easily. Distutils helps with the installation, pip with the dependencies and <a href="http://virtualenv.openplans.org/">virtualenv</a> (a topic for a later post) helps a lot with testing package interactions. But what about unittests? What about cleaning up after setup.py? What about generating documentation or other files?</p>
<h5>Extending distutils</h5>
<p>Until all these features get put into distutils, you have to <a href="http://docs.python.org/distutils/extending.html">extend</a> it yourself in <span style="font-family:monospace">setup.py</span>. Fortunately, this is not very complicated and can buy you some reliability in your build process. Adding a command like <span style="font-family:monospace">python setup.py test</span> is pretty trivial:</p>
<pre><code class="python">from distutils.core import setup
from unittest import TextTestRunner, TestLoader
import mymodule.tests

cmdclasses = dict()

class TestCommand(Command):
    """Runs the unit tests for mymodule"""

    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        loader = TestLoader()
        t = TextTestRunner()
        t.run(loader.loadTestsFromModule(mymodule.tests))

# 'test' is the parameter as it gets added to setup.py
cmdclasses['test'] = TestCommand

setup(cmdclass = cmdclasses
#...
)</code></pre>
<p>The same sort of functionality could be used to verify any prerequisites not already checked by distutils or pip, generate documentation without external dependencies like <a href="http://code.djangoproject.com/browser/django/trunk/docs/Makefile">Make</a> (although Django supports Python 2.3 before this functionality was available) or to create a uniform way to take source control diffs and submit patches. Executing these commands from one place makes the whole process more consistent and easy to understood. Hopefully the new enhancements to distutils will make the process even better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidfischer.name/2010/01/extending-distutils-for-repeatable-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying Django Powered Web Applications</title>
		<link>http://www.davidfischer.name/2009/06/deploying-django-powered-web-applications/</link>
		<comments>http://www.davidfischer.name/2009/06/deploying-django-powered-web-applications/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 17:35:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[ellington]]></category>
		<category><![CDATA[installation]]></category>

		<guid isPermaLink="false">http://www.davidfischer.name/?p=48</guid>
		<description><![CDATA[Terminology Firstly, there&#8217;s a little]]></description>
			<content:encoded><![CDATA[<h3>Terminology</h3>
<p>Firstly, there&#8217;s a little problem of terminology to take care of. What many people call a web application, Django calls a &#8220;project&#8221;. Instead, the Django team uses the term &#8220;application&#8221; to describe a web application component that can be deployed into one of many projects. To describe it in the wordpress paradigm, wordpress could be a Django project (if it weren&#8217;t written in php) but the blogging component, the tagging component and the themes manager might all be separate Django applications.</p>
<p>This distinction really pushes the concept of re-using components. For example, once some one were to write a tagging Django application, the same app could be deployed for photo tagging, blog tagging and other types of content management. These applications are supposed to be completely contained and include their seed data (fixtures), database models, and templates.</p>
<p>The issue and what brings me to the main part of my post is what to do with the media? Should an application include its own images, css, javascript? What&#8217;s the best way to deploy them in a convenient way for being served?</p>
<h3>Deployment</h3>
<p>Packaging python modules is a relatively trivial task and there is a well defined approach for it: <a href="http://docs.python.org/distutils/">distutils</a>. This creates a more or less standard installer that allows anyone to install your package with a single command. From there, it can be put into the <a href="http://pypi.python.org/pypi">python package index</a> and <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a> can install your python package (and dependency packages) with a single command. This works great for python packages like Django and BeautifulSoup, but how would it work for a whole web application? It made me wonder how Ellington, the flagship Django product, does it.</p>
<p>When distributing a python module, it makes sense to support as many platforms and configurations as possible. However, when deploying a full web application into a production environment, it makes sense to restrict your platform to what is tried and true. Ellington&#8217;s <a href="http://ellingtoncms.com/">website</a>, for example states:</p>
<blockquote><p>Ellington takes advantage of the most secure and flexible open-source technology available: Apache for web serving, Python for programming, PostgreSQL for data, all optimized to work together on a stable, high-performance Linux platform.</p></blockquote>
<p>Ellington isn&#8217;t intended to run on a wide variety of platforms even though it probably could. It is meant to run a production grade newspaper and therefore they specify its exact dependencies &#8212; probably the specific versions of apache, postgres, python and even linux!</p>
<p>So what have I learned about deployment and what do I do with all the media? After browsing django-users and the blogosphere, sticking with distutils is a great idea.  I think that packaging each separate Django application is good idea. Each package is completely self contained and includes its media, templates, and code. In addition, the project settings should be <a href="http://www.b-list.org/weblog/2006/sep/10/django-tips-laying-out-application/">minimal</a> and possibly contained in another easily deployed python module controlled by distutils. In terms of fitting the whole thing together and deploying end to end, this is where the native package manager comes into play. This is the best way to manage both python and external dependencies. Rpm, msi or deb installers could fetch all the appropriate python modules (your Django applications), install the right version of your database and web server, sync your database, create the symbolic links to your media and even fill out your basic settings. For larger installations that require the database to be split from the python code and from the static media, this process still makes sense with few changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidfischer.name/2009/06/deploying-django-powered-web-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
