samedi 16 juillet 2016

How to compile *.po gettext translations in setup.py python script

Consider a python package that has multilanguage support (using gettext). How to compile *.po files to *.mo files on the fly when executing setup.py? I really don't want to distribute precompiled *.mo files.

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from distutils.core import setup

setup(
    name='tractorbeam',
    version='0.1.0',
    url='http://starfleet.org/tractorbeam/',
    description='Pull beer out of the fridge while sitting on the couch.',

    author='James T. Kirk',
    author_email= 'jkirk@starfleet.org',

    packages=['tractorbeam'],
    package_data={
        'tractorbeam': [
            'locale/*.po',
            'locale/*.mo',  # How to compile on the fly?
        ]
    },

    install_requires=[
        'requests'
    ]
)

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire