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
|
|
10
|
VERSION = '1.20'
|
11
|
|
12
|
def get_version():
|
13
|
if os.path.exists('VERSION'):
|
14
|
version_file = open('VERSION', 'r')
|
15
|
version = version_file.read()
|
16
|
version_file.close()
|
17
|
return version
|
18
|
if os.path.exists('.git'):
|
19
|
p = subprocess.Popen(['git','describe','--match=v*'], stdout=subprocess.PIPE)
|
20
|
result = p.communicate()[0]
|
21
|
version = result.split()[0][1:]
|
22
|
version = version.replace('-','.')
|
23
|
return version
|
24
|
return VERSION
|
25
|
|
26
|
def data_tree(destdir, sourcedir):
|
27
|
extensions = ['.css', '.png', '.jpeg', '.jpg', '.xml', '.html', '.js', '.ezt', '.gif', '.otf']
|
28
|
r = []
|
29
|
for root, dirs, files in os.walk(sourcedir):
|
30
|
l = [os.path.join(root, x) for x in files if os.path.splitext(x)[1] in extensions]
|
31
|
r.append( (root.replace(sourcedir, destdir, 1), l) )
|
32
|
if 'CVS' in dirs:
|
33
|
dirs.remove('CVS')
|
34
|
if '.svn' in dirs:
|
35
|
dirs.remove('.svn')
|
36
|
return r
|
37
|
|
38
|
class eo_sdist(sdist):
|
39
|
|
40
|
def run(self):
|
41
|
print "creating VERSION file"
|
42
|
if os.path.exists('VERSION'):
|
43
|
os.remove('VERSION')
|
44
|
version = get_version()
|
45
|
version_file = open('VERSION', 'w')
|
46
|
version_file.write(version)
|
47
|
version_file.close()
|
48
|
sdist.run(self)
|
49
|
print "removing VERSION file"
|
50
|
if os.path.exists('VERSION'):
|
51
|
os.remove('VERSION')
|
52
|
|
53
|
distutils.core.setup(
|
54
|
name = 'wcs-au-quotidien',
|
55
|
version = get_version(),
|
56
|
maintainer = 'Frederic Peters',
|
57
|
maintainer_email = 'fpeters@entrouvert.com',
|
58
|
package_dir = { 'extra': 'extra' },
|
59
|
packages = ['extra', 'extra.modules', 'extra.modules.pyatom'],
|
60
|
cmdclass = {'build_py': qx_build_py,
|
61
|
'sdist': eo_sdist},
|
62
|
data_files = data_tree('share/wcs/texts', 'texts') +\
|
63
|
data_tree('share/wcs/themes/auquotidien', 'theme') +\
|
64
|
data_tree('share/wcs/themes/', 'data/themes/') + \
|
65
|
data_tree('share/auquotidien/apache-errors', 'apache-errors') +\
|
66
|
[('share/wcs/', ['au-quotidien-wcs-settings.xml',])]
|
67
|
)
|