Tests for RPMDistribution
[zeroinstall/zeroinstall-rsl.git] / setup.py
blob08afb80fcca7b94379f27f703e1229c676b3c716
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
8 import zeroinstall
10 class build_with_data(build_py):
11 """Python < 2.4 doesn't support package_data_files, so add it manually."""
12 package_data_files = [
13 "zeroinstall/0launch-gui/README",
14 "zeroinstall/0launch-gui/0launch-gui",
15 "zeroinstall/0launch-gui/ZeroInstall-GUI.xml",
16 "zeroinstall/0launch-gui/zero-install.glade",
17 "zeroinstall/gtkui/desktop.glade",
18 "zeroinstall/gtkui/cache.glade",
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 # distutils doesn't seem to have any support for adding configuration files.
41 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
42 # menu definitions as configuration.
43 class my_install(install):
44 def finalize_options(self):
45 install.finalize_options(self) # super.finalize_options()
46 if self.home:
47 self.__config_dir = os.path.join(self.home, '.config')
48 elif self.prefix == '/usr':
49 self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
50 else:
51 self.__config_dir = os.path.join(self.prefix, 'etc/xdg')
53 def run(self):
54 install.run(self) # super.run()
55 menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
56 self.mkpath(menus_dir)
57 menu = convert_path('applications/zeroinstall.menu')
58 self.copy_file(menu, menus_dir)
60 setup(name="zeroinstall-injector",
61 version=zeroinstall.version,
62 description="The Zero Install Injector (0launch)",
63 author="Thomas Leonard",
64 author_email="zero-install-devel@lists.sourceforge.net",
65 url="http://0install.net",
66 scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
67 data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
68 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
69 ('share/desktop-directories', ['applications/zeroinstall.directory']),
70 ('share/pixmaps', ['applications/zeroinstall-zero2desktop.png'])],
71 license='LGPL',
72 cmdclass={
73 'build_py': build_with_data,
74 'install_lib': install_lib_exec,
75 'install': my_install,
77 long_description="""\
78 A running process is created by combining many different libraries (and other
79 components). In the Zero Install world, we have all versions of each library
80 available at all times. The problem then is how to choose which versions to
81 use.
83 The injector solves this problem by selecting components to meet a program's
84 requirements, according to a policy you give it. The injector finds out which
85 versions are available, and downloads and runs the ones you choose.""",
86 packages=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])