2010/08/30: Installing python using distutils, the setup.py method

Installing python code is quite easy using distutils. Here, the code to be installed brings a file setup.py which does all the job. Nevertheless, given the framework, it's essentially declarative. Here is a real example, from wsgitools.


#!/usr/bin/env python

__author__ = "Helmut Grohne <helmut@subdivi.de>"

from distutils.core import setup

setup(name="wsgitools",
      version="0.2.1",
      description="a set of tools working with WSGI (see PEP 333)",
      author="Helmut Grohne",
      author_email="helmut@subdivi.de",
      url="http://subdivi.de/~helmut/wsgitools/",
      platforms = ["any"],
      license="GPL",
      keywords=["wsgi", "pep333", "scgi"],
      classifiers=[
          "Development Status :: 4 - Beta",
          "Environment :: No Input/Output (Daemon)",
          "Environment :: Web Environment",
          "Intended Audience :: Developers",
          "License :: OSI Approved :: GNU General Public License (GPL)",
          "Natural Language :: English",
          "Programming Language :: Python",
          "Topic :: Internet :: WWW/HTTP",
          "Topic :: Internet :: WWW/HTTP :: WSGI",
          "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
          "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
          "Topic :: Internet :: WWW/HTTP :: WSGI :: Server"
      ],
      packages=["wsgitools", "wsgitools.scgi"])
download

With such a framework, a typical configure, build, install would look as follows.


python setup.py config
python setup.py build
python setup.py install -c -O1 --prefix=${PREFIX}

Of course, the FreeBSD portsframework, as do many others, supports this form on installation (see bsd.python.mk). So you just write the following.


USE_PYTHON=     YES
USE_PYDISTUTILS=YES