RSS

(root)/packagedb/0.5.x : /pavement.py (revision 615)

To get this branch, use:
bzr branch /bzr/packagedb/0.5.x
Line Revision Contents
1 48.2.225
#!/usr/bin/python -tt
2 604
3 48.2.206
import pkg_resources
4
5 48.2.225
from paver.easy import path as paver_path
6
from paver.easy import sh as paver_sh
7
from paver.easy import *
8
import paver.misctasks
9
from paver import setuputils
10
setuputils.install_distutils_tasks()
11 408.1.29
12
import sys, os
13 48.2.212
import re
14 408.1.29
import glob
15
import paver.doctools
16 48.2.206
from setuptools import find_packages, command
17 48.2.225
from turbogears.finddata import find_package_data
18 48.2.206
19
sys.path.insert(0, str(paver_path.getcwd()))
20 408.1.29
21
from pkgdb.release import *
22
23
options(
24
    setup = Bunch(
25
        name=NAME,
26
        version=VERSION,
27
        description=DESCRIPTION,
28
        author=AUTHOR,
29
        author_email=EMAIL,
30
        url=URL,
31
        download_url=DOWNLOAD_URL,
32
        license=LICENSE,
33
        install_requires = [
34 48.2.212
            'TurboGears[future] >= 1.0',
35
            'TurboMail',
36 48.2.230
            'python_fedora >= 0.3.12',
37 614
            'SQLAlchemy >= 0.5.5, < 0.6',
38 599.1.2
            'sqlalchemy-migrate >= 0.5',
39 48.2.206
            # Doesn't use setuptools so not on RHEL5
40 48.2.276
            #'python_bugzilla >= 0.5',
41 408.1.29
        ],
42 562.1.4
        scripts = ['start-pkgdb', 'pkgdb.wsgi', 'manage_db',
43
            'clients/pkgdb-client',
44 493
            'server-scripts/pkgdb-sync-yum',
45 48.2.212
            'server-scripts/pkgdb-sync-bugzilla'],
46 408.1.29
        zip_safe=False,
47
        packages=find_packages(),
48 48.2.225
        package_data = find_package_data(where='pkgdb',
49
            package='pkgdb'),
50 408.1.29
        keywords = [
51
            # Use keywords if you'll be adding your package to the
52
            # Python Cheeseshop
53
54
            # if this has widgets, uncomment the next line
55
            # 'turbogears.widgets',
56
            # if this has a tg-admin command, uncomment the next line
57
            # 'turbogears.command',
58
            'turbogears.app',
59
        ],
60 48.2.220
        message_extractors = {
61
            'pkgdb': [('**.py', 'python', None),
62
                ('templates/**.html', 'genshi', None),],
63
            },
64 408.1.29
        classifiers = [
65
            'Development Status :: 4 - Beta',
66
            'Operating System :: OS Independent',
67
            'Programming Language :: Python',
68
            'Environment :: Web Environment',
69
            'Framework :: TurboGears',
70
            # if this is an application that you'll distribute through
71
            # the Cheeseshop, uncomment the next line
72
            'Framework :: TurboGears :: Applications',
73
            # if this is a package that includes widgets that you'll distribute
74
            # through the Cheeseshop, uncomment the next line
75
            # 'Framework :: TurboGears :: Widgets',
76
        ],
77
        test_suite = 'nose.collector',
78 48.2.206
        entry_points = {
79
            'console_scripts': [
80
                'start-pkgdb = pkgdb.commands:start'
81
            ],
82
        },
83 408.1.29
        ),
84
    sphinx = Bunch(
85
        docroot='.',
86
        builddir='build-doc',
87 48.12.60
        sourcedir='docs'
88 408.1.29
        ),
89
    pylint = Bunch(
90
        module=['pkgdb']
91 48.2.206
        ),
92
    publish=Bunch(
93
        doc_location='fedorahosted.org:/srv/web/releases/p/a/packagedb/doc/',
94
        tarball_location='fedorahosted.org:/srv/web/releases/p/a/packagedb/'
95
        ),
96
    i18n=Bunch(
97
        builddir='locale',
98 48.2.225
        domain='fedora-packagedb',
99 48.2.206
        ),
100
    data = Bunch(
101 537.1.75
        #datafiles=[],
102 48.2.225
        localefiles=['locale'],
103 48.2.206
        docfiles=['docs'],
104 48.2.225
        conffiles=['pkgdb.cfg', 'pkgdb-client.cfg', {'httpd-pkgdb.conf': 'httpd/conf.d/pkgdb.conf'}],
105
        ),
106
    ### FIXME: Eventually, this should be tied into data and a library that
107
    # finds file location instead.
108
    installdirs = Bunch(
109
        prefix='/usr/local',
110
        execprefix='%(prefix)s',
111
        bindir='%(execprefix)s/bin',
112
        sbindir='%(execprefix)s/sbin',
113
        libexecdir='%(execprefix)s/libexec',
114
        datadir='%(prefix)s/share',
115
        sysconfdir='%(prefix)s/etc',
116
        localstatedir='%(prefix)s/var',
117
        includedir='%(prefix)s/include',
118
        infodir='%(datadir)s/info',
119
        mandir='%(datadir)s/man',
120
        localedir='%(datadir)s/locale',
121
        ),
122
    ### FIXME: Eventually, this should be tied into data and a library that
123
    # finds file location instead.
124
    substitute = Bunch(
125 48.2.212
        # Files to substitute on
126 562.1.4
        onfiles=['start-pkgdb', 'pkgdb.wsgi', 'manage_db', 'server-scripts/pkgdb-sync-yum',
127 48.2.212
            'server-scripts/pkgdb-sync-bugzilla',
128
            'update-schema/pkgdb-0.3.10-0.3.11.py', 'httpd-pkgdb.conf'],
129
        # Strings to substitute inside the files
130
        patterns={'@CONFDIR@': '/usr/local/etc',
131
            '@DATADIR@': '/usr/local/share',
132
            '@SBINDIR@': '/usr/local/sbin'},
133
        ),
134 48.2.206
    ### FIXME: These are due to a bug in paver-1.0
135
    # http://code.google.com/p/paver/issues/detail?id=24
136
    sdist=Bunch(),
137 408.1.29
    )
138
139 48.2.225
#
140
# Publish tasks -- somewhat site specific
141
#
142
143 48.2.206
@task
144
@needs(['html'])
145
def publish_doc():
146
    options.order('publish', add_rest=True)
147
    command = 'rsync -av build-doc/html/ %s' % (options.doc_location,)
148
    dry(command, paver_sh, command)
149
150
@task
151
@needs(['sdist'])
152
def publish_tarball():
153
    options.order('publish', add_rest=True)
154 537.1.99
    tarname = '%s-%s.tar.bz2' % (options.name, options.version)
155 48.2.206
    command = 'scp dist/%s %s' % (tarname, options.tarball_location)
156
    dry(command, paver_sh, command)
157
158
@task
159
@needs(['publish_doc', 'publish_tarball'])
160
def publish():
161
    pass
162
163 48.2.225
#
164
# convenience tasks to create all messages catalogs instead of one at a time
165
#
166
167 48.2.206
try:
168
    import babel.messages.frontend
169
    has_babel = True
170
except ImportError:
171
    has_babel = False
172
173 48.2.225
if has_babel:
174 48.2.206
    @task
175
    def make_catalogs():
176
        '''Compile all message catalogs for release'''
177
        options.order('i18n', add_rest=True)
178
        for po_file in glob.glob('po/*.po'):
179
            locale, ext = os.path.splitext(os.path.basename(po_file))
180 48.2.225
            build_dir = paver_path(options.builddir)
181
            build_dir = build_dir.joinpath(locale, 'LC_MESSAGES')
182 48.2.206
183 48.2.225
            build_dir.makedirs(mode=0755)
184 48.2.206
            if 'compile_catalog' in options.keys():
185
                defaults = options.compile_catalog
186
            else:
187
                defaults = Bunch(domain=options.domain,
188
                        directory=options.builddir)
189
                options.compile_catalog = defaults
190
191
            defaults.update({'input-file': po_file, 'locale': locale})
192
            ### FIXME: compile_catalog cannot handle --dry-run on its own
193
            dry('paver compile_catalog -D %(domain)s -d %(directory)s'
194
                    ' -i %(input-file)s --locale %(locale)s' % defaults,
195
                    paver_sh, 'paver compile_catalog -D %(domain)s' \
196
                        ' -d %(directory)s -i %(input-file)s' \
197
                        ' --locale %(locale)s' % defaults)
198
            ### FIXME: Need to get call_task to call this repeatedly
199
            # because options.compile_catalog has changed
200
            #dry('paver compile_catalog -D %(domain)s -d %(directory)s'
201
            #        ' -i %(input-file)s --locale %(locale)s' % defaults,
202
            #        call_task, 'babel.messages.frontend.compile_catalog', options)
203
204 48.2.225
#
205
# Install tasks
206
#
207
208
### Backends ###
209
210
def _apply_root(args, path):
211
    '''Add the root value to the start of the path'''
212
    if 'root' in args:
213
        if path.startswith('/'):
214
            path = path[1:]
215
        path = paver_path(os.path.join(args['root'], path))
216
    else:
217
        path = paver_path(path)
218
    return path
219
220
def _install_catalogs(args, paths):
221 48.2.206
    '''Install message catalogs in their proper location on the filesystem.
222
223
    Note: To use this with non-default commandline arguments, you must use 
224
    '''
225
    # Rebuild message catalogs
226
    if 'skip_build' not in args and 'skip-build' not in args:
227
        call_task('make_catalogs')
228
229
    options.order('i18n', add_rest=True)
230 48.2.225
231
    # Setup the install_dir
232
    cat_dir = _apply_root(args, paths.localedir)
233
234
    for catalog in paver_path(options.builddir).walkfiles('*.mo'):
235
        locale_dir = catalog.dirname()
236
        path = paver_path('.')
237
        for index, nextpath in enumerate(locale_dir.splitall()):
238
            path = path.joinpath(nextpath)
239
            if paver_path(options.builddir).samefile(path):
240
                install_locale = cat_dir.joinpath(os.path.join(
241
                        *locale_dir.splitall()[index + 1:]))
242
                install_locale.makedirs(mode=0755)
243
                install_locale = install_locale.joinpath(catalog.basename())
244
                if install_locale.exists():
245
                    install_locale.remove()
246
                dry('cp %s %s'%  (catalog, install_locale),
247
                        catalog.copy, install_locale)
248
                dry('chmod 0644 %s'%  install_locale,
249
                        install_locale.chmod, 0644)
250
251
def _install_conf(args, paths):
252
    '''Install configuration files'''
253
    options.order('setup', add_rest=True)
254
    if 'skip_build' not in args and 'skip-build' not in args:
255
        call_task('substitute')
256
257
    options.order('data', add_rest=True)
258
    # Setup the install_dir
259
    conf_dir = apply_root(args, paths.sysconfdir)
260
261
    conf_dir.joinpath(options.name)
262
    if not conf_dir.exists():
263
        conf_dir.makedirs(mode=0755)
264
265
    for conf_file in options.data.conffiles:
266
        conf_file = paver_path(conf_file)
267
        installfile = conf_dir.joinpath(conf_file)
268 48.2.228
        dry('cp %s %s' %  (conf_file, installfile),
269 48.2.225
                conf_file.copy, install_file)
270 48.2.228
        dry('chmod 0644 %s'%  install_locale,
271
                install_locale.chmod, 0644)
272 48.2.225
273
    for catalog in paver_path(options.builddir).walkfiles('*.mo'):
274
        locale_dir = catalog.dirname()
275
        path = paver_path('.')
276
        for index, nextpath in enumerate(locale_dir.splitall()):
277
            path = path.joinpath(nextpath)
278
            if paver_path(options.builddir).samefile(path):
279
                install_locale = cat_dir.joinpath(os.path.join(
280
                        *locale_dir.splitall()[index + 1:]))
281
                install_locale.makedirs(mode=0755)
282
                install_locale = install_locale.joinpath(catalog.basename())
283
                if install_locale.exists():
284
                    install_locale.remove()
285
                dry('cp %s %s'%  (catalog, install_locale),
286
                        catalog.copy, install_locale)
287
                dry('chmod 0644 %s'%  install_locale,
288
                        install_locale.chmod, 0644)
289
    pass
290
291
def _install_data(args, paths):
292
    pass
293
294
def _install_sbin(args, paths):
295
    pass
296
297
# Any install target needs to first look in:
298
# Commandline
299
# Default config
300
@task
301
def install_doc():
302
    pass
303
304
@task
305
def install_public_code():
306
    pass
307
308
@task
309
def install_private_code():
310
    pass
311
312 537.1.22
def _db_autodoc_run(*args, **kwargs):
313
    cmd = subprocess.Popen('/usr/bin/postgresql_autodoc -d pkgdb -u pkgdbadmin -h localhost --password -t dia'.split(' '))
314
    return cmd.wait()
315
316
@task
317
def db_autodoc():
318
    autodocopts = options.module
319
    dry('postgresql_autodoc -d pkgdb -u pkgdbadmin -h localhost --password -t dia', _db_autodoc_run, autodocopts)
320
321 48.2.225
### Frontends -- these are what you invoke with paver ###
322 48.2.206
@task
323
@cmdopts([('root=', None, 'Base root directory to install into'),
324
    ('install-catalogs=', None, 'directory that locale catalogs go in'),
325
    ('skip-build', None, 'Skip directly to installing'),
326
    ])
327
def install_catalogs():
328
    _install_catalogs(options.install_catalogs)
329
    pass
330
331 48.2.225
### FIXME: setuptools.command.install does not respond to --dry-run
332
@task
333
@needs(['setuptools.command.install'])
334
def install():
335
    '''Override the setuptools install.'''
336
    # First override any paths
337
    for arg in options.install:
338
        if arg in options.installdirs.keys():
339
            options.installdirs[arg] = options.install[arg]
340
341
    # Then expand all paths
342
    new = Bunch()
343
    num_unexpanded = 0
344
    for path_type in options.installdirs:
345
        options.installdirs[path_type] = options.installdirs[path_type] % \
346
                options.installdirs
347
        new[path_type] = options.installdirs[path_type]
348
349
    while num_unexpanded != len(options.installdirs):
350
        num_unexpanded = len(options.installdirs)
351
        for path_type in options.installdirs.keys():
352
            options.installdirs[path_type] = options.installdirs[path_type] % \
353
                    new
354
            if new[path_type] == options.installdirs[path_type]:
355
                del options.installdirs[path_type]
356
            else:
357
                new[path_type] = options.installdirs[path_type]
358
359
    if num_unexpanded:
360
        raise PavementError('%s unexpanded path variables.  Correct these in pavement.py installdirs: %s' % (num_unexpanded, options.installdirs))
361
362
    # Then call each individual piece of installation
363
    _install_catalogs(options.install, new)
364
    _install_conf(options.install, new)
365
    _install_data(options.install, new)
366
    _install_sbin(options.install, new)
367
368 48.2.206
@task
369
@needs(['make_catalogs', 'setuptools.command.sdist'])
370
def sdist():
371
    pass
372
373 408.1.29
#
374
# Generic Tasks
375
#
376
377 48.2.212
### Substitute path variables ###
378
@task
379
@cmdopts([
380
    ('install-conf=', None, 'Installation directory for configuration files'),
381 48.2.225
    ('install-data=', None, 'Installation directory for data files'),
382
    ('install-sbin=', None, 'Installation directory for daemons')
383 48.2.212
    ])
384
def substitute():
385
    options.order('substitutions', add_rest=True)
386
    substitutions = options.patterns
387
    if hasattr(options.substitute, 'install_conf'):
388
        substitutions['@CONFDIR@'] = options.substitute.install_conf
389
    if hasattr(options.substitute, 'install_data'):
390
        substitutions['@DATADIR@'] = options.substitute.install_data
391 48.2.225
    if hasattr(options.substitute, 'install_sbin'):
392
        substitutions['@SBINDIR@'] = options.substitute.install_sbin
393 48.2.212
394
    subRE = re.compile('('+'|'.join(options.patterns.keys())+')+')
395
396
    for filename in options.onfiles:
397
        infile = paver_path(filename + '.in')
398
        if not infile.exists():
399 48.2.225
            raise PavementError('Nonexistent file listed in substitute: %s' % infile)
400 48.2.212
        outf = paver_path(filename)
401
        contents = []
402
        for line in infile.lines(encoding='utf8'):
403
            matches = subRE.search(line)
404
            if matches:
405
                for pattern in substitutions:
406
                    line = line.replace(pattern, substitutions[pattern])
407
            contents.append(line)
408
        outf.write_lines(contents, encoding='utf8')
409
410
@task
411
@needs(['substitute', 'setuptools.command.build'])
412
def build():
413
    pass
414
415 48.2.206
### Pylint ###
416
417 408.1.29
try:
418
    from pylint import lint
419
    has_pylint = True
420
except ImportError:
421
    has_pylint = False
422
423
if has_pylint:
424
    @task
425
    def pylint():
426
        '''Check the module you're building with pylint.'''
427
        options.order('pylint', add_rest=True)
428
        pylintopts = options.module
429
        dry('pylint %s' % (" ".join(pylintopts)), lint.Run, pylintopts)

Loggerhead 1.18.1 is a web-based interface for Bazaar branches