File: setup.py

package info (click to toggle)
zeroinstall-injector 0.49-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,948 kB
  • ctags: 1,650
  • sloc: python: 13,155; xml: 273; makefile: 64; sh: 64; ansic: 42
file content (99 lines) | stat: -rw-r--r-- 4,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from distutils.core import setup
from distutils.util import convert_path
from distutils.command.build_py import build_py
from distutils.command.install import install
from distutils.command.install_lib import install_lib
from distutils.command.install_data import install_data
import os, subprocess, sys
import glob
import zeroinstall

class build_with_data(build_py):
	"""Python < 2.4 doesn't support package_data_files, so add it manually."""
	package_data_files = [
		"zeroinstall/0launch-gui/README",
		"zeroinstall/0launch-gui/0launch-gui",
		"zeroinstall/0launch-gui/zero-install.ui",
		"zeroinstall/gtkui/desktop.ui",
		"zeroinstall/gtkui/cache.ui",
		"zeroinstall/zerostore/_unlzma",
	]
	def run(self):
		# Copy .py files and build, as usual
		build_py.run(self)
		# Copy data files
		for data_file in self.package_data_files:
			outfile = os.path.join(self.build_lib, data_file)
			self.copy_file(data_file, outfile, preserve_mode=0)
			executable = (os.stat(data_file).st_mode & 0111) != 0
			if executable:
				os.chmod(outfile, os.stat(outfile).st_mode | 0111)

class install_lib_exec(install_lib):
	def run(self):
		install_lib.run(self)	# super.run()
		if os.name != 'posix': return

		launch = os.path.join(self.install_dir, 'zeroinstall/0launch-gui/0launch-gui')
		os.chmod(launch, os.stat(launch).st_mode | 0111)

class install_data_locale(install_data):
	def run(self):
		self.data_files.extend(self._compile_po_files())
		install_data.run(self)	# super.run()

	def _compile_po_files(self):
		i18nfiles = []
		for mo in glob.glob("locale/*/LC_MESSAGES/zero-install.mo"):
			dest = os.path.dirname(os.path.join('share', mo))
			i18nfiles.append((dest, [mo]))
		return i18nfiles

# distutils doesn't seem to have any support for adding configuration files.
# Unfortunately, the freedesktop.org menu spec strangely defines part of the
# menu definitions as configuration.
class my_install(install):
	def finalize_options(self):
		install.finalize_options(self)	# super.finalize_options()
		if self.home:
			self.__config_dir = os.path.join(self.home, '.config')
		elif self.prefix == '/usr':
			self.__config_dir = os.path.join(self.root or '/', 'etc/xdg')
		else:
			self.__config_dir = os.path.join(self.root or '/', self.prefix[1:], 'etc/xdg')

	def run(self):
		install.run(self)	# super.run()
		menus_dir = os.path.join(self.__config_dir, 'menus/applications-merged')
		self.mkpath(menus_dir)
		menu = convert_path('applications/zeroinstall.menu')
		self.copy_file(menu, menus_dir)

setup(name="zeroinstall-injector",
      version=zeroinstall.version,
      description="The Zero Install Injector (0launch)",
      author="Thomas Leonard",
      author_email="zero-install-devel@lists.sourceforge.net",
      url="http://0install.net",
      scripts=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
      data_files = [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
		    ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
		    ('share/desktop-directories', ['applications/zeroinstall.directory']),
		    ('share/pixmaps', ['applications/zeroinstall-zero2desktop.png'])],
      license='LGPL',
      cmdclass={
	'build_py': build_with_data,
	'install_lib': install_lib_exec,
	'install_data': install_data_locale,
	'install': my_install,
      },
      long_description="""\
A running process is created by combining many different libraries (and other
components). In the Zero Install world, we have all versions of each library
available at all times. The problem then is how to choose which versions to
use.

The injector solves this problem by selecting components to meet a program's
requirements, according to a policy you give it. The injector finds out which
versions are available, and downloads and runs the ones you choose.""",
      packages=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])