RSS

(root)/python-fedora/scraper : /pavement.py (revision 622)

To get this branch, use:
bzr branch /bzr/python-fedora/scraper
Line Revision Contents
1 458.1.2
try:
2
    # 1.0
3
    from paver.easy import path as paver_path
4
    from paver.easy import sh as paver_sh
5
    from paver.easy import *
6
    import paver.misctasks
7
    from paver import setuputils
8
    setuputils.install_distutils_tasks()
9 458.1.7
    PAVER_VER = '1.0'
10 458.1.2
except ImportError:
11
    # 0.8
12
    from paver.defaults import *
13
    from paver.runtime import path as paver_path
14
    from paver.runtime import sh as paver_sh
15 458.1.7
    PAVER_VER = '0.8'
16 303
17
import sys, os
18 388
import glob
19 303
import paver.doctools
20 458.1.2
from setuptools import find_packages, command
21
22
sys.path.insert(0, str(paver_path.getcwd()))
23 303
24 107.1.5
from fedora.release import *
25
26 296
options(
27
    setup = Bunch(
28
        name=NAME,
29 107.1.5
        version=VERSION,
30
        description=DESCRIPTION,
31
        author=AUTHOR,
32
        author_email=EMAIL,
33
        license=LICENSE,
34 74
        keywords='Fedora Python Modules',
35 107.1.5
        url=URL,
36
        download_url=DOWNLOAD_URL,
37 1
        packages=find_packages(),
38 3
        include_package_data=True,
39 296
        # non-setuptools package.  When everything we care about uses
40
        # python-2.5 distutils we can add these:
41
        #   for bodhi (koji yum)
42 474
        #   pycurl
43
        install_requires=['simplejson'],
44 296
        # And these to extra_require:
45
        #   for widgets: (bugzilla feedparser)
46 558
        extras_require = {
47
            'tg' : ['TurboGears >= 1.0.4', 'SQLAlchemy', 'decorator'],
48
            'wsgi': ['repoze.who', 'Beaker', 'Paste'],
49 515
            },
50 587.1.8
        test_require = ['TurboGears >= 2.0', 'nose', ],
51 1
        entry_points = {
52 6
            'turbogears.identity.provider' : (
53 441
                'jsonfas = fedora.tg.identity.jsonfasprovider1:JsonFasIdentityProvider [tg]',
54 515
                'jsonfas2 = fedora.tg.identity.jsonfasprovider2:JsonFasIdentityProvider [tg]',
55 518
                'sqlobjectcsrf = fedora.tg.identity.soprovidercsrf:SqlObjectCsrfIdentityProvider [tg]'),
56 121.1.1
            'turbogears.visit.manager' : (
57 441
                'jsonfas = fedora.tg.visit.jsonfasvisit1:JsonFasVisitManager [tg]',
58
                'jsonfas2 = fedora.tg.visit.jsonfasvisit2:JsonFasVisitManager [tg]'),
59 588
            # Needed for the test suite
60 587
            'paste.app_factory' : (
61 588
                'main = fedora.wsgi.test.testapp:make_app'),
62
            'paste.app_install' : (
63
                'main = pylons.util:PylonsInstaller'),
64 443
            },
65 458.1.2
        message_extractors = {
66
            'fedora': [('**.py', 'python', None),
67
                ('tg/templates/genshi/**.html', 'genshi', None),],
68
            },
69 443
        classifiers = [
70
            'Development Status :: 4 - Beta',
71
            'Framework :: TurboGears',
72
            'Framework :: Django',
73
            'Intended Audience :: Developers',
74
            'Intended Audience :: System Administrators',
75 525
            'License :: OSI Approved :: GNU Lesser General Public License v2+ (LGPLv2+)',
76 443
            'Programming Language :: Python :: 2.4',
77
            'Topic :: Internet :: WWW/HTTP',
78
            'Topic :: Software Development :: Libraries :: Python Modules',
79
            ],
80 296
        ),
81 533
    minilib=Bunch(
82
        extra_files=['doctools']
83
        ),
84 296
    sphinx=Bunch(
85
        docroot='.',
86
        builddir='build-doc',
87
        sourcedir='doc'
88 303
        ),
89
    pylint=Bunch(
90
        module=['fedora']
91 388
        ),
92
    publish=Bunch(
93
        doc_location='fedorahosted.org:/srv/web/releases/p/y/python-fedora/doc/',
94 396
        tarball_location='fedorahosted.org:/srv/web/releases/p/y/python-fedora/'
95 388
        ),
96 458.1.2
    i18n=Bunch(
97
        builddir='locale',
98
        installdir='/usr/share/locale',
99
        domain='python-fedora',
100
        ),
101 458.1.14
    ### FIXME: These are due to a bug in paver-1.0
102
    # http://code.google.com/p/paver/issues/detail?id=24
103
    sdist=Bunch(),
104 296
    )
105 303
106 388
@task
107
@needs(['html'])
108
def publish_doc():
109 396
    options.order('publish', add_rest=True)
110 388
    command = 'rsync -av build-doc/html/ %s' % (options.doc_location,)
111 458.1.14
    if PAVER_VER == '0.8':
112
        command = [command]
113
    dry(command, paver_sh, command)
114 388
115 396
@task
116
@needs(['sdist'])
117
def publish_tarball():
118
    options.order('publish', add_rest=True)
119
    tarname = '%s-%s.tar.gz' % (options.name, options.version)
120
    command = 'scp dist/%s %s' % (tarname, options.tarball_location)
121 458.1.14
    if PAVER_VER == '0.8':
122
        command = [command]
123
    dry(command, paver_sh, command)
124 396
125
@task
126
@needs(['publish_doc', 'publish_tarball'])
127
def publish():
128
    pass
129
130 458.1.2
try:
131
    import babel.messages.frontend
132
    has_babel = True
133
except ImportError:
134
    has_babel = False
135
136 458.1.14
if has_babel and PAVER_VER != '0.8':
137 458.1.2
    @task
138
    def make_catalogs():
139
        '''Compile all message catalogs for release'''
140
        options.order('i18n', add_rest=True)
141
        for po_file in glob.glob('po/*.po'):
142
            locale, ext = os.path.splitext(os.path.basename(po_file))
143
            build_dir = paver_path(os.path.join(options.builddir, locale,
144
                'LC_MESSAGES'))
145
146
            try:
147 458.1.6
                build_dir.makedirs(mode=0755)
148 458.1.2
            except OSError, e:
149
                # paver < 1.0 raises if directory exists
150
                if e.errno == 17:
151
                    pass
152
                else:
153
                    raise
154 458.1.13
            if 'compile_catalog' in options.keys():
155
                defaults = options.compile_catalog
156 458.1.2
            else:
157
                defaults = Bunch(domain=options.domain,
158
                        directory=options.builddir)
159 458.1.13
                options.compile_catalog = defaults
160 458.1.2
161
            defaults.update({'input-file': po_file, 'locale': locale})
162
            ### FIXME: compile_catalog cannot handle --dry-run on its own
163
            dry('paver compile_catalog -D %(domain)s -d %(directory)s'
164
                    ' -i %(input-file)s --locale %(locale)s' % defaults,
165 458.1.17
                    paver_sh, 'paver compile_catalog -D %(domain)s' \
166
                        ' -d %(directory)s -i %(input-file)s' \
167
                        ' --locale %(locale)s' % defaults)
168
            ### FIXME: Need to get call_task to call this repeatedly
169
            # because options.compile_catalog has changed
170
            #dry('paver compile_catalog -D %(domain)s -d %(directory)s'
171
            #        ' -i %(input-file)s --locale %(locale)s' % defaults,
172
            #        call_task, 'babel.messages.frontend.compile_catalog', options)
173 458.1.2
174 482
#
175
# Backends
176
#
177
178
def _apply_root(args, path):
179
    '''Add the root value to the start of the path'''
180
    if 'root' in args:
181
        if path.startswith('/'):
182
            path = path[1:]
183
        path = paver_path(os.path.join(args['root'], path))
184
    else:
185
        path = paver_path(path)
186
    return path
187
188 458.1.2
def _install_catalogs(args):
189
    '''Install message catalogs in their proper location on the filesystem.
190
191
    Note: To use this with non-default commandline arguments, you must use 
192
    '''
193
    # Rebuild message catalogs
194 458.1.19
    if 'skip_build' not in args and 'skip-build' not in args:
195 458.1.2
        call_task('make_catalogs')
196
197
    options.order('i18n', add_rest=True)
198
    # Setup the install_dir
199
    if 'install_catalogs' in args:
200
        cat_dir = args['install_catalogs']
201
    elif 'install_data' in args:
202
        cat_dir = os.path.join(args['install_data'], 'locale')
203
    else:
204
        cat_dir = options.installdir
205
206 482
    # Setup the install_dir
207
    cat_dir = _apply_root(args, cat_dir)
208 458.1.2
209
    for catalog in paver_path(options.builddir).walkfiles('*.mo'):
210
        locale_dir = catalog.dirname()
211
        path = paver_path('.')
212
        for index, nextpath in enumerate(locale_dir.splitall()):
213
            path = path.joinpath(nextpath)
214
            if paver_path(options.builddir).samefile(path):
215
                install_locale = cat_dir.joinpath(os.path.join(
216
                        *locale_dir.splitall()[index + 1:]))
217
                try:
218 458.1.6
                    install_locale.makedirs(mode=0755)
219 458.1.2
                except OSError, e:
220
                    # paver < 1.0 raises if directory exists
221
                    if e.errno == 17:
222
                        pass
223
                    else:
224
                        raise
225
                install_locale = install_locale.joinpath(catalog.basename())
226
                if install_locale.exists():
227
                    install_locale.remove()
228 458.1.14
                dry('cp %s %s'%  (catalog, install_locale),
229
                        catalog.copy, install_locale)
230
                dry('chmod 0644 %s'%  install_locale,
231
                        install_locale.chmod, 0644)
232 458.1.2
233
@task
234
@cmdopts([('root=', None, 'Base root directory to install into'),
235
    ('install-catalogs=', None, 'directory that locale catalogs go in'),
236
    ('skip-build', None, 'Skip directly to installing'),
237
    ])
238
def install_catalogs():
239
    _install_catalogs(options.install_catalogs)
240
    pass
241
242
@task
243
@needs(['make_catalogs', 'setuptools.command.sdist'])
244
def sdist():
245
    pass
246
247 458.1.14
### FIXME: setuptools.command.install does not respond to --dry-run
248 458.1.7
if PAVER_VER != '0.8':
249
    # Paver 0.8 will have to explicitly install the message catalogs
250 458.1.14
    # As overriding setuptools.command gives errors on paver-0.8
251 458.1.7
    @task
252
    @needs(['setuptools.command.install'])
253
    def install():
254
        '''Override the setuptools install.'''
255
        _install_catalogs(options.install)
256 458.1.2
257 303
#
258
# Generic Tasks
259
#
260
261
try:
262
    from pylint import lint
263
    has_pylint = True
264
except ImportError:
265
    has_pylint = False
266
267
if has_pylint:
268
    @task
269
    def pylint():
270
        '''Check the module you're building with pylint.'''
271
        options.order('pylint', add_rest=True)
272
        pylintopts = options.module
273
        dry('pylint %s' % (" ".join(pylintopts)), lint.Run, pylintopts)
274
275
276 587
@task
277
def test():
278
    sh("nosetests --where=fedora/wsgi/test")

Loggerhead 1.18.1 is a web-based interface for Bazaar branches