setup.py :  » Installer » Zero-Install » zeroinstall-injector-0.47 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Installer » Zero Install 
Zero Install » zeroinstall injector 0.47 » setup.py
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"])
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.