Source

postfacto / setup.py

"""Installs PostFacto using distutils

Run:
    python setup.py install

to install this package.
"""

from distutils.core import setup
from distutils.command.install import INSTALL_SCHEMES
import sys
import os
import shutil

required_python_version = '2.3'

###############################################################################
# arguments for the setup command
###############################################################################
name = "PostFacto"
version = "1.0alpha"
desc = "Version control for Postgresql"
long_desc = "Post Facto brings Subversion-style version control to PostgreSQL"
classifiers=[
    "Development Status :: 3 - Alpha",
    "Environment :: Console",
    "Intended Audience :: Developers",
    "Intended Audience :: System Administrators",
    "License :: Freely Distributable",
    "Operating System :: OS Independent",
    "Programming Language :: Python",
    "Topic :: Database",
    "Topic :: Software Development :: Version Control",
]
author="Post Facto Team"
author_email="team@post-facto.org"
url="http://www.post-facto.org"
cp_license="BSD"
packages=[
    "postfacto", "postfacto.test"
]
download_url="http://download.post-facto.org/postfacto/1.0alpha/"
data_files=[
    ('postfacto', ['postfacto/LICENSE.txt',
                  ]),
]
###############################################################################
# end arguments for setup
###############################################################################

def fix_data_files(data_files):
    """
    bdist_wininst seems to have a bug about where it installs data files.
    I found a fix the django team used to work around the problem at
    http://code.djangoproject.com/changeset/8313 .  This function
    re-implements that solution.
    Also see http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
    for more info.
    """
    def fix_dest_path(path):
        return '\\PURELIB\\%(path)s' % vars()
    
    if not 'bdist_wininst' in sys.argv: return
    
    data_files[:] = [
        (fix_dest_path(path), files)
        for path, files in data_files]
fix_data_files(data_files)

def main():
    if sys.version < required_python_version:
        s = "I'm sorry, but %s %s requires Python %s or later."
        print s % (name, version, required_python_version)
        sys.exit(1)
    # set default location for "data_files" to
    # platform specific "site-packages" location
    for scheme in INSTALL_SCHEMES.values():
        scheme['data'] = scheme['purelib']
    
    dist = setup(
        name=name,
        version=version,
        description=desc,
        long_description=long_desc,
        classifiers=classifiers,
        author=author,
        author_email=author_email,
        url=url,
        license=cp_license,
        packages=packages,
        download_url=download_url,
        data_files=data_files,
        scripts=[os.path.join("postfacto", "pf.py")],
    )


if __name__ == "__main__":
    main()