1 #! /usr/bin/env python3
2 # -*- coding: utf-8 -*-
9 from setuptools.command.install_lib import install_lib as _install_lib
10 from distutils.command.build import build as _build
11 from distutils.command.sdist import sdist
12 from distutils.cmd import Command
13 from distutils.spawn import find_executable
14 from setuptools import setup, find_packages
17 class eo_sdist(sdist):
19 if os.path.exists('VERSION'):
21 version = get_version()
22 with open('VERSION', 'w') as fd:
25 if os.path.exists('VERSION'):
30 '''Use the VERSION, if absent generates a version with git describe, if not
31 tag exists, take 0.0- and add the length of the commit log.
33 if os.path.exists('VERSION'):
34 with open('VERSION', 'r') as v:
36 if os.path.exists('.git'):
38 ['git', 'describe', '--dirty=.dirty', '--match=v*'],
39 stdout=subprocess.PIPE,
40 stderr=subprocess.PIPE,
42 result = p.communicate()[0]
44 result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
45 if '-' in result: # not a tagged version
46 real_number, commit_count, commit_hash = result.split('-', 2)
47 version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
52 return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
56 class compile_translations(Command):
57 description = 'compile message catalogs to MO files via django compilemessages'
60 def initialize_options(self):
63 def finalize_options(self):
67 orig_dir = os.getcwd()
69 from django.core.management import call_command
71 for path, dirs, files in os.walk('chloro'):
72 if 'locale' not in dirs:
75 os.chdir(os.path.realpath(path))
76 call_command('compilemessages')
79 sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
83 class compile_scss(Command):
84 description = 'compile scss files into css files'
87 def initialize_options(self):
90 def finalize_options(self):
95 for program in ('sassc', 'sass'):
96 sass_bin = find_executable(program)
101 'A sass compiler is required but none was found. See sass-lang.com for choices.'
104 for path, dirnames, filenames in os.walk('chloro'):
105 for filename in filenames:
106 if not filename.endswith('.scss'):
108 if filename.startswith('_'):
110 subprocess.check_call(
113 '%s/%s' % (path, filename),
114 '%s/%s' % (path, filename.replace('.scss', '.css')),
120 sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
123 class install_lib(_install_lib):
125 self.run_command('compile_translations')
126 _install_lib.run(self)
131 version=get_version(),
132 description='Content Manager',
133 author='Frederic Peters',
134 author_email='fpeters@0d.be',
135 packages=find_packages(exclude=['tests']),
136 include_package_data=True,
137 scripts=('manage.py',),
139 'Development Status :: 4 - Beta',
140 'Environment :: Web Environment',
141 'Framework :: Django',
142 'Intended Audience :: Developers',
143 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
144 'Operating System :: OS Independent',
145 'Programming Language :: Python',
146 'Programming Language :: Python :: 3',
148 install_requires=['django>=1.11, <1.12', 'django-ckeditor<=4.5.3', 'django-taggit', 'gadjo'],
152 'compile_scss': compile_scss,
153 'compile_translations': compile_translations,
154 'install_lib': install_lib,