Skip to content

Commit

Permalink
Compile messages after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
rbas committed May 23, 2015
1 parent 61a9421 commit bf65b4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
2 changes: 1 addition & 1 deletion django_fiobank/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
VERSION = (0, 1, 1)
VERSION = (0, 1, 2)

__author__ = 'rbas'
__version__ = VERSION
Expand Down
40 changes: 10 additions & 30 deletions setup.py
Expand Up @@ -9,11 +9,7 @@
except ImportError:
from distutils.core import setup, find_packages # NOQA

from setuptools.command.install_lib import install_lib as _install_lib
from distutils.command.build import build as _build
from distutils.cmd import Command

from django.core.management.commands.compilemessages import Command
from setuptools.command.install import install

version = django_fiobank.__versionstr__

Expand All @@ -33,35 +29,20 @@ def read_file(filename):
return open(os.path.join(base_path, filename)).read()


class CompileTranslations(Command):
description = 'compile message catalogs to MO files via django ' \
'compilemessages'
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

class CompileTranslations(install):
"""Customized setuptools install command - prints a friendly greeting."""
def run(self):
curdir = os.getcwd()
os.chdir(os.path.realpath(os.path.dirname(django_fiobank.__file__)))
try:
Command.execute(stderr=sys.stderr)
except TypeError:
command = lambda cmd: subprocess.check_call(shlex.split(cmd))
command('django-admin.py compilemessages')

except TypeError as e:
raise e
pass
os.chdir(curdir)


class Build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands


class InstallLib(_install_lib):
def run(self):
self.run_command('compile_translations')
_install_lib.run(self)
install.run(self)

setup(
name='django_fiobank',
Expand All @@ -79,8 +60,7 @@ def run(self):
],
include_package_data=True,
package_data={'django_fiobank': ['locale/*/LC_MESSAGES/*']},
cmdclass={'build': Build, 'install_lib': InstallLib,
'compile_translations': CompileTranslations},
cmdclass={'install': CompileTranslations},
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down

0 comments on commit bf65b4a

Please sign in to comment.