Make changes to some strings to improve the i18n
[zeroinstall/zeroinstall-rsl.git] / setup.py
blob5f6d6d0c3bb1def4e8b9dd004e6117cd75b03ebb
1 from distutils.core import setup
2 from distutils.util import convert_path
3 from distutils.command.build_py import build_py
4 from distutils.command.install import install
5 from distutils.command.install_lib import install_lib
6 from distutils.command.install_data import install_data
7 import os, subprocess, sys
8 import glob
9 import zeroinstall
11 class build_with_data(build_py):
12 """Python < 2.4 doesn't support package_data_files, so add it manually."""
13 package_data_files = [
14 "zeroinstall/0launch-gui/README",
15 "zeroinstall/0launch-gui/0launch-gui",
16 "zeroinstall/0launch-gui/ZeroInstall-GUI.xml",
17 "zeroinstall/0launch-gui/zero-install.glade",
18 "zeroinstall/gtkui/desktop.glade",
19 "zeroinstall/gtkui/cache.glade",
20 "zeroinstall/zerostore/_unlzma",
22 def run(self):
23 # Copy .py files and build, as usual
24 build_py.run(self)
25 # Copy data files
26 for data_file in self.package_data_files:
27 outfile = os.path.join(self.build_lib, data_file)
28 self.copy_file(data_file, outfile, preserve_mode=0)
29 executable = (os.stat(data_file).st_mode & 0111) != 0
30 if executable:
31 os.chmod(outfile, os.stat(outfile).st_mode | 0111)
33 class install_lib_exec(install_lib):
34 def run(self):
35 install_lib.run(self) # super.run()
36 if os.name != 'posix': return
38 launch = os.path.join(self.install_dir, 'zeroinstall/0launch-gui/0launch-gui')
39 os.chmod(launch, os.stat(launch).st_mode | 0111)
41 class install_data_locale(install_data):
42 def run(self):
43 self.data_files.extend(self._compile_po_files())
44 install_data.run(self) # super.run()
46 def _compile_po_files(self):
47 i18nfiles = []
48 for mo in glob.glob("locale/*/LC_MESSAGES/zero-install.mo"):
49 dest = os.path.dirname(os.path.join('share', mo))
50 i18nfiles.append((dest, [mo]))
51 return i18nfiles
53 # distutils doesn't seem to have any support for adding configuration files.
54 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
55 # menu definitions as configuration.
56 class my_install(install):
57 def finalize_options(self):
58 install.finalize_options(self) # super.finalize_options()
59 if self.home:
60 self.__config_dir = os.path.join(self.home, '.config')
61 elif self.prefix == '/usr':
62 self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
63 else:
64 self.__config_dir = os.path.join(self.root or '/', self.prefix[1:], 'etc/xdg')
66 def run(self):
67 install.run(self) # super.run()
68 menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
69 self.mkpath(menus_dir)
70 menu = convert_path('applications/zeroinstall.menu')
71 self.copy_file(menu, menus_dir)
73 setup(name="zeroinstall-injector",
74 version=zeroinstall.version,
75 description="The Zero Install Injector (0launch)",
76 author="Thomas Leonard",
77 author_email="zero-install-devel@lists.sourceforge.net",
78 url="http://0install.net",
79 scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
80 data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
81 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
82 ('share/desktop-directories', ['applications/zeroinstall.directory']),
83 ('share/pixmaps', ['applications/zeroinstall-zero2desktop.png'])],
84 license='LGPL',
85 cmdclass={
86 'build_py': build_with_data,
87 'install_lib': install_lib_exec,
88 'install_data': install_data_locale,
89 'install': my_install,
91 long_description="""\
92 A running process is created by combining many different libraries (and other
93 components). In the Zero Install world, we have all versions of each library
94 available at all times. The problem then is how to choose which versions to
95 use.
97 The injector solves this problem by selecting components to meet a program's
98 requirements, according to a policy you give it. The injector finds out which
99 versions are available, and downloads and runs the ones you choose.""",
100 packages=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])