Projet

Général

Profil

Télécharger (2,26 ko) Statistiques
| Branche: | Tag: | Révision:

root / setup.py @ 968a4052

1
#! /usr/bin/env python
2

    
3
import os
4
import subprocess
5
import distutils.core
6

    
7
from distutils.command.sdist import sdist
8
from quixote.ptl.qx_distutils import qx_build_py
9
from setuptools import setup
10

    
11
VERSION = '1.20'
12

    
13
def get_version():
14
    if os.path.exists('VERSION'):
15
        version_file = open('VERSION', 'r')
16
        version = version_file.read()
17
        version_file.close()
18
        return version
19
    if os.path.exists('.git'):
20
        p = subprocess.Popen(['git','describe','--match=v*'], stdout=subprocess.PIPE)
21
        result = p.communicate()[0]
22
        version = result.split()[0][1:]
23
        version = version.replace('-','.')
24
        return version
25
    return VERSION
26

    
27
def data_tree(destdir, sourcedir):
28
    extensions = ['.css', '.png', '.jpeg', '.jpg', '.xml', '.html', '.js', '.ezt', '.gif', '.otf']
29
    r = []
30
    for root, dirs, files in os.walk(sourcedir):
31
        l = [os.path.join(root, x) for x in files if os.path.splitext(x)[1] in extensions]
32
        r.append( (root.replace(sourcedir, destdir, 1), l) )
33
        if 'CVS' in dirs:
34
            dirs.remove('CVS')
35
        if '.svn' in dirs:
36
            dirs.remove('.svn')
37
    return r
38

    
39
class eo_sdist(sdist):
40

    
41
    def run(self):
42
        print "creating VERSION file"
43
        if os.path.exists('VERSION'):
44
            os.remove('VERSION')
45
        version = get_version()
46
        version_file = open('VERSION', 'w')
47
        version_file.write(version)
48
        version_file.close()
49
        sdist.run(self)
50
        print "removing VERSION file"
51
        if os.path.exists('VERSION'):
52
            os.remove('VERSION')
53

    
54
setup(
55
        name = 'wcs-au-quotidien',
56
        version = get_version(),
57
        maintainer = 'Frederic Peters',
58
        maintainer_email = 'fpeters@entrouvert.com',
59
        package_dir = {'auquotidien': 'auquotidien'},
60
        packages = ['auquotidien', 'auquotidien.modules', 'auquotidien.modules.pyatom'],
61
        cmdclass = {'build_py': qx_build_py,
62
                    'sdist': eo_sdist},
63
        data_files = data_tree('share/wcs/texts', 'texts') +\
64
            data_tree('share/wcs/themes/auquotidien', 'theme') +\
65
            data_tree('share/wcs/themes/', 'data/themes/') + \
66
            data_tree('share/auquotidien/apache-errors', 'apache-errors') +\
67
            [('share/wcs/', ['au-quotidien-wcs-settings.xml',])]
68
    )
(5-5/6)