2014-12-23 09:41:14 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
import glob
|
2018-08-09 14:32:57 +02:00
|
|
|
import itertools
|
2014-12-23 09:41:14 +01:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import subprocess
|
2015-12-19 19:18:17 +01:00
|
|
|
import sys
|
2015-03-09 17:34:11 +01:00
|
|
|
from distutils.cmd import Command
|
|
|
|
from distutils.command.build import build as _build
|
2014-12-23 09:41:14 +01:00
|
|
|
from distutils.command.sdist import sdist
|
2022-03-18 13:17:06 +01:00
|
|
|
from distutils.errors import CompileError
|
2018-01-26 12:23:07 +01:00
|
|
|
from distutils.spawn import find_executable
|
2021-04-06 21:31:24 +02:00
|
|
|
|
2014-12-23 09:41:14 +01:00
|
|
|
from setuptools import find_packages, setup
|
|
|
|
from setuptools.command.install_lib import install_lib as _install_lib
|
|
|
|
|
2021-02-15 18:01:46 +01:00
|
|
|
|
2014-12-23 09:41:14 +01:00
|
|
|
class eo_sdist(sdist):
|
|
|
|
def run(self):
|
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
os.remove('VERSION')
|
|
|
|
version = get_version()
|
2018-12-28 10:59:19 +01:00
|
|
|
with open('VERSION', 'w') as fd:
|
|
|
|
fd.write(version)
|
|
|
|
with open('combo/version.py', 'w') as fd:
|
|
|
|
fd.write('VERSION = %r' % version)
|
2014-12-23 09:41:14 +01:00
|
|
|
sdist.run(self)
|
|
|
|
if os.path.exists('VERSION'):
|
|
|
|
os.remove('VERSION')
|
|
|
|
|
2021-02-15 18:01:46 +01:00
|
|
|
|
2014-12-23 09:41:14 +01:00
|
|
|
def get_version():
|
2018-08-04 11:27:32 +02:00
|
|
|
"""Use the VERSION, if absent generates a version with git describe, if not
|
|
|
|
tag exists, take 0.0- and add the length of the commit log.
|
2021-02-15 18:01:46 +01:00
|
|
|
"""
|
2014-12-23 09:41:14 +01:00
|
|
|
if os.path.exists('VERSION'):
|
2018-08-04 11:27:32 +02:00
|
|
|
with open('VERSION') as v:
|
|
|
|
return v.read()
|
2014-12-23 09:41:14 +01:00
|
|
|
if os.path.exists('.git'):
|
2018-08-04 11:27:32 +02:00
|
|
|
p = subprocess.Popen(
|
|
|
|
['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
)
|
2014-12-23 09:41:14 +01:00
|
|
|
result = p.communicate()[0]
|
|
|
|
if p.returncode == 0:
|
2019-11-12 18:54:10 +01:00
|
|
|
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
|
|
|
if '-' in result: # not a tagged version
|
2018-08-04 11:27:32 +02:00
|
|
|
real_number, commit_count, commit_hash = result.split('-', 2)
|
|
|
|
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
|
|
|
else:
|
|
|
|
version = result
|
2014-12-23 09:41:14 +01:00
|
|
|
return version
|
2018-08-04 11:27:32 +02:00
|
|
|
else:
|
|
|
|
return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
|
|
|
|
return '0.0'
|
2014-12-23 09:41:14 +01:00
|
|
|
|
2021-02-15 18:01:46 +01:00
|
|
|
|
2015-05-20 11:27:26 +02:00
|
|
|
def data_tree(destdir, sourcedir):
|
|
|
|
extensions = ['.css', '.png', '.jpeg', '.jpg', '.gif', '.xml', '.html', '.js']
|
|
|
|
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))
|
|
|
|
return r
|
|
|
|
|
2021-02-15 18:01:46 +01:00
|
|
|
|
2015-03-09 17:34:11 +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):
|
2019-11-12 18:54:10 +01:00
|
|
|
orig_dir = os.getcwd()
|
2015-03-09 17:34:11 +01:00
|
|
|
try:
|
|
|
|
from django.core.management import call_command
|
2021-02-15 18:01:46 +01:00
|
|
|
|
2015-03-10 09:51:35 +01:00
|
|
|
for path, dirs, files in os.walk('combo'):
|
2015-03-09 17:34:11 +01:00
|
|
|
if 'locale' not in dirs:
|
|
|
|
continue
|
|
|
|
curdir = os.getcwd()
|
|
|
|
os.chdir(os.path.realpath(path))
|
|
|
|
call_command('compilemessages')
|
|
|
|
os.chdir(curdir)
|
|
|
|
except ImportError:
|
|
|
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
|
2019-11-12 18:54:10 +01:00
|
|
|
os.chdir(orig_dir)
|
2015-03-09 17:34:11 +01:00
|
|
|
|
|
|
|
|
2018-01-21 10:46:41 +01:00
|
|
|
class compile_scss(Command):
|
|
|
|
description = 'compile scss files into css files'
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
sass_bin = None
|
2019-08-21 09:46:03 +02:00
|
|
|
for program in ('sassc', 'sass'):
|
2018-01-21 10:46:41 +01:00
|
|
|
sass_bin = find_executable(program)
|
|
|
|
if sass_bin:
|
|
|
|
break
|
|
|
|
if not sass_bin:
|
|
|
|
raise CompileError(
|
|
|
|
'A sass compiler is required but none was found. See sass-lang.com for choices.'
|
|
|
|
)
|
|
|
|
|
2019-03-29 17:36:35 +01:00
|
|
|
for path, dirnames, filenames in os.walk('combo'):
|
2018-01-26 12:46:35 +01:00
|
|
|
for filename in filenames:
|
|
|
|
if not filename.endswith('.scss'):
|
|
|
|
continue
|
|
|
|
if filename.startswith('_'):
|
|
|
|
continue
|
|
|
|
subprocess.check_call(
|
2021-02-15 18:01:46 +01:00
|
|
|
[
|
2018-01-26 12:46:35 +01:00
|
|
|
sass_bin,
|
|
|
|
'%s/%s' % (path, filename),
|
|
|
|
'%s/%s' % (path, filename.replace('.scss', '.css')),
|
2021-02-15 18:01:46 +01:00
|
|
|
]
|
2018-01-26 12:46:35 +01:00
|
|
|
)
|
2018-01-21 10:46:41 +01:00
|
|
|
|
|
|
|
|
2015-03-09 17:34:11 +01:00
|
|
|
class build(_build):
|
2018-01-21 10:46:41 +01:00
|
|
|
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
|
2015-03-09 17:34:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
class install_lib(_install_lib):
|
|
|
|
def run(self):
|
|
|
|
self.run_command('compile_translations')
|
|
|
|
_install_lib.run(self)
|
|
|
|
|
2014-12-23 09:41:14 +01:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name='combo',
|
|
|
|
version=get_version(),
|
|
|
|
description='Content Manager',
|
|
|
|
author='Frederic Peters',
|
|
|
|
author_email='fpeters@entrouvert.com',
|
2018-03-12 12:09:29 +01:00
|
|
|
packages=find_packages(exclude=['tests']),
|
2014-12-23 09:41:14 +01:00
|
|
|
include_package_data=True,
|
|
|
|
scripts=('manage.py',),
|
|
|
|
url='https://dev.entrouvert.org/projects/combo/',
|
|
|
|
classifiers=[
|
2018-08-12 19:54:33 +02:00
|
|
|
'Development Status :: 4 - Beta',
|
2014-12-23 09:41:14 +01:00
|
|
|
'Environment :: Web Environment',
|
|
|
|
'Framework :: Django',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
|
|
|
|
'Operating System :: OS Independent',
|
|
|
|
'Programming Language :: Python',
|
2018-08-12 19:54:33 +02:00
|
|
|
'Programming Language :: Python :: 3',
|
2014-12-23 09:41:14 +01:00
|
|
|
],
|
2020-04-02 21:24:47 +02:00
|
|
|
install_requires=[
|
2021-12-19 16:55:28 +01:00
|
|
|
'django>=2.2, <2.3',
|
2020-04-01 16:30:35 +02:00
|
|
|
'django-ckeditor<4.5.4',
|
2018-04-16 13:30:17 +02:00
|
|
|
'gadjo>=0.53',
|
2021-03-19 22:41:43 +01:00
|
|
|
'feedparser<6' if sys.version_info < (3, 9) else 'feedparser>=6',
|
2015-09-18 12:25:45 +02:00
|
|
|
'requests',
|
2017-05-15 19:01:38 +02:00
|
|
|
'XStatic-Leaflet',
|
2020-01-17 12:13:49 +01:00
|
|
|
'XStatic-Leaflet-GestureHandling',
|
2018-02-12 19:20:18 +01:00
|
|
|
'XStatic-Leaflet-MarkerCluster',
|
2017-09-05 15:21:23 +02:00
|
|
|
'XStatic_OpenSans',
|
2020-01-04 15:41:04 +01:00
|
|
|
'XStatic_roboto-fontface>=0.5.0.0',
|
2020-11-04 13:28:27 +01:00
|
|
|
'eopayment>=1.60',
|
2015-12-30 17:58:54 +01:00
|
|
|
'python-dateutil',
|
2020-12-16 13:48:08 +01:00
|
|
|
'djangorestframework>=3.3, <3.10',
|
2019-08-14 09:40:13 +02:00
|
|
|
'django-ratelimit<3',
|
2017-05-15 14:10:06 +02:00
|
|
|
'sorl-thumbnail',
|
|
|
|
'Pillow',
|
2020-06-03 11:27:09 +02:00
|
|
|
'pycryptodomex',
|
2018-07-01 21:40:33 +02:00
|
|
|
'pyproj',
|
2019-06-30 09:43:16 +02:00
|
|
|
'pywebpush',
|
2019-03-28 09:58:54 +01:00
|
|
|
'pygal',
|
|
|
|
'lxml',
|
2014-12-07 15:34:30 +01:00
|
|
|
],
|
2014-12-23 09:41:14 +01:00
|
|
|
zip_safe=False,
|
2015-03-09 17:34:11 +01:00
|
|
|
cmdclass={
|
|
|
|
'build': build,
|
2018-01-21 10:46:41 +01:00
|
|
|
'compile_scss': compile_scss,
|
2015-03-09 17:34:11 +01:00
|
|
|
'compile_translations': compile_translations,
|
|
|
|
'install_lib': install_lib,
|
|
|
|
'sdist': eo_sdist,
|
|
|
|
},
|
2014-12-23 09:41:14 +01:00
|
|
|
)
|