2013-03-15 08:48:57 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
''' Setup script for Polynum
|
|
|
|
'''
|
|
|
|
|
2013-08-13 17:10:33 +02:00
|
|
|
import glob
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2013-03-15 08:48:57 +01:00
|
|
|
from setuptools import setup, find_packages
|
2013-04-12 14:48:26 +02:00
|
|
|
from setuptools.command.install_lib import install_lib as _install_lib
|
|
|
|
from distutils.command.build import build as _build
|
2013-08-13 17:10:33 +02:00
|
|
|
from distutils.command.sdist import sdist
|
2013-04-12 14:48:26 +02:00
|
|
|
from distutils.cmd import Command
|
|
|
|
|
|
|
|
class compile_translations(Command):
|
|
|
|
description = 'compile message catalogs to MO files via django compilemessages'
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
2013-08-09 15:33:33 +02:00
|
|
|
try:
|
|
|
|
from django.core.management.commands.compilemessages import \
|
|
|
|
compile_messages
|
2014-03-26 14:49:38 +01:00
|
|
|
for path in ['portail_citoyen2'] + glob.glob('portail_citoyen2/apps/*'):
|
2013-08-09 15:33:33 +02:00
|
|
|
if path.endswith('.py'):
|
|
|
|
continue
|
|
|
|
if not os.path.isdir(os.path.join(path, 'locale')):
|
|
|
|
continue
|
|
|
|
curdir = os.getcwd()
|
|
|
|
os.chdir(os.path.realpath(path))
|
2014-01-21 15:31:32 +01:00
|
|
|
compile_messages(sys.stderr)
|
2013-08-09 15:33:33 +02:00
|
|
|
os.chdir(curdir)
|
|
|
|
except ImportError:
|
|
|
|
print
|
|
|
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
|
|
|
print
|
|
|
|
print
|
2013-04-12 14:48:26 +02:00
|
|
|
|
|
|
|
class build(_build):
|
|
|
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
|
|
|
|
|
|
|
class install_lib(_install_lib):
|
|
|
|
def run(self):
|
|
|
|
self.run_command('compile_translations')
|
|
|
|
_install_lib.run(self)
|
2013-03-15 08:48:57 +01:00
|
|
|
|
2013-08-13 17:10:33 +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-05-13 16:40:25 +02:00
|
|
|
def get_version():
|
|
|
|
|
|
|
|
version = None
|
2013-08-13 17:10:33 +02:00
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
version_file = open('VERSION', 'r')
|
|
|
|
version = version_file.read()
|
2013-08-13 17:20:56 +02:00
|
|
|
version_file.close()
|
2013-08-13 17:10:33 +02:00
|
|
|
return version
|
2013-05-13 16:40:25 +02:00
|
|
|
for d in glob.glob('*'):
|
|
|
|
if not os.path.isdir(d):
|
|
|
|
continue
|
|
|
|
module_file = os.path.join(d, '__init__.py')
|
|
|
|
if not os.path.exists(module_file):
|
|
|
|
continue
|
|
|
|
for v in re.findall("""__version__ *= *['"](.*)['"]""",
|
|
|
|
open(module_file).read()):
|
|
|
|
assert version is None
|
|
|
|
version = v
|
|
|
|
if version:
|
|
|
|
break
|
|
|
|
assert version is not None
|
|
|
|
if os.path.exists('.git'):
|
|
|
|
import subprocess
|
2013-05-15 16:11:20 +02:00
|
|
|
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
2013-05-13 16:40:25 +02:00
|
|
|
stdout=subprocess.PIPE)
|
|
|
|
result = p.communicate()[0]
|
|
|
|
assert p.returncode == 0, 'git returned non-zero'
|
2013-05-15 16:11:20 +02:00
|
|
|
new_version = result.split()[0][1:]
|
2013-05-13 16:40:25 +02:00
|
|
|
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
|
|
|
|
version = new_version.replace('-', '.')
|
|
|
|
return version
|
|
|
|
|
|
|
|
|
2014-03-04 18:10:00 +01:00
|
|
|
setup(name="portail-citoyen2",
|
2013-05-13 16:40:25 +02:00
|
|
|
version=get_version(),
|
2013-03-15 08:48:57 +01:00
|
|
|
license="AGPLv3 or later",
|
|
|
|
description="Portail citoyen",
|
|
|
|
url="http://dev.entrouvert.org/projects/portail-citoyen/",
|
|
|
|
author="Entr'ouvert",
|
|
|
|
author_email="info@entrouvert.org",
|
|
|
|
maintainer="Benjamin Dauvergne",
|
|
|
|
maintainer_email="info@entrouvert.com",
|
|
|
|
include_package_data=True,
|
2013-04-18 17:46:36 +02:00
|
|
|
packages=find_packages(),
|
2014-04-01 16:03:05 +02:00
|
|
|
scripts=('portail-citoyen2',),
|
2013-11-18 23:53:31 +01:00
|
|
|
setup_requires=[
|
2014-03-06 09:55:31 +01:00
|
|
|
'django>=1.5.1',
|
2013-11-18 23:53:31 +01:00
|
|
|
],
|
2013-03-15 08:48:57 +01:00
|
|
|
install_requires=[
|
2014-01-07 18:12:29 +01:00
|
|
|
'requests>=2.1',
|
2013-03-19 16:47:11 +01:00
|
|
|
'feedparser',
|
2013-05-31 11:45:01 +02:00
|
|
|
'django>=1.5.1,<1.6',
|
2014-03-06 09:55:31 +01:00
|
|
|
'django-cms>=3',
|
2014-01-08 01:58:52 +01:00
|
|
|
'python-entrouvert',
|
2013-12-19 15:28:55 +01:00
|
|
|
'south>=0.8.4',
|
2014-03-04 18:10:00 +01:00
|
|
|
'djangocms-text-ckeditor',
|
2014-03-07 17:45:48 +01:00
|
|
|
'django-allauth',
|
2014-05-26 22:55:26 +02:00
|
|
|
'django-admin-tools',
|
2013-03-15 08:48:57 +01:00
|
|
|
],
|
2014-03-04 18:10:00 +01:00
|
|
|
cmdclass={
|
|
|
|
'build': build,
|
|
|
|
'install_lib': install_lib,
|
2013-08-13 17:10:33 +02:00
|
|
|
'compile_translations': compile_translations,
|
2014-03-04 18:10:00 +01:00
|
|
|
'sdist': eo_sdist
|
|
|
|
},
|
2013-03-15 08:48:57 +01:00
|
|
|
)
|