More detailed bug reports about why no version could be selected
[zeroinstall/zeroinstall-rsl.git] / setup.py
blob3dd5ad9dff8db686e3b241069abfdf863364f79d
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
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 directory in glob.glob("locale/*/LC_MESSAGES"):
49 po = os.path.join(directory, 'zero-install.po')
50 mo = os.path.join(directory, 'zero-install.mo')
51 print 'compiling %s -> %s' % (po, mo)
52 if subprocess.call(['msgfmt', '-o', mo, po]) != 0:
53 raise 'Error while running msgfmt on %s' % directory
54 dest = os.path.dirname(os.path.join('share', mo))
55 i18nfiles.append((dest, [mo]))
56 return i18nfiles
58 # distutils doesn't seem to have any support for adding configuration files.
59 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
60 # menu definitions as configuration.
61 class my_install(install):
62 def finalize_options(self):
63 install.finalize_options(self) # super.finalize_options()
64 if self.home:
65 self.__config_dir = os.path.join(self.home, '.config')
66 elif self.prefix == '/usr':
67 self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
68 else:
69 self.__config_dir = os.path.join(self.root or '/', self.prefix[1:], 'etc/xdg')
71 def run(self):
72 install.run(self) # super.run()
73 menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
74 self.mkpath(menus_dir)
75 menu = convert_path('applications/zeroinstall.menu')
76 self.copy_file(menu, menus_dir)
78 setup(name="zeroinstall-injector",
79 version=zeroinstall.version,
80 description="The Zero Install Injector (0launch)",
81 author="Thomas Leonard",
82 author_email="zero-install-devel@lists.sourceforge.net",
83 url="http://0install.net",
84 scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
85 data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
86 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
87 ('share/desktop-directories', ['applications/zeroinstall.directory']),
88 ('share/pixmaps', ['applications/zeroinstall-zero2desktop.png'])],
89 license='LGPL',
90 cmdclass={
91 'build_py': build_with_data,
92 'install_lib': install_lib_exec,
93 'install_data': install_data_locale,
94 'install': my_install,
96 long_description="""\
97 A running process is created by combining many different libraries (and other
98 components). In the Zero Install world, we have all versions of each library
99 available at all times. The problem then is how to choose which versions to
100 use.
102 The injector solves this problem by selecting components to meet a program's
103 requirements, according to a policy you give it. The injector finds out which
104 versions are available, and downloads and runs the ones you choose.""",
105 packages=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])