1 from distutils
.core
import setup
2 from distutils
.util
import convert_path
3 from distutils
.core
import Command
4 from distutils
.command
.build_py
import build_py
5 from distutils
.command
.install
import install
6 from distutils
.command
.install_lib
import install_lib
7 from distutils
.command
.install_data
import install_data
8 import os
, subprocess
, sys
12 class adjust_scripts_for_home(Command
):
13 """setup.py install --home puts libraries in ~/lib/python, but Python doesn't look there.
14 If we're installing with --home, modify the scripts to add this to sys.path.
15 Don't do this otherwise; the system copy mustn't conflict with the copy in $HOME.
17 description
= "(used internally when using --home)"
20 ('scripts-dir=', 'd', "directory to install scripts to"),
21 ('lib-dir=', 'd', "directory libraries install to"),
24 def initialize_options (self
):
25 self
.scripts_dir
= None
28 def finalize_options (self
):
29 self
.set_undefined_options('install',
30 ('install_scripts', 'scripts_dir'),
31 ('install_lib', 'lib_dir'),
35 for script
in self
.distribution
.scripts
:
36 outfile
= os
.path
.join(self
.scripts_dir
, os
.path
.basename(script
))
38 stream
= open(outfile
)
42 code
= code
.replace('## PATH ##', '''
44 sys.path.insert(0, %s)''' % repr(self
.lib_dir
))
45 stream
= open(outfile
, 'w')
49 class build_with_data(build_py
):
50 """Python < 2.4 doesn't support package_data_files, so add it manually."""
51 package_data_files
= [
52 "zeroinstall/0launch-gui/README",
53 "zeroinstall/0launch-gui/0launch-gui",
54 "zeroinstall/0launch-gui/zero-install.ui",
55 "zeroinstall/gtkui/desktop.ui",
56 "zeroinstall/gtkui/cache.ui",
57 "zeroinstall/zerostore/_unlzma",
60 # Copy .py files and build, as usual
63 for data_file
in self
.package_data_files
:
64 outfile
= os
.path
.join(self
.build_lib
, data_file
)
65 self
.copy_file(data_file
, outfile
, preserve_mode
=0)
66 executable
= (os
.stat(data_file
).st_mode
& 0111) != 0
68 os
.chmod(outfile
, os
.stat(outfile
).st_mode |
0111)
70 class install_lib_exec(install_lib
):
72 install_lib
.run(self
) # super.run()
73 if os
.name
!= 'posix': return
75 launch
= os
.path
.join(self
.install_dir
, 'zeroinstall/0launch-gui/0launch-gui')
76 os
.chmod(launch
, os
.stat(launch
).st_mode |
0111)
78 class install_data_locale(install_data
):
80 self
.data_files
.extend(self
._compile
_po
_files
())
81 install_data
.run(self
) # super.run()
83 def _compile_po_files(self
):
85 for mo
in glob
.glob("locale/*/LC_MESSAGES/zero-install.mo"):
86 dest
= os
.path
.dirname(os
.path
.join('share', mo
))
87 i18nfiles
.append((dest
, [mo
]))
90 # distutils doesn't seem to have any support for adding configuration files.
91 # Unfortunately, the freedesktop.org menu spec strangely defines part of the
92 # menu definitions as configuration.
93 class my_install(install
):
94 def finalize_options(self
):
95 install
.finalize_options(self
) # super.finalize_options()
97 self
.__config
_dir
= os
.path
.join(self
.home
, '.config')
98 elif self
.prefix
== '/usr':
99 self
.__config
_dir
= os
.path
.join(self
.root
or '/', 'etc/xdg')
101 self
.__config
_dir
= os
.path
.join(self
.root
or '/', self
.prefix
[1:], 'etc/xdg')
104 install
.run(self
) # super.run()
105 menus_dir
= os
.path
.join(self
.__config
_dir
, 'menus/applications-merged')
106 self
.mkpath(menus_dir
)
107 menu
= convert_path('applications/zeroinstall.menu')
108 self
.copy_file(menu
, menus_dir
)
111 self
.run_command('adjust_scripts_for_home')
113 setup(name
="zeroinstall-injector",
114 version
=zeroinstall
.version
,
115 description
="The Zero Install Injector (0launch)",
116 author
="Thomas Leonard",
117 author_email
="zero-install-devel@lists.sourceforge.net",
118 url
="http://0install.net",
119 scripts
=['0launch', '0alias', '0store', '0store-secure-add', '0desktop'],
120 data_files
= [('man/man1', ['0launch.1', '0alias.1', '0store-secure-add.1', '0store.1', '0desktop.1']),
121 ('share/applications', ['applications/zeroinstall-add.desktop', 'applications/zeroinstall-manage.desktop']),
122 ('share/desktop-directories', ['applications/zeroinstall.directory']),
123 ('share/icons/hicolor/24x24/apps', ['applications/24x24/zeroinstall.png']),
124 ('share/icons/hicolor/48x48/apps', ['applications/48x48/zeroinstall.png'])],
127 'build_py': build_with_data
,
128 'install_lib': install_lib_exec
,
129 'install_data': install_data_locale
,
130 'adjust_scripts_for_home': adjust_scripts_for_home
,
131 'install': my_install
,
133 long_description
="""\
134 A running process is created by combining many different libraries (and other
135 components). In the Zero Install world, we have all versions of each library
136 available at all times. The problem then is how to choose which versions to
139 The injector solves this problem by selecting components to meet a program's
140 requirements, according to a policy you give it. The injector finds out which
141 versions are available, and downloads and runs the ones you choose.""",
142 packages
=["zeroinstall", "zeroinstall.support", "zeroinstall.zerostore", "zeroinstall.injector", "zeroinstall.0launch-gui", "zeroinstall.gtkui"])