2005-05-19 23:26:55 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
2013-08-13 18:02:17 +02:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
2013-04-27 15:58:40 +02:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils import cmd
|
|
|
|
from distutils.command.install_data import install_data as _install_data
|
|
|
|
from distutils.command.build import build as _build
|
2013-08-13 18:02:17 +02:00
|
|
|
from distutils.command.sdist import sdist
|
2013-04-26 09:46:11 +02:00
|
|
|
|
2005-05-24 13:52:27 +02:00
|
|
|
local_cfg = None
|
|
|
|
if os.path.exists('wcs/wcs_cfg.py'):
|
|
|
|
local_cfg = file('wcs/wcs_cfg.py').read()
|
|
|
|
os.unlink('wcs/wcs_cfg.py')
|
|
|
|
|
2013-04-27 15:58:40 +02:00
|
|
|
class build_trans(cmd.Command):
|
|
|
|
description = 'Compile .po files into .mo files'
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
po_dir = os.path.join(os.path.dirname(os.curdir), 'po')
|
|
|
|
for path, names, filenames in os.walk(po_dir):
|
|
|
|
for f in filenames:
|
|
|
|
if f.endswith('.po'):
|
|
|
|
lang = f[:-3]
|
|
|
|
src = os.path.join(path, f)
|
|
|
|
dest_path = os.path.join('build', 'locale', lang, 'LC_MESSAGES')
|
|
|
|
dest = os.path.join(dest_path, 'wcs.mo')
|
|
|
|
if not os.path.exists(dest_path):
|
|
|
|
os.makedirs(dest_path)
|
|
|
|
if not os.path.exists(dest):
|
|
|
|
print 'Compiling %s' % src
|
|
|
|
subprocess.call(['msgfmt', src, '--output-file', dest])
|
|
|
|
else:
|
|
|
|
src_mtime = os.stat(src)[8]
|
|
|
|
dest_mtime = os.stat(dest)[8]
|
|
|
|
if src_mtime > dest_mtime:
|
|
|
|
print 'Compiling %s' % src
|
|
|
|
subprocess.call(['msgfmt', src, '--output-file', dest])
|
|
|
|
|
|
|
|
class build(_build):
|
|
|
|
sub_commands = _build.sub_commands + [('build_trans', None)]
|
|
|
|
def run(self):
|
|
|
|
_build.run(self)
|
|
|
|
|
2013-08-13 18:02:17 +02:00
|
|
|
|
|
|
|
class eo_sdist(sdist):
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
print "creating VERSION file"
|
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
os.remove('VERSION')
|
|
|
|
version = get_version()
|
|
|
|
version_file = open('VERSION', 'w')
|
|
|
|
version_file.write(version)
|
|
|
|
version_file.close()
|
|
|
|
sdist.run(self)
|
|
|
|
print "removing VERSION file"
|
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
os.remove('VERSION')
|
|
|
|
|
|
|
|
|
2013-04-27 15:58:40 +02:00
|
|
|
class install_data(_install_data):
|
|
|
|
def run(self):
|
|
|
|
for lang in os.listdir('build/locale/'):
|
|
|
|
lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
|
|
|
|
lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', 'wcs.mo')
|
|
|
|
self.data_files.append( (lang_dir, [lang_file]) )
|
|
|
|
_install_data.run(self)
|
|
|
|
|
|
|
|
|
2005-05-24 13:52:27 +02:00
|
|
|
def data_tree(destdir, sourcedir):
|
2015-09-08 13:57:31 +02:00
|
|
|
extensions = ['.css', '.png', '.jpeg', '.jpg', '.gif', '.xml', '.html',
|
2015-09-10 22:44:42 +02:00
|
|
|
'.js', '.ezt', '.dat', '.eot', '.svg', '.ttf', '.woff']
|
2005-05-24 13:52:27 +02:00
|
|
|
r = []
|
|
|
|
for root, dirs, files in os.walk(sourcedir):
|
|
|
|
l = [os.path.join(root, x) for x in files if os.path.splitext(x)[1] in extensions]
|
|
|
|
r.append( (root.replace(sourcedir, destdir, 1), l) )
|
2009-04-09 09:52:28 +02:00
|
|
|
for vcs_dirname in ('CVS', '.svn', '.bzr', '.git'):
|
|
|
|
if vcs_dirname in dirs:
|
|
|
|
dirs.remove(vcs_dirname)
|
2005-05-24 13:52:27 +02:00
|
|
|
return r
|
|
|
|
|
2013-04-26 09:46:11 +02:00
|
|
|
def get_version():
|
2013-08-13 18:02:17 +02:00
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
version_file = open('VERSION', 'r')
|
|
|
|
version = version_file.read()
|
|
|
|
version_file.close()
|
|
|
|
return version
|
2013-04-26 09:46:11 +02:00
|
|
|
if os.path.exists('.git'):
|
2014-04-24 16:31:04 +02:00
|
|
|
p = subprocess.Popen(['git','describe','--match=v*'], stdout=subprocess.PIPE)
|
2013-04-26 09:46:11 +02:00
|
|
|
result = p.communicate()[0]
|
2014-04-24 16:31:04 +02:00
|
|
|
version = result.split()[0][1:]
|
|
|
|
version = version.replace('-', '.')
|
|
|
|
return version
|
2015-10-06 23:02:17 +02:00
|
|
|
return '0'
|
2013-04-26 09:46:11 +02:00
|
|
|
|
2013-04-27 15:58:40 +02:00
|
|
|
|
|
|
|
cmdclass = {
|
|
|
|
'build': build,
|
|
|
|
'build_trans': build_trans,
|
|
|
|
'install_data': install_data,
|
2013-08-13 18:02:17 +02:00
|
|
|
'sdist': eo_sdist
|
2013-04-27 15:58:40 +02:00
|
|
|
}
|
|
|
|
|
2009-04-17 11:24:51 +02:00
|
|
|
setup(
|
2005-05-19 23:26:55 +02:00
|
|
|
name = 'wcs',
|
2013-05-06 12:53:57 +02:00
|
|
|
version = get_version(),
|
2005-05-19 23:26:55 +02:00
|
|
|
maintainer = "Frederic Peters",
|
|
|
|
maintainer_email = "fpeters@entrouvert.com",
|
|
|
|
url = "http://wcs.labs.libre-entreprise.org",
|
2016-06-14 21:52:47 +02:00
|
|
|
install_requires=['gadjo'],
|
2005-05-19 23:26:55 +02:00
|
|
|
package_dir = { 'wcs': 'wcs' },
|
2006-10-13 10:49:34 +02:00
|
|
|
packages = ['wcs', 'wcs.admin', 'wcs.backoffice', 'wcs.ctl',
|
2010-03-23 17:00:59 +01:00
|
|
|
'wcs.ctl.Bouncers', 'wcs.forms', 'wcs.wf', 'wcs.qommon',
|
|
|
|
'wcs.qommon.admin', 'wcs.qommon.backoffice', 'wcs.qommon.ident',
|
|
|
|
'wcs.qommon.vendor'],
|
2013-04-27 15:58:40 +02:00
|
|
|
cmdclass = cmdclass,
|
2006-06-15 18:34:00 +02:00
|
|
|
scripts = ['wcsctl.py'],
|
2009-04-22 17:18:35 +02:00
|
|
|
data_files = data_tree('share/wcs/web/', 'data/web/') + \
|
2008-01-02 14:52:09 +01:00
|
|
|
data_tree('share/wcs/themes/', 'data/themes/') + \
|
2011-04-21 15:50:17 +02:00
|
|
|
data_tree('share/wcs/vendor/', 'data/vendor/') + \
|
2015-04-22 18:51:55 +02:00
|
|
|
data_tree('share/wcs/qommon/', 'wcs/qommon/static/') +
|
|
|
|
[('share/wcs/', ['data/webbots', 'data/print-html-as-pdf.js'])]
|
2005-05-19 23:26:55 +02:00
|
|
|
)
|
2005-05-24 13:52:27 +02:00
|
|
|
|
|
|
|
if local_cfg:
|
|
|
|
file('wcs/wcs_cfg.py', 'w').write(local_cfg)
|