Updated Swedish translation
[zeroinstall.git] / setup.py
blobbe2922ad840ce4b3253d8f9a1b0714449da594fa
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/zero-install.ui",
17 "zeroinstall/gtkui/desktop.ui",
18 "zeroinstall/gtkui/cache.ui",
19 "zeroinstall/zerostore/_unlzma",
21 def run(self):
22 # Copy .py files and build, as usual
23 build_py.run(self)
24 # Copy data files
25 for data_file in self.package_data_files:
26 outfile = os.path.join(self.build_lib, data_file)
27 self.copy_file(data_file, outfile, preserve_mode=0)
28 executable = (os.stat(data_file).st_mode & 0111) != 0
29 if executable:
30 os.chmod(outfile, os.stat(outfile).st_mode | 0111)
32 class install_lib_exec(install_lib):
33 def run(self):
34 install_lib.run(self) # super.run()
35 if os.name != 'posix': return
37 launch = os.path.join(self.install_dir, 'zeroinstall/0launch-gui/0launch-gui')
38 os.chmod(launch, os.stat(launch).st_mode | 0111)
40 class install_data_locale(install_data):
41 def run(self):
42 self.data_files.extend(self._compile_po_files())
43 install_data.run(self) # super.run()
45 def _compile_po_files(self):
46 i18nfiles = []
47 for mo in glob.glob("locale/*/LC_MESSAGES/zero-install.mo"):
48 dest = os.path.dirname(os.path.join('share', mo))
49 i18nfiles.append((dest, [mo]))
50 return i18nfiles
52 # distutils doesn't seem to have any support for adding configuration files.
53 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
54 # menu definitions as configuration.
55 class my_install(install):
56 def finalize_options(self):
57 install.finalize_options(self) # super.finalize_options()
58 if self.home:
59 self.__config_dir = os.path.join(self.home, '.config')
60 elif self.prefix == '/usr':
61 self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
62 else:
63 self.__config_dir = os.path.join(self.root or '/', self.prefix[1:], 'etc/xdg')
65 def run(self):
66 install.run(self) # super.run()
67 menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
68 self.mkpath(menus_dir)
69 menu = convert_path('applications/zeroinstall.menu')
70 self.copy_file(menu, menus_dir)
72 setup(name="zeroinstall-injector",
73 version=zeroinstall.version,
74 description="The Zero Install Injector (0launch)",
75 author="Thomas Leonard",
76 author_email="zero-install-devel@lists.sourceforge.net",
77 url="http://0install.net",
78 scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
79 data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
80 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
81 ('share/desktop-directories', ['applications/zeroinstall.directory']),
82 ('share/icons/hicolor/24x24/apps', ['applications/24x24/zeroinstall.png']),
83 ('share/icons/hicolor/48x48/apps', ['applications/48x48/zeroinstall.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"])