diff --git a/moulinette/package.py.in b/moulinette/package.py.in index a72b5486..f4f113e5 100644 --- a/moulinette/package.py.in +++ b/moulinette/package.py.in @@ -3,13 +3,13 @@ # Public constants defined during build """Package's data directory (e.g. /usr/share/moulinette)""" -datadir = %PKGDATADIR% +datadir = '%PKGDATADIR%' """Package's library directory (e.g. /usr/lib/moulinette)""" -libdir = %PKGLIBDIR% +libdir = '%PKGLIBDIR%' -"""Locale directory for the package (e.g. /usr/lib/moulinette/locale)""" -localedir = %PKGLOCALEDIR% +"""Locale directory for the package (e.g. /usr/share/moulinette/locale)""" +localedir = '%PKGLOCALEDIR%' """Cache directory for the package (e.g. /var/cache/moulinette)""" -cachedir = %PKGCACHEDIR% +cachedir = '%PKGCACHEDIR%' diff --git a/setup.py b/setup.py new file mode 100755 index 00000000..0f632a5e --- /dev/null +++ b/setup.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +import os +import sys + +from distutils.core import setup +from distutils.dir_util import mkpath +from distutils.sysconfig import PREFIX + +# Define package directories +datadir = os.path.join(PREFIX, 'share/moulinette') +libdir = os.path.join(PREFIX, 'lib/moulinette') +localedir = os.path.join(datadir, 'locale') +cachedir = '/var/cache/moulinette' + +# Extend installation +locale_files = [] +if "install" in sys.argv: + # Evaluate locale files + for f in os.listdir('locales'): + if f.endswith('.json'): + locale_files.append('locales/%s' % f) + + # Generate package.py + package = open('moulinette/package.py.in').read() + package = package.replace('%PKGDATADIR%', datadir) \ + .replace('%PKGLIBDIR%', libdir) \ + .replace('%PKGLOCALEDIR%', localedir) \ + .replace('%PKGCACHEDIR%', cachedir) + with open('moulinette/package.py', 'w') as f: + f.write(package) + + # Create needed directories + mkpath(libdir, mode=0755, verbose=1) + mkpath(os.path.join(datadir, 'actionsmap'), mode=0755, verbose=1) + + +setup(name='Moulinette', + version='2.0.0', + description='', + author='Yunohost Team', + author_email='yunohost@yunohost.org', + url='http://yunohost.org', + license='AGPL', + packages=['moulinette', + 'moulinette.authenticators', + 'moulinette.interfaces'], + data_files=[(localedir, locale_files)] + )