1 #! /usr/bin/env python3
7 from distutils.cmd import Command
8 from distutils.command.build import build as _build
9 from distutils.command.sdist import sdist
10 from distutils.spawn import find_executable
12 from setuptools import find_packages, setup
13 from setuptools.command.install_lib import install_lib as _install_lib
16 class eo_sdist(sdist):
18 if os.path.exists('VERSION'):
20 version = get_version()
21 with open('VERSION', 'w') as fd:
24 if os.path.exists('VERSION'):
29 """Use the VERSION, if absent generates a version with git describe, if not
30 tag exists, take 0.0- and add the length of the commit log.
32 if os.path.exists('VERSION'):
33 with open('VERSION') as v:
35 if os.path.exists('.git'):
37 ['git', 'describe', '--dirty=.dirty', '--match=v*'],
38 stdout=subprocess.PIPE,
39 stderr=subprocess.PIPE,
41 result = p.communicate()[0]
43 result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
44 if '-' in result: # not a tagged version
45 real_number, commit_count, commit_hash = result.split('-', 2)
46 version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
51 return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
55 class compile_translations(Command):
56 description = 'compile message catalogs to MO files via django compilemessages'
59 def initialize_options(self):
62 def finalize_options(self):
66 orig_dir = os.getcwd()
68 from django.core.management import call_command
70 for path, dirs, files in os.walk('chloro'):
71 if 'locale' not in dirs:
74 os.chdir(os.path.realpath(path))
75 call_command('compilemessages')
78 sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
82 class compile_scss(Command):
83 description = 'compile scss files into css files'
86 def initialize_options(self):
89 def finalize_options(self):
94 for program in ('sassc', 'sass'):
95 sass_bin = find_executable(program)
100 'A sass compiler is required but none was found. See sass-lang.com for choices.'
103 for path, dirnames, filenames in os.walk('chloro'):
104 for filename in filenames:
105 if not filename.endswith('.scss'):
107 if filename.startswith('_'):
109 subprocess.check_call(
112 '%s/%s' % (path, filename),
113 '%s/%s' % (path, filename.replace('.scss', '.css')),
119 sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
122 class install_lib(_install_lib):
124 self.run_command('compile_translations')
125 _install_lib.run(self)
130 version=get_version(),
131 description='Content Manager',
132 author='Frederic Peters',
133 author_email='fpeters@0d.be',
134 packages=find_packages(exclude=['tests']),
135 include_package_data=True,
136 scripts=('manage.py',),
138 'Development Status :: 4 - Beta',
139 'Environment :: Web Environment',
140 'Framework :: Django',
141 'Intended Audience :: Developers',
142 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
143 'Operating System :: OS Independent',
144 'Programming Language :: Python',
145 'Programming Language :: Python :: 3',
147 install_requires=['django>=1.11, <1.12', 'django-ckeditor<=4.5.3', 'django-taggit', 'gadjo'],
151 'compile_scss': compile_scss,
152 'compile_translations': compile_translations,
153 'install_lib': install_lib,