Added 0store audit
[zeroinstall.git] / setup.py
blob642e6a1abde9f07e0c17e1ba96a4e9718d85db98
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",
20 def run(self):
21 # Copy .py files and build, as usual
22 build_py.run(self)
23 # Copy data files
24 for data_file in self.package_data_files:
25 outfile = os.path.join(self.build_lib, data_file)
26 self.copy_file(data_file, outfile, preserve_mode=0)
27 executable = (os.stat(data_file).st_mode & 0111) != 0
28 if executable:
29 os.chmod(outfile, os.stat(outfile).st_mode | 0111)
31 class install_lib_exec(install_lib):
32 def run(self):
33 install_lib.run(self) # super.run()
34 if os.name != 'posix': return
36 launch = os.path.join(self.install_dir, 'zeroinstall/0launch-gui/0launch-gui')
37 os.chmod(launch, os.stat(launch).st_mode | 0111)
39 # distutils doesn't seem to have any support for adding configuration files.
40 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
41 # menu definitions as configuration.
42 class my_install(install):
43 def finalize_options(self):
44 install.finalize_options(self) # super.finalize_options()
45 if self.home:
46 self.__config_dir = os.path.join(self.home, '.config')
47 elif self.prefix == '/usr':
48 self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
49 else:
50 self.__config_dir = os.path.join(self.prefix, 'etc/xdg')
52 def run(self):
53 install.run(self) # super.run()
54 menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
55 self.mkpath(menus_dir)
56 menu = convert_path('applications/zeroinstall.menu')
57 self.copy_file(menu, menus_dir)
59 setup(name="zeroinstall-injector",
60 version=zeroinstall.version,
61 description="The Zero Install Injector (0launch)",
62 author="Thomas Leonard",
63 author_email="zero-install-devel@lists.sourceforge.net",
64 url="http://0install.net",
65 scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
66 data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
67 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
68 ('share/desktop-directories', ['applications/zeroinstall.directory']),
69 ('share/pixmaps', ['applications/zeroinstall-zero2desktop.png'])],
70 license='LGPL',
71 cmdclass={
72 'build_py': build_with_data,
73 'install_lib': install_lib_exec,
74 'install': my_install,
76 long_description="""\
77 A running process is created by combining many different libraries (and other
78 components). In the Zero Install world, we have all versions of each library
79 available at all times. The problem then is how to choose which versions to
80 use.
82 The injector solves this problem by selecting components to meet a program's
83 requirements, according to a policy you give it. The injector finds out which
84 versions are available, and downloads and runs the ones you choose.""",
85 packages=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])