~cr3/launchpad-results/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python
#
# Copyright 2010 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

import os
import re

from glob import glob
from os import path

from distutils.command.install_data import install_data

import ez_setup
ez_setup.use_setuptools()

from setuptools import (
    setup,
    find_packages,
    )


LPX_RESULTS_CONFIG = os.environ.get("LPX_RESULTS_CONFIG", "default")


class custom_install_data(install_data, object):

    def finalize_options(self):
        """Add wildcard support for filenames."""
        super(custom_install_data, self).finalize_options()

        for f in self.data_files:
            if type(f) != str:
                files = f[1]
                i = 0
                while i < len(files):
                    if "*" in files[i]:
                        for e in glob(files[i]):
                            files.append(e)
                        files.pop(i)
                        i -= 1
                    i += 1


def changelog_version(changelog="debian/changelog"):
    """
    Return the latest version taken from the debian changelog file
    for use in `version` in a distutils `setup.py` file.

    :param changelog: Path to changelog file.
    """
    version = "dev"
    if path.exists(changelog):
        file = open(changelog)
        try:
            head = file.readline()
        finally:
            file.close()

        match = re.compile(".*\((.*)\).*").match(head)
        if match:
            version = match.group(1)

    return version


SETUP_NAME = "lpx.results"
SETUP_CONF_DIR = path.join("..", "etc", SETUP_NAME)
SETUP_DATA_DIR = path.join("share", SETUP_NAME)
SETUP_VERSION = changelog_version()


setup(
    name=SETUP_NAME,
    version=SETUP_VERSION,
    namespace_packages=["lpx"],
    include_package_data=True,
    packages=find_packages("lib"),
    package_dir={
        "": "lib",
    },
    data_files=[
        (SETUP_CONF_DIR, [
            path.join("configs", LPX_RESULTS_CONFIG, "*.conf"),
            ]),
        (path.join(SETUP_DATA_DIR, "scripts"), [
            "scripts/*",
            ]),
        (path.join(SETUP_DATA_DIR, "templates"), [
            "templates/*.html",
            ]),
        (path.join(SETUP_DATA_DIR, "templates", "apidoc"), [
            "templates/apidoc/*.html",
            "templates/apidoc/*.xml",
            ]),
        (path.join(SETUP_DATA_DIR, "templates", "errors"), [
            "templates/errors/*.html",
            ]),
        (path.join(SETUP_DATA_DIR, "templates", "gm"), [
            "templates/gm/*.js",
            ]),
        (path.join(SETUP_DATA_DIR, "templates", "person"), [
            "templates/person/*.html",
            ]),
        (path.join(SETUP_DATA_DIR, "templates", "project"), [
            "templates/project/*.html",
            ]),
        (path.join(SETUP_DATA_DIR, "static"), [
            "static/*.txt",
            ]),
        (path.join(SETUP_DATA_DIR, "static", "build"), [
            "static/build/*.css",
            "static/build/*.js",
            "static/build/icon-sprites*",
            ]),
        (path.join(SETUP_DATA_DIR, "static", "launchpad"), [
            "static/launchpad/favicon.ico",
            ]),
        (path.join(SETUP_DATA_DIR, "static", "launchpad", "images"), [
            "static/launchpad/images/*.png",
            ]),
        ],
    cmdclass = {
        "install_data": custom_install_data,
        },

    # Setuptools metadata.
    zip_safe=False,
    install_requires=[
        "storm",
        "cssutils",
        "django",
        "httplib2",
        "python-openid",
        "lazr.enum",
        "lazr.restful",
        "lazr.restfulclient",
        "lazr.uri",
        "lazr-js",
        "oauth",
        "RestrictedPython",
        "setuptools",
        "simplejson",
        "wadllib",
        "zope.component",
        "zope.interface",
        "zope.schema",
        "zope.security",
        "zope.testing",
        ],
    package_data={
        "": [
            "*.xsl",
            "*.zcml",
            ],
        },

    # PyPI metadta.
    author="Marc Tardif",
    author_email="marc.tardif@canonical.com",
    license="Affero GPL v3",
    url="https://launchpad.net/launchpad-results",
    download_url="https://launchpad.net/launchpad-results/+download",
    )