2014-11-06 21:15:33 +01:00
|
|
|
#!/usr/bin/python
|
2014-11-20 14:54:36 +01:00
|
|
|
import sys
|
2014-11-06 21:15:33 +01:00
|
|
|
import os
|
2015-04-17 16:33:14 +02:00
|
|
|
import subprocess
|
2017-06-15 15:49:10 +02:00
|
|
|
import glob
|
2014-11-06 21:15:33 +01:00
|
|
|
|
2014-11-20 14:54:36 +01:00
|
|
|
from setuptools import setup, find_packages
|
|
|
|
from setuptools.command.install_lib import install_lib as _install_lib
|
|
|
|
from distutils.command.build import build as _build
|
|
|
|
from distutils.command.sdist import sdist
|
|
|
|
from distutils.cmd import Command
|
|
|
|
|
2015-10-30 15:55:53 +01:00
|
|
|
|
2014-11-20 14:54:36 +01:00
|
|
|
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):
|
2017-06-15 15:49:10 +02:00
|
|
|
curdir = os.getcwd()
|
2014-11-20 14:54:36 +01:00
|
|
|
try:
|
2017-06-15 15:49:10 +02:00
|
|
|
os.environ.pop('DJANGO_SETTINGS_MODULE', None)
|
2015-10-30 15:55:53 +01:00
|
|
|
from django.core.management import call_command
|
2017-06-15 15:49:10 +02:00
|
|
|
for dir in glob.glob('src/*'):
|
|
|
|
for path, dirs, files in os.walk(dir):
|
|
|
|
if 'locale' not in dirs:
|
|
|
|
continue
|
|
|
|
os.chdir(os.path.realpath(path))
|
|
|
|
call_command('compilemessages')
|
|
|
|
os.chdir(curdir)
|
2014-11-20 14:54:36 +01:00
|
|
|
except ImportError:
|
2017-06-15 15:49:10 +02:00
|
|
|
print
|
|
|
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
|
|
|
print
|
|
|
|
print
|
|
|
|
os.chdir(curdir)
|
2014-11-20 14:54:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
class build(_build):
|
|
|
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
|
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
class install_lib(_install_lib):
|
|
|
|
def run(self):
|
|
|
|
self.run_command('compile_translations')
|
|
|
|
_install_lib.run(self)
|
|
|
|
|
2014-11-06 21:15:33 +01:00
|
|
|
def get_version():
|
2015-04-17 16:33:14 +02:00
|
|
|
'''Use the VERSION, if absent generates a version with git describe, if not
|
|
|
|
tag exists, take 0.0.0- and add the length of the commit log.
|
|
|
|
'''
|
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
with open('VERSION', 'r') as v:
|
|
|
|
return v.read()
|
2014-11-06 21:15:33 +01:00
|
|
|
if os.path.exists('.git'):
|
|
|
|
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
2015-04-17 16:33:14 +02:00
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
2014-11-06 21:15:33 +01:00
|
|
|
result = p.communicate()[0]
|
2015-04-17 16:33:14 +02:00
|
|
|
if p.returncode == 0:
|
|
|
|
return result.split()[0][1:].replace('-', '.')
|
|
|
|
else:
|
|
|
|
return '0.0.0-%s' % len(
|
|
|
|
subprocess.check_output(
|
|
|
|
['git', 'rev-list', 'HEAD']).splitlines())
|
|
|
|
return '0.0.0'
|
2014-11-06 21:15:33 +01:00
|
|
|
|
|
|
|
README = file(os.path.join(
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
'README')).read()
|
|
|
|
|
2015-05-27 16:07:44 +02:00
|
|
|
setup(name='authentic2-auth-fc',
|
2014-11-06 21:15:33 +01:00
|
|
|
version=get_version(),
|
|
|
|
license='AGPLv3',
|
2015-05-27 16:07:44 +02:00
|
|
|
description='Authentic2 FranceConnect plugin',
|
2014-11-06 21:15:33 +01:00
|
|
|
long_description=README,
|
|
|
|
author="Entr'ouvert",
|
2015-05-27 16:07:44 +02:00
|
|
|
url='https://repos.entrouvert.org/authentic2-auth-fc.git',
|
2014-11-06 21:15:33 +01:00
|
|
|
author_email="info@entrouvert.com",
|
|
|
|
packages=find_packages('src'),
|
|
|
|
package_dir={
|
|
|
|
'': 'src',
|
|
|
|
},
|
|
|
|
package_data={
|
2015-05-27 16:07:44 +02:00
|
|
|
'authentic2_auth_fc': [
|
|
|
|
'templates/authentic2_auth_fc/*.html',
|
|
|
|
'static/authentic2_auth_fc/css/*.css',
|
|
|
|
'static/authentic2_auth_fc/img/*.png',
|
2016-02-23 18:18:13 +01:00
|
|
|
'static/authentic2_auth_fc/img/*.svg',
|
2014-11-06 21:15:33 +01:00
|
|
|
'locale/fr/LC_MESSAGES/django.po',
|
2014-12-10 16:00:30 +01:00
|
|
|
'locale/fr/LC_MESSAGES/django.mo',
|
2017-07-18 00:44:30 +02:00
|
|
|
'*.json',
|
2014-11-06 21:15:33 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
install_requires=[
|
|
|
|
'authentic2',
|
|
|
|
'requests',
|
|
|
|
'requests-oauthlib',
|
|
|
|
],
|
|
|
|
entry_points={
|
|
|
|
'authentic2.plugin': [
|
2015-05-27 16:07:44 +02:00
|
|
|
'authentic2-auth-fc = authentic2_auth_fc:Plugin',
|
2014-11-06 21:15:33 +01:00
|
|
|
],
|
|
|
|
},
|
2014-11-20 14:54:36 +01:00
|
|
|
cmdclass={
|
|
|
|
'build': build,
|
|
|
|
'install_lib': install_lib,
|
|
|
|
'compile_translations': compile_translations,
|
|
|
|
'sdist': eo_sdist},
|
2015-10-30 11:48:26 +01:00
|
|
|
zip_safe=False,
|
2014-11-06 21:15:33 +01:00
|
|
|
)
|