setup.py revision 2688
3177N/A#!/usr/bin/python2.6
20N/A#
20N/A# CDDL HEADER START
20N/A#
20N/A# The contents of this file are subject to the terms of the
20N/A# Common Development and Distribution License (the "License").
20N/A# You may not use this file except in compliance with the License.
20N/A#
20N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20N/A# or http://www.opensolaris.org/os/licensing.
20N/A# See the License for the specific language governing permissions
20N/A# and limitations under the License.
20N/A#
20N/A# When distributing Covered Code, include this CDDL HEADER in each
20N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20N/A# If applicable, add the following below this CDDL HEADER, with the
20N/A# fields enclosed by brackets "[]" replaced with your own identifying
20N/A# information: Portions Copyright [yyyy] [name of copyright owner]
20N/A#
20N/A# CDDL HEADER END
20N/A#
3339N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
20N/A#
20N/A
3143N/Aimport errno
3143N/Aimport fnmatch
22N/Aimport os
0N/Aimport platform
50N/Aimport stat
50N/Aimport sys
50N/Aimport shutil
50N/Aimport re
50N/Aimport subprocess
50N/Aimport tarfile
50N/Aimport tempfile
50N/Aimport urllib
50N/Aimport py_compile
50N/Aimport hashlib
50N/Aimport time
50N/A
50N/Afrom distutils.errors import DistutilsError, DistutilsFileError
50N/Afrom distutils.core import setup, Extension
589N/Afrom distutils.cmd import Command
589N/Afrom distutils.command.install import install as _install
965N/Afrom distutils.command.install_data import install_data as _install_data
965N/Afrom distutils.command.install_lib import install_lib as _install_lib
965N/Afrom distutils.command.build import build as _build
965N/Afrom distutils.command.build_ext import build_ext as _build_ext
965N/Afrom distutils.command.build_py import build_py as _build_py
2951N/Afrom distutils.command.bdist import bdist as _bdist
1836N/Afrom distutils.command.clean import clean as _clean
1836N/Afrom distutils.dist import Distribution
382N/Afrom distutils import log
812N/A
382N/Afrom distutils.sysconfig import get_python_inc
382N/Aimport distutils.dep_util as dep_util
382N/Aimport distutils.dir_util as dir_util
1963N/Aimport distutils.file_util as file_util
382N/Aimport distutils.util as util
1963N/Aimport distutils.ccompiler
382N/Afrom distutils.unixccompiler import UnixCCompiler
382N/A
382N/Aosname = platform.uname()[0].lower()
382N/Aostype = arch = 'unknown'
382N/Aif osname == 'sunos':
26N/A arch = platform.processor()
689N/A ostype = "posix"
689N/Aelif osname == 'linux':
466N/A arch = "linux_" + platform.machine()
0N/A ostype = "posix"
468N/Aelif osname == 'windows':
812N/A arch = osname
3273N/A ostype = "windows"
3274N/Aelif osname == 'darwin':
3274N/A arch = osname
812N/A ostype = "posix"
52N/Aelif osname == 'aix':
812N/A arch = "aix"
0N/A ostype = "posix"
3339N/A
3339N/Apwd = os.path.normpath(sys.path[0])
3339N/A
3339N/A#
3234N/A# Unbuffer stdout and stderr. This helps to ensure that subprocess output
3194N/A# is properly interleaved with output from this program.
382N/A#
382N/Asys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)
382N/Asys.stderr = os.fdopen(sys.stderr.fileno(), "w", 0)
3234N/A
3234N/Adist_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "dist_" + arch))
382N/Abuild_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "build_" + arch))
382N/Aif "ROOT" in os.environ and os.environ["ROOT"] != "":
3274N/A root_dir = os.environ["ROOT"]
3274N/Aelse:
382N/A root_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "root_" + arch))
22N/Apkgs_dir = os.path.normpath(os.path.join(pwd, os.pardir, "packages", arch))
1836N/Aextern_dir = os.path.normpath(os.path.join(pwd, "extern"))
2507N/A
3274N/Apy_install_dir = 'usr/lib/python2.6/vendor-packages'
1836N/A
1836N/Ascripts_dir = 'usr/bin'
2962N/Alib_dir = 'usr/lib'
2962N/Asvc_method_dir = 'lib/svc/method'
2962N/A
1431N/Aman1_dir = 'usr/share/man/man1'
1968N/Aman1m_dir = 'usr/share/man/man1m'
873N/Aman5_dir = 'usr/share/man/man5'
812N/Aman1_ja_JP_dir = 'usr/share/man/ja_JP.UTF-8/man1'
1431N/Aman1m_ja_JP_dir = 'usr/share/man/ja_JP.UTF-8/man1m'
1431N/Aman5_ja_JP_dir = 'usr/share/man/ja_JP.UTF-8/man5'
466N/Aman1_zh_CN_dir = 'usr/share/man/zh_CN.UTF-8/man1'
1431N/Aman1m_zh_CN_dir = 'usr/share/man/zh_CN.UTF-8/man1m'
3274N/Aman5_zh_CN_dir = 'usr/share/man/zh_CN.UTF-8/man5'
3274N/A
3274N/Aresource_dir = 'usr/share/lib/pkg'
3274N/Atransform_dir = 'usr/share/pkg/transforms'
3274N/Asmf_app_dir = 'lib/svc/manifest/application/pkg'
3274N/Aexecattrd_dir = 'etc/security/exec_attr.d'
3274N/Aauthattrd_dir = 'etc/security/auth_attr.d'
3274N/Asysrepo_dir = 'etc/pkg/sysrepo'
3274N/Asysrepo_logs_dir = 'var/log/pkg/sysrepo'
3274N/Asysrepo_cache_dir = 'var/cache/pkg/sysrepo'
3274N/Aautostart_dir = 'etc/xdg/autostart'
3274N/Adesktop_dir = 'usr/share/applications'
3274N/Agconf_dir = 'etc/gconf/schemas'
3274N/Ahelp_dir = 'usr/share/gnome/help/package-manager'
466N/Aomf_dir = 'usr/share/omf/package-manager'
466N/Astartpage_dir = 'usr/share/package-manager/data/startpagebase'
466N/Aum_lib_dir = 'usr/lib/update-manager'
23N/Aum_share_dir = 'usr/share/update-manager'
466N/Apm_share_dir = 'usr/share/package-manager'
466N/Alocale_dir = 'usr/share/locale'
466N/A
466N/A
466N/A# A list of source, destination tuples of modules which should be hardlinked
466N/A# together if the os supports it and otherwise copied.
466N/Ahardlink_modules = []
466N/A
1431N/Ascripts_sunos = {
1633N/A scripts_dir: [
1633N/A ['client.py', 'pkg'],
1633N/A ['pkgdep.py', 'pkgdepend'],
1633N/A ['pkgrepo.py', 'pkgrepo'],
466N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
466N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
466N/A ['util/publish/pkglint.py', 'pkglint'],
1633N/A ['util/publish/pkgmerge.py', 'pkgmerge'],
1633N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
1633N/A ['publish.py', 'pkgsend'],
1633N/A ['pull.py', 'pkgrecv'],
1633N/A ['sign.py', 'pkgsign'],
1633N/A ['packagemanager.py', 'packagemanager'],
3143N/A ['updatemanager.py', 'pm-updatemanager'],
2230N/A ],
1968N/A lib_dir: [
1633N/A ['depot.py', 'pkg.depotd'],
2515N/A ['checkforupdates.py', 'pm-checkforupdates'],
2816N/A ['updatemanagernotifier.py', 'updatemanagernotifier'],
2816N/A ['launch.py', 'pm-launch'],
1937N/A ['sysrepo.py', 'pkg.sysrepo'],
382N/A ],
2230N/A um_lib_dir: [
2230N/A ['um/update-refresh.sh', 'update-refresh.sh'],
2230N/A ],
2230N/A svc_method_dir: [
2028N/A ['svc/svc-pkg-depot', 'svc-pkg-depot'],
1968N/A ['svc/svc-pkg-mdns', 'svc-pkg-mdns'],
1968N/A ['svc/svc-pkg-sysrepo', 'svc-pkg-sysrepo'],
2028N/A ['um/pkg-update', 'pkg-update'],
1968N/A ],
1968N/A }
1968N/A
2028N/Ascripts_windows = {
2028N/A scripts_dir: [
2028N/A ['client.py', 'client.py'],
1968N/A ['pkgrepo.py', 'pkgrepo.py'],
1968N/A ['publish.py', 'publish.py'],
1968N/A ['pull.py', 'pull.py'],
1968N/A ['scripts/pkg.bat', 'pkg.bat'],
1968N/A ['scripts/pkgsend.bat', 'pkgsend.bat'],
1968N/A ['scripts/pkgrecv.bat', 'pkgrecv.bat'],
589N/A ],
589N/A lib_dir: [
589N/A ['depot.py', 'depot.py'],
589N/A ['scripts/pkg.depotd.bat', 'pkg.depotd.bat'],
1431N/A ],
1431N/A }
1431N/A
1431N/Ascripts_other_unix = {
1431N/A scripts_dir: [
858N/A ['client.py', 'client.py'],
1633N/A ['pkgdep.py', 'pkgdep'],
2962N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
3053N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
2515N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
2515N/A ['pull.py', 'pull.py'],
466N/A ['publish.py', 'publish.py'],
466N/A ['scripts/pkg.sh', 'pkg'],
466N/A ['scripts/pkgsend.sh', 'pkgsend'],
466N/A ['scripts/pkgrecv.sh', 'pkgrecv'],
466N/A ],
466N/A lib_dir: [
466N/A ['depot.py', 'depot.py'],
466N/A ['scripts/pkg.depotd.sh', 'pkg.depotd'],
466N/A ],
589N/A }
589N/A
589N/A# indexed by 'osname'
1191N/Ascripts = {
1191N/A "sunos": scripts_sunos,
1191N/A "linux": scripts_other_unix,
1191N/A "windows": scripts_windows,
1191N/A "darwin": scripts_other_unix,
2816N/A "aix" : scripts_other_unix,
2816N/A "unknown": scripts_sunos,
589N/A }
589N/A
589N/Aman1_files = [
589N/A 'man/packagemanager.1',
812N/A 'man/pkg.1',
812N/A 'man/pkgdepend.1',
812N/A 'man/pkgdiff.1',
812N/A 'man/pkgfmt.1',
812N/A 'man/pkglint.1',
812N/A 'man/pkgmerge.1',
812N/A 'man/pkgmogrify.1',
1968N/A 'man/pkgsend.1',
1968N/A 'man/pkgsign.1',
1968N/A 'man/pkgrecv.1',
812N/A 'man/pkgrepo.1',
812N/A 'man/pm-updatemanager.1',
812N/A ]
812N/Aman1m_files = [
1475N/A 'man/pkg.depotd.1m',
1475N/A 'man/pkg.sysrepo.1m'
1475N/A ]
1475N/Aman5_files = [
975N/A 'man/pkg.5'
975N/A ]
975N/A
975N/Aman1_ja_files = [
1633N/A 'man/ja_JP/packagemanager.1',
1633N/A 'man/ja_JP/pkg.1',
1633N/A 'man/ja_JP/pkgdepend.1',
1633N/A 'man/ja_JP/pkgdiff.1',
2028N/A 'man/ja_JP/pkgfmt.1',
1633N/A 'man/ja_JP/pkglint.1',
3143N/A 'man/ja_JP/pkgmerge.1',
1633N/A 'man/ja_JP/pkgmogrify.1',
14N/A 'man/ja_JP/pkgsend.1',
382N/A 'man/ja_JP/pkgsign.1',
429N/A 'man/ja_JP/pkgrecv.1',
14N/A 'man/ja_JP/pkgrepo.1',
404N/A 'man/ja_JP/pm-updatemanager.1',
404N/A ]
30N/Aman1m_ja_files = [
382N/A 'man/ja_JP/pkg.depotd.1m',
30N/A 'man/ja_JP/pkg.sysrepo.1m'
791N/A ]
2728N/Aman5_ja_files = [
2728N/A 'man/ja_JP/pkg.5'
689N/A ]
1968N/A
1968N/Aman1_zh_CN_files = [
1968N/A 'man/zh_CN/packagemanager.1',
1968N/A 'man/zh_CN/pkg.1',
1191N/A 'man/zh_CN/pkgdepend.1',
258N/A 'man/zh_CN/pkgdiff.1',
1968N/A 'man/zh_CN/pkgfmt.1',
2816N/A 'man/zh_CN/pkglint.1',
382N/A 'man/zh_CN/pkgmerge.1',
1968N/A 'man/zh_CN/pkgmogrify.1',
30N/A 'man/zh_CN/pkgsend.1',
589N/A 'man/zh_CN/pkgsign.1',
589N/A 'man/zh_CN/pkgrecv.1',
1968N/A 'man/zh_CN/pkgrepo.1',
589N/A 'man/zh_CN/pm-updatemanager.1',
589N/A ]
589N/Aman1m_zh_CN_files = [
589N/A 'man/zh_CN/pkg.depotd.1m',
1968N/A 'man/zh_CN/pkg.sysrepo.1m'
589N/A ]
1968N/Aman5_zh_CN_files = [
466N/A 'man/zh_CN/pkg.5'
466N/A ]
2230N/A
1968N/Apackages = [
1968N/A 'pkg',
1431N/A 'pkg.actions',
1968N/A 'pkg.bundle',
1968N/A 'pkg.client',
54N/A 'pkg.client.linkedimage',
1968N/A 'pkg.client.transport',
1968N/A 'pkg.file_layout',
2515N/A 'pkg.flavor',
2816N/A 'pkg.gui',
2816N/A 'pkg.lint',
2816N/A 'pkg.portable',
2816N/A 'pkg.publish',
1475N/A 'pkg.server'
2230N/A ]
466N/A
1633N/Apylint_targets = [
1633N/A 'pkg.altroot',
135N/A 'pkg.client.linkedimage',
2230N/A 'pkg.client.pkgdefs',
2230N/A ]
2230N/A
135N/Aweb_files = []
135N/Afor entry in os.walk("web"):
1968N/A web_dir, dirs, files = entry
135N/A if not files:
1968N/A continue
382N/A web_files.append((os.path.join(resource_dir, web_dir), [
382N/A os.path.join(web_dir, f) for f in files
382N/A if f != "Makefile"
3194N/A ]))
3158N/A # install same set of files in "en/" in "__LOCALE__/ as well"
3194N/A # for localizable file package (regarding themes, install
382N/A # theme "oracle.com" only)
3194N/A if os.path.basename(web_dir) == "en" and \
3158N/A os.path.dirname(web_dir) in ("web", "web/_themes/oracle.com"):
3194N/A web_files.append((os.path.join(resource_dir,
1968N/A os.path.dirname(web_dir), "__LOCALE__"), [
382N/A os.path.join(web_dir, f) for f in files
1968N/A if f != "Makefile"
1542N/A ]))
1542N/A
1968N/Asmf_app_files = [
1968N/A 'svc/pkg-mdns.xml',
812N/A 'svc/pkg-server.xml',
1968N/A 'svc/pkg-update.xml',
589N/A 'svc/pkg-system-repository.xml',
1968N/A 'svc/zoneproxy-client.xml',
858N/A 'svc/zoneproxyd.xml'
858N/A ]
1968N/Aresource_files = [
858N/A 'util/opensolaris.org.sections',
858N/A 'util/pkglintrc',
858N/A ]
858N/Atransform_files = [
858N/A 'util/publish/transforms/developer',
858N/A 'util/publish/transforms/documentation',
858N/A 'util/publish/transforms/locale',
1968N/A 'util/publish/transforms/smf-manifests'
2962N/A ]
2962N/Asysrepo_files = [
2962N/A 'util/apache2/sysrepo/sysrepo_p5p.py',
2962N/A 'util/apache2/sysrepo/sysrepo_httpd.conf.mako',
2962N/A 'util/apache2/sysrepo/sysrepo_publisher_response.mako',
2962N/A ]
2962N/Asysrepo_log_stubs = [
2962N/A 'util/apache2/sysrepo/logs/access_log',
2962N/A 'util/apache2/sysrepo/logs/error_log',
2962N/A ]
1431N/Aexecattrd_files = [
1431N/A 'util/misc/exec_attr.d/package:pkg',
3194N/A 'util/misc/exec_attr.d/package:pkg:package-manager'
3194N/A]
1431N/Aauthattrd_files = ['util/misc/auth_attr.d/package:pkg']
1431N/Aautostart_files = [
1431N/A 'um/data/updatemanagernotifier.desktop',
1431N/A]
1431N/Adesktop_files = [
1431N/A 'gui/data/addmoresoftware.desktop',
1431N/A 'gui/data/packagemanager.desktop',
1431N/A 'um/data/updatemanager.desktop',
1431N/A]
1431N/Agconf_files = [
1431N/A 'gui/data/packagemanager-preferences.schemas',
1431N/A 'um/data/updatemanager-preferences.schemas',
1431N/A]
3158N/Aintl_files = [
1968N/A 'gui/data/addmoresoftware.desktop.in',
1542N/A 'gui/data/packagemanager-info.xml.in',
1542N/A 'gui/data/packagemanager-preferences.schemas.in',
2515N/A 'gui/data/packagemanager.desktop.in',
2515N/A 'um/data/updatemanager-preferences.schemas.in',
1968N/A 'um/data/updatemanager.desktop.in',
3158N/A 'um/data/updatemanagernotifier.desktop.in',
1968N/A]
1633N/Ahelp_locales = \
1633N/A 'C ar ca cs de es fr hu id it ja ko pl pt_BR ru sv zh_CN zh_HK zh_TW'.split()
589N/Ahelp_files = {
1968N/A 'C': ['gui/help/C/package-manager.xml'],
1902N/A 'C/figures': [
1968N/A 'gui/help/C/figures/%s.png' % n
1968N/A for n in 'pkgmgr-main startpage_new update_all_new webinstall'.split()
1968N/A ]
1191N/A}
2816N/Ahelp_files.update(
2816N/A (locale, ['gui/help/%s/package-manager.xml' % locale])
2816N/A for locale in help_locales[1:]
3194N/A)
3194N/A# add package-manager-__LOCALE__.omf for localizable file package
3194N/Aomf_files = [
1191N/A 'gui/help/package-manager-%s.omf' % locale
2816N/A for locale in help_locales + [ "__LOCALE__" ]
2816N/A]
2816N/Astartpage_locales = \
2816N/A 'C ar ca cs de es fr hu id it ja ko nl pt_BR ru sv zh_CN zh_HK zh_TW'.split()
2816N/Astartpage_files = {
589N/A 'C': [
589N/A 'gui/data/startpagebase/C/%s.png' % n
589N/A for n in [
589N/A 'dialog-information', 'dialog-warning', 'hc_dialog-information',
589N/A 'hc_dialog-warning', 'hc_install', 'hc_opensolaris',
589N/A 'hci_dialog-information', 'hci_dialog-warning', 'hci_install',
3234N/A 'hci_opensolaris', 'install', 'opensolaris'
765N/A ]
765N/A ] + ['gui/data/startpagebase/C/startpage.html']
765N/A}
3194N/Astartpage_files.update(
3194N/A (locale, ['gui/data/startpagebase/%s/startpage.html' % locale])
3194N/A for locale in startpage_locales[1:]
3194N/A)
589N/Apkg_locales = \
765N/A 'ar ca cs de es fr he hu id it ja ko nl pl pt_BR ru sk sv zh_CN zh_HK zh_TW'.split()
765N/A
3194N/Asyscallat_srcs = [
3194N/A 'modules/syscallat.c'
3194N/A ]
765N/Apspawn_srcs = [
765N/A 'modules/pspawn.c'
1968N/A ]
3234N/Aelf_srcs = [
1968N/A 'modules/elf.c',
135N/A 'modules/elfextract.c',
1968N/A 'modules/liblist.c',
157N/A ]
382N/Aarch_srcs = [
429N/A 'modules/arch.c'
429N/A ]
2028N/A_actions_srcs = [
2028N/A 'modules/actions/_actions.c'
429N/A ]
429N/A_actcomm_srcs = [
429N/A 'modules/actions/_common.c'
429N/A ]
429N/A_varcet_srcs = [
429N/A 'modules/_varcet.c'
429N/A ]
2028N/Asolver_srcs = [
1968N/A 'modules/solver/solver.c',
1968N/A 'modules/solver/py_solver.c'
1968N/A ]
1968N/Asolver_link_args = ["-lm", "-lc"]
1968N/Aif osname == 'sunos':
1968N/A solver_link_args = ["-ztext"] + solver_link_args
1968N/A
1968N/A# Runs lint on the extension module source code
1968N/Aclass pylint_func(Command):
1968N/A description = "Runs pylint tools over IPS python source code"
812N/A user_options = []
1968N/A
1968N/A def initialize_options(self):
1968N/A pass
1968N/A
1968N/A def finalize_options(self):
3194N/A pass
3194N/A
3194N/A # Make string shell-friendly
1968N/A @staticmethod
3194N/A def escape(astring):
3194N/A return astring.replace(' ', '\\ ')
1968N/A
3194N/A def run(self, quiet=False):
3194N/A proto = os.path.join(root_dir, py_install_dir)
1968N/A sys.path.insert(0, proto)
812N/A
1968N/A # Insert tests directory onto sys.path so any custom checkers
1968N/A # can be found.
1968N/A sys.path.insert(0, os.path.join(pwd, 'tests'))
1968N/A # assumes pylint is accessible on the sys.path
1968N/A from pylint import lint
3194N/A
3194N/A #
3194N/A # For some reason, the load-plugins option, when used in the
1968N/A # rcfile, does not work, so we put it here instead, to load
3194N/A # our custom checkers.
3194N/A #
1968N/A # Unfortunately, pylint seems pretty fragile and will crash if
3194N/A # we try to run it over all the current pkg source. Hence for
3194N/A # now we only run it over a subset of the source. As source
1968N/A # files are made pylint clean they should be added to the
812N/A # pylint_targets list.
1968N/A #
1968N/A args = ['--load-plugins=multiplatform']
812N/A if quiet:
1968N/A args += ['--reports=no']
3194N/A args += ['--rcfile', os.path.join(pwd, 'tests', 'pylintrc')]
3194N/A args += pylint_targets
3194N/A lint.Run(args)
3194N/A
812N/A
1968N/Aclass pylint_func_quiet(pylint_func):
812N/A
812N/A def run(self, quiet=False):
873N/A pylint_func.run(self, quiet=True)
873N/A
873N/A
3194N/Ainclude_dirs = [ 'modules' ]
3194N/Alint_flags = [ '-u', '-axms', '-erroff=E_NAME_DEF_NOT_USED2' ]
3194N/A
3194N/A# Runs lint on the extension module source code
812N/Aclass clint_func(Command):
1968N/A description = "Runs lint tools over IPS C extension source code"
812N/A user_options = []
812N/A
3194N/A def initialize_options(self):
3194N/A pass
3194N/A
1968N/A def finalize_options(self):
1475N/A pass
1968N/A
975N/A # Make string shell-friendly
1968N/A @staticmethod
1968N/A def escape(astring):
1968N/A return astring.replace(' ', '\\ ')
1968N/A
1968N/A def run(self):
1968N/A if "LINT" in os.environ and os.environ["LINT"] != "":
1968N/A lint = [os.environ["LINT"]]
2230N/A else:
2230N/A lint = ['lint']
1968N/A if osname == 'sunos' or osname == "linux":
2962N/A archcmd = lint + lint_flags + \
2962N/A ['-D_FILE_OFFSET_BITS=64'] + \
2962N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1968N/A ['-I' + self.escape(get_python_inc())] + \
1968N/A arch_srcs
3171N/A elfcmd = lint + lint_flags + \
3158N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
3171N/A ['-I' + self.escape(get_python_inc())] + \
3158N/A ["%s%s" % ("-l", k) for k in elf_libraries] + \
3171N/A elf_srcs
3158N/A _actionscmd = lint + lint_flags + \
382N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
3158N/A ['-I' + self.escape(get_python_inc())] + \
3158N/A _actions_srcs
451N/A _actcommcmd = lint + lint_flags + \
1633N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1633N/A ['-I' + self.escape(get_python_inc())] + \
1633N/A _actcomm_srcs
1968N/A _varcetcmd = lint + lint_flags + \
1968N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1968N/A ['-I' + self.escape(get_python_inc())] + \
1968N/A _varcet_srcs
1968N/A pspawncmd = lint + lint_flags + \
1968N/A ['-D_FILE_OFFSET_BITS=64'] + \
1968N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1968N/A ['-I' + self.escape(get_python_inc())] + \
1968N/A pspawn_srcs
1968N/A syscallatcmd = lint + lint_flags + \
1968N/A ['-D_FILE_OFFSET_BITS=64'] + \
1968N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
2515N/A ['-I' + self.escape(get_python_inc())] + \
2515N/A syscallat_srcs
1968N/A
2230N/A print(" ".join(archcmd))
1968N/A os.system(" ".join(archcmd))
1968N/A print(" ".join(elfcmd))
1542N/A os.system(" ".join(elfcmd))
1542N/A print(" ".join(_actionscmd))
445N/A os.system(" ".join(_actionscmd))
466N/A print(" ".join(_actcommcmd))
1542N/A os.system(" ".join(_actcommcmd))
1633N/A print(" ".join(_varcetcmd))
1633N/A os.system(" ".join(_varcetcmd))
1020N/A print(" ".join(pspawncmd))
1020N/A os.system(" ".join(pspawncmd))
1020N/A print(" ".join(syscallatcmd))
1020N/A os.system(" ".join(syscallatcmd))
1020N/A
2515N/A
2515N/A# Runs both C and Python lint
2515N/Aclass lint_func(Command):
2515N/A description = "Runs C and Python lint checkers"
2515N/A user_options = []
2515N/A
2515N/A def initialize_options(self):
2515N/A pass
2515N/A
2515N/A def finalize_options(self):
2515N/A pass
451N/A
1968N/A # Make string shell-friendly
2230N/A @staticmethod
2230N/A def escape(astring):
2230N/A return astring.replace(' ', '\\ ')
2230N/A
2230N/A def run(self):
2230N/A clint_func(Distribution()).run()
2230N/A pylint_func(Distribution()).run()
2230N/A
2230N/Aclass install_func(_install):
2230N/A def initialize_options(self):
2515N/A _install.initialize_options(self)
2515N/A
1902N/A # PRIVATE_BUILD set in the environment tells us to put the build
1968N/A # directory into the .pyc files, rather than the final
1968N/A # installation directory.
1968N/A private_build = os.getenv("PRIVATE_BUILD", None)
1968N/A
1968N/A if private_build is None:
1968N/A self.install_lib = py_install_dir
1968N/A self.install_data = os.path.sep
1968N/A self.root = root_dir
812N/A else:
812N/A self.install_lib = os.path.join(root_dir, py_install_dir)
812N/A self.install_data = root_dir
812N/A
1968N/A # This is used when installing scripts, below, but it isn't a
1968N/A # standard distutils variable.
1968N/A self.root_dir = root_dir
1968N/A
1968N/A def run(self):
1968N/A """At the end of the install function, we need to rename some
1968N/A files because distutils provides no way to rename files as they
1968N/A are placed in their install locations.
1968N/A """
1968N/A
1968N/A _install.run(self)
1968N/A
1968N/A for o_src, o_dest in hardlink_modules:
1968N/A for e in [".py", ".pyc"]:
1968N/A src = util.change_root(self.root_dir, o_src + e)
1968N/A dest = util.change_root(
1968N/A self.root_dir, o_dest + e)
812N/A if ostype == "posix":
429N/A if os.path.exists(dest) and \
429N/A os.stat(src)[stat.ST_INO] != \
2028N/A os.stat(dest)[stat.ST_INO]:
1836N/A os.remove(dest)
2230N/A file_util.copy_file(src, dest,
3171N/A link="hard", update=1)
1836N/A else:
3158N/A file_util.copy_file(src, dest, update=1)
429N/A
612N/A for d, files in scripts[osname].iteritems():
1542N/A for (srcname, dstname) in files:
1968N/A dst_dir = util.change_root(self.root_dir, d)
1968N/A dst_path = util.change_root(self.root_dir,
1968N/A os.path.join(d, dstname))
1968N/A dir_util.mkpath(dst_dir, verbose=True)
1968N/A file_util.copy_file(srcname, dst_path, update=True)
1968N/A # make scripts executable
1968N/A os.chmod(dst_path,
1968N/A os.stat(dst_path).st_mode
1968N/A | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
1968N/A
1968N/Aclass install_lib_func(_install_lib):
1968N/A """Remove the target files prior to the standard install_lib procedure
1968N/A if the build_py module has determined that they've actually changed.
1968N/A This may be needed when a module's timestamp goes backwards in time, if
1968N/A a working-directory change is reverted, or an older changeset is checked
1968N/A out.
1968N/A """
1968N/A
1968N/A def install(self):
1968N/A build_py = self.get_finalized_command("build_py")
1968N/A prefix_len = len(self.build_dir) + 1
1968N/A for p in build_py.copied:
1968N/A id_p = os.path.join(self.install_dir, p[prefix_len:])
1968N/A rm_f(id_p)
1968N/A if self.compile:
1968N/A rm_f(id_p + "c")
1968N/A if self.optimize > 0:
1968N/A rm_f(id_p + "o")
1968N/A return _install_lib.install(self)
1968N/A
1968N/Aclass install_data_func(_install_data):
1968N/A """Enhance the standard install_data subcommand to take not only a list
1968N/A of filenames, but a list of source and destination filename tuples, for
812N/A the cases where a filename needs to be renamed between the two
1968N/A locations."""
2028N/A
812N/A def run(self):
812N/A self.mkpath(self.install_dir)
812N/A for f in self.data_files:
812N/A dir, files = f
812N/A dir = util.convert_path(dir)
3273N/A if not os.path.isabs(dir):
3273N/A dir = os.path.join(self.install_dir, dir)
3273N/A elif self.root:
3273N/A dir = change_root(self.root, dir)
3273N/A self.mkpath(dir)
812N/A
812N/A if not files:
812N/A self.outfiles.append(dir)
3171N/A else:
1836N/A for file in files:
3158N/A if isinstance(file, basestring):
1836N/A infile = file
3158N/A outfile = os.path.join(dir,
3158N/A os.path.basename(file))
812N/A else:
3339N/A infile, outfile = file
812N/A infile = util.convert_path(infile)
812N/A outfile = util.convert_path(outfile)
1968N/A if os.path.sep not in outfile:
1968N/A outfile = os.path.join(dir,
1968N/A outfile)
3158N/A self.copy_file(infile, outfile)
1968N/A self.outfiles.append(outfile)
1968N/A
1968N/A # Don't bother making this generic for the one symlink.
1968N/A src = "HighContrastInverse"
1968N/A dst = os.path.join(self.install_dir, pm_share_dir,
1968N/A "icons/HighContrastLargePrintInverse")
1968N/A try:
1968N/A targ = os.readlink(dst)
812N/A except OSError, e:
3158N/A if e.errno in (errno.ENOENT, errno.EINVAL):
812N/A targ = None
812N/A else:
812N/A raise
812N/A
812N/A if src != targ:
3234N/A log.info("linking %s -> %s" % (src, dst))
1968N/A rm_f(dst)
1968N/A os.symlink(src, dst)
1968N/A
812N/Adef run_cmd(args, swdir, updenv=None, ignerr=False):
3339N/A if updenv:
3339N/A # use temp environment modified with the given dict
812N/A env = os.environ.copy()
812N/A env.update(updenv)
812N/A else:
3171N/A # just use environment of this (parent) process as is
1836N/A env = os.environ
3158N/A if ignerr:
812N/A # send stderr to devnull
3171N/A stderr = open(os.devnull)
1836N/A else:
1836N/A # just use stderr of this (parent) process
3158N/A stderr = None
812N/A ret = subprocess.Popen(args, cwd=swdir, env=env,
812N/A stderr=stderr).wait()
812N/A if ret != 0:
3339N/A if stderr:
812N/A stderr.close()
452N/A print >> sys.stderr, \
466N/A "install failed and returned %d." % ret
858N/A print >> sys.stderr, \
382N/A "Command was: %s" % " ".join(args)
466N/A sys.exit(1)
965N/A if stderr:
858N/A stderr.close()
2230N/A
382N/Adef _copy_file_contents(src, dst, buffer_size=16*1024):
858N/A """A clone of distutils.file_util._copy_file_contents() that strips the
858N/A CDDL text. For Python files, we replace the CDDL text with an equal
858N/A number of empty comment lines so that line numbers match between the
382N/A source and destination files."""
742N/A
3339N/A # Match the lines between and including the CDDL header signposts, as
3339N/A # well as empty comment lines before and after, if they exist.
466N/A cddl_re = re.compile("\n(#\s*\n)?^[^\n]*CDDL HEADER START.+"
466N/A "CDDL HEADER END[^\n]*$(\n#\s*$)?", re.MULTILINE|re.DOTALL)
1968N/A
858N/A with file(src, "r") as sfp:
858N/A try:
858N/A os.unlink(dst)
858N/A except EnvironmentError, e:
858N/A if e.errno != errno.ENOENT:
858N/A raise DistutilsFileError("could not delete "
858N/A "'%s': %s" % (dst, e))
858N/A
858N/A with file(dst, "w") as dfp:
858N/A while True:
858N/A buf = sfp.read(buffer_size)
2992N/A if not buf:
2992N/A break
2992N/A if src.endswith(".py"):
2992N/A match = cddl_re.search(buf)
2992N/A if match:
2992N/A # replace the CDDL expression
2992N/A # with the same number of empty
2992N/A # comment lines as the cddl_re
2992N/A # matched.
2992N/A substr = buf[
2992N/A match.start():match.end()]
2992N/A count = len(
2992N/A substr.split("\n")) - 2
3158N/A blanks = "#\n" * count
3158N/A buf = cddl_re.sub("\n" + blanks,
2992N/A buf)
3158N/A else:
3158N/A buf = cddl_re.sub("", buf)
2992N/A dfp.write(buf)
2992N/A
2992N/A# Make file_util use our version of _copy_file_contents
2992N/Afile_util._copy_file_contents = _copy_file_contents
3158N/A
3158N/Adef intltool_update_maintain():
2992N/A """Check if scope of localization looks up-to-date or possibly not,
3158N/A by comparing file set described in po/POTFILES.{in,skip} and
3158N/A actual source files (e.g. .py) detected.
2992N/A """
2992N/A rm_f("po/missing")
2992N/A rm_f("po/notexist")
466N/A
466N/A args = [
466N/A "/usr/bin/intltool-update", "--maintain"
466N/A ]
466N/A print " ".join(args)
466N/A podir = os.path.join(os.getcwd(), "po")
466N/A run_cmd(args, podir, updenv={"LC_ALL": "C"}, ignerr=True)
466N/A
466N/A if os.path.exists("po/missing"):
466N/A print >> sys.stderr, \
466N/A "New file(s) with translatable strings detected:"
466N/A missing = open("po/missing", "r")
2992N/A print >> sys.stderr, "--------"
466N/A for fn in missing:
466N/A print >> sys.stderr, "%s" % fn.strip()
466N/A print >> sys.stderr, "--------"
466N/A missing.close()
3158N/A print >> sys.stderr, \
3158N/A"""Please evaluate whether any of the above file(s) needs localization.
466N/AIf so, please add its name to po/POTFILES.in. If not (e.g., it's not
466N/Adelivered), please add its name to po/POTFILES.skip.
466N/APlease be sure to maintain alphabetical ordering in both files."""
3158N/A sys.exit(1)
3158N/A
466N/A if os.path.exists("po/notexist"):
466N/A print >> sys.stderr, \
466N/A"""The following files are listed in po/POTFILES.in, but no longer exist
466N/Ain the workspace:"""
1968N/A notexist = open("po/notexist", "r")
1968N/A print >> sys.stderr, "--------"
1968N/A for fn in notexist:
466N/A print >> sys.stderr, "%s" % fn.strip()
382N/A print >> sys.stderr, "--------"
612N/A notexist.close()
612N/A print >> sys.stderr, \
612N/A "Please remove the file names from po/POTFILES.in"
612N/A sys.exit(1)
1431N/A
1431N/Adef intltool_update_pot():
2028N/A """Generate pkg.pot by extracting localizable strings from source
2028N/A files (e.g. .py)
2028N/A """
2028N/A rm_f("po/pkg.pot")
2028N/A
2028N/A args = [
2028N/A "/usr/bin/intltool-update", "--pot"
3171N/A ]
3158N/A print " ".join(args)
2028N/A podir = os.path.join(os.getcwd(), "po")
2028N/A run_cmd(args, podir,
1431N/A updenv={"LC_ALL": "C", "XGETTEXT": "/usr/gnu/bin/xgettext"})
1968N/A
1968N/A if not os.path.exists("po/pkg.pot"):
1968N/A print >> sys.stderr, \
2028N/A "Failed in generating pkg.pot."
2515N/A sys.exit(1)
2515N/A
2515N/Adef intltool_merge(src, dst):
1431N/A if not dep_util.newer(src, dst):
3171N/A return
3158N/A
1431N/A args = [
3171N/A "/usr/bin/intltool-merge", "-d", "-u",
3158N/A "-c", "po/.intltool-merge-cache", "po", src, dst
1672N/A ]
3171N/A print " ".join(args)
3158N/A run_cmd(args, os.getcwd(), updenv={"LC_ALL": "C"})
1431N/A
1431N/Adef msgfmt(src, dst):
2028N/A if not dep_util.newer(src, dst):
2028N/A return
2028N/A
2028N/A args = ["/usr/bin/msgfmt", "-o", dst, src]
2028N/A print " ".join(args)
2028N/A run_cmd(args, os.getcwd())
612N/A
617N/Adef localizablexml(src, dst):
2065N/A """create XML help for localization, where French part of legalnotice
2065N/A is stripped off
2065N/A """
2065N/A if not dep_util.newer(src, dst):
2028N/A return
2028N/A
3171N/A fsrc = open(src, "r")
2028N/A fdst = open(dst, "w")
2028N/A
2028N/A # indicates currently in French part of legalnotice
2028N/A in_fr = False
2028N/A
3171N/A for l in fsrc:
1431N/A if in_fr: # in French part
1431N/A if l.startswith('</legalnotice>'):
975N/A # reached end of legalnotice
1779N/A print >> fdst, l,
3171N/A in_fr = False
1431N/A elif l.startswith('<para lang="fr"/>') or \
617N/A l.startswith('<para lang="fr"></para>'):
1542N/A in_fr = True
1542N/A else:
1542N/A # not in French part
2028N/A print >> fdst, l,
3171N/A
1542N/A fsrc.close()
1542N/A fdst.close()
1542N/A
1779N/Adef xml2po_gen(src, dst):
3171N/A """Input is English XML file. Output is pkg_help.pot, message
1542N/A source for next translation update.
1542N/A """
1542N/A if not dep_util.newer(src, dst):
2028N/A return
1542N/A
1542N/A args = ["/usr/bin/xml2po", "-o", dst, src]
1542N/A print " ".join(args)
1431N/A run_cmd(args, os.getcwd())
1431N/A
1968N/Adef xml2po_merge(src, dst, mofile):
1431N/A """Input is English XML file and <lang>.po file (which contains
1968N/A translations). Output is translated XML file.
612N/A """
451N/A msgfmt(mofile[:-3] + ".po", mofile)
382N/A
3274N/A monewer = dep_util.newer(mofile, dst)
382N/A srcnewer = dep_util.newer(src, dst)
382N/A
1431N/A if not srcnewer and not monewer:
382N/A return
382N/A
382N/A args = ["/usr/bin/xml2po", "-t", mofile, "-o", dst, src]
3274N/A print " ".join(args)
3274N/A run_cmd(args, os.getcwd())
145N/A
1968N/Aclass installfile(Command):
451N/A user_options = [
451N/A ("file=", "f", "source file to copy"),
451N/A ("dest=", "d", "destination directory"),
451N/A ("mode=", "m", "file mode"),
451N/A ]
451N/A
451N/A description = "De-CDDLing file copy"
451N/A
451N/A def initialize_options(self):
451N/A self.file = None
451N/A self.dest = None
451N/A self.mode = None
451N/A
451N/A def finalize_options(self):
451N/A if self.mode is None:
451N/A self.mode = 0644
451N/A elif isinstance(self.mode, basestring):
451N/A try:
1902N/A self.mode = int(self.mode, 8)
2230N/A except ValueError:
1902N/A self.mode = 0644
2065N/A
2065N/A def run(self):
2065N/A dest_file = os.path.join(self.dest, os.path.basename(self.file))
2065N/A ret = self.copy_file(self.file, dest_file)
2065N/A
2065N/A os.chmod(dest_file, self.mode)
2065N/A os.utime(dest_file, None)
2507N/A
2507N/A return ret
2507N/A
2507N/Aclass build_func(_build):
2992N/A sub_commands = _build.sub_commands + [('build_data', None)]
2992N/A
2992N/A def initialize_options(self):
2507N/A _build.initialize_options(self)
814N/A self.build_base = build_dir
1431N/A
466N/Adef get_hg_version():
3171N/A try:
812N/A p = subprocess.Popen(['hg', 'id', '-i'], stdout = subprocess.PIPE)
812N/A return p.communicate()[0].strip()
873N/A except OSError:
812N/A print >> sys.stderr, "ERROR: unable to obtain mercurial version"
return "unknown"
def syntax_check(filename):
""" Run python's compiler over the file, and discard the results.
Arrange to generate an exception if the file does not compile.
This is needed because distutil's own use of pycompile (in the
distutils.utils module) is broken, and doesn't stop on error. """
try:
py_compile.compile(filename, os.devnull, doraise=True)
except py_compile.PyCompileError, e:
res = ""
for err in e.exc_value:
if isinstance(err, basestring):
res += err + "\n"
continue
# Assume it's a tuple of (filename, lineno, col, code)
fname, line, col, code = err
res += "line %d, column %s, in %s:\n%s" % (line,
col or "unknown", fname, code)
raise DistutilsError(res)
# On Solaris, ld inserts the full argument to the -o option into the symbol
# table. This means that the resulting object will be different depending on
# the path at which the workspace lives, and not just on the interesting content
# of the object.
#
# In order to work around that bug (7076871), we create a new compiler class
# that looks at the argument indicating the output file, chdirs to its
# directory, and runs the real link with the output file set to just the base
# name of the file.
#
# Unfortunately, distutils isn't too customizable in this regard, so we have to
# twiddle with a couple of the names in the distutils.ccompiler namespace: we
# have to add a new entry to the compiler_class dict, and we have to override
# the new_compiler() function to point to our own. Luckily, our copy of
# new_compiler() gets to be very simple, since we always know what we want to
# return.
class MyUnixCCompiler(UnixCCompiler):
def link(self, *args, **kwargs):
output_filename = args[2]
output_dir = kwargs.get('output_dir')
cwd = os.getcwd()
assert(not output_dir)
output_dir = os.path.join(cwd, os.path.dirname(output_filename))
output_filename = os.path.basename(output_filename)
nargs = args[:2] + (output_filename,) + args[3:]
if not os.path.exists(output_dir):
os.mkdir(output_dir, 0755)
os.chdir(output_dir)
UnixCCompiler.link(self, *nargs, **kwargs)
os.chdir(cwd)
distutils.ccompiler.compiler_class['myunix'] = (
'unixccompiler', 'MyUnixCCompiler',
'standard Unix-style compiler with a link stage modified for Solaris'
)
def my_new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
return MyUnixCCompiler(None, dry_run, force)
if osname == 'sunos':
distutils.ccompiler.new_compiler = my_new_compiler
class build_ext_func(_build_ext):
def initialize_options(self):
_build_ext.initialize_options(self)
self.build64 = False
if osname == 'sunos':
self.compiler = 'myunix'
def build_extension(self, ext):
# Build 32-bit
log.info("building 32-bit extension")
_build_ext.build_extension(self, ext)
# Set up for 64-bit
old_build_temp = self.build_temp
d, f = os.path.split(self.build_temp)
# store our 64-bit extensions elsewhere
self.build_temp = d + "/temp64.%s" % \
os.path.basename(self.build_temp).replace("temp.", "")
ext.extra_compile_args += ["-m64"]
ext.extra_link_args += ["-m64"]
self.build64 = True
# Build 64-bit
log.info("building 64-bit extension")
_build_ext.build_extension(self, ext)
# Reset to 32-bit
self.build_temp = old_build_temp
ext.extra_compile_args.remove("-m64")
ext.extra_link_args.remove("-m64")
self.build64 = False
def get_ext_fullpath(self, ext_name):
path = _build_ext.get_ext_fullpath(self, ext_name)
if not self.build64:
return path
dpath, fpath = os.path.split(path)
return os.path.join(dpath, "64", fpath)
class build_py_func(_build_py):
def __init__(self, dist):
ret = _build_py.__init__(self, dist)
self.copied = []
# Gather the timestamps of the .py files in the gate, so we can
# force the mtimes of the built and delivered copies to be
# consistent across builds, causing their corresponding .pyc
# files to be unchanged unless the .py file content changed.
self.timestamps = {}
p = subprocess.Popen(
[sys.executable, os.path.join(pwd, "pydates")],
stdout=subprocess.PIPE)
for line in p.stdout:
stamp, path = line.split()
stamp = float(stamp)
self.timestamps[path] = stamp
if p.wait() != 0:
print >> sys.stderr, "ERROR: unable to gather .py " \
"timestamps"
sys.exit(1)
return ret
# override the build_module method to do VERSION substitution on
# pkg/__init__.py
def build_module (self, module, module_file, package):
if module == "__init__" and package == "pkg":
versionre = '(?m)^VERSION[^"]*"([^"]*)"'
# Grab the previously-built version out of the build
# tree.
try:
ocontent = \
file(self.get_module_outfile(self.build_lib,
[package], module)).read()
ov = re.search(versionre, ocontent).group(1)
except IOError:
ov = None
v = get_hg_version()
vstr = 'VERSION = "%s"' % v
# If the versions haven't changed, there's no need to
# recompile.
if v == ov:
return
mcontent = file(module_file).read()
mcontent = re.sub(versionre, vstr, mcontent)
tmpfd, tmp_file = tempfile.mkstemp()
os.write(tmpfd, mcontent)
os.close(tmpfd)
print "doing version substitution: ", v
rv = _build_py.build_module(self, module, tmp_file, package)
os.unlink(tmp_file)
return rv
# Will raise a DistutilsError on failure.
syntax_check(module_file)
return _build_py.build_module(self, module, module_file, package)
def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1,
link=None, level=1):
# If the timestamp on the source file (coming from mercurial if
# unchanged, or from the filesystem if changed) doesn't match
# the filesystem timestamp on the destination, then force the
# copy to make sure the right data is in place.
try:
dst_mtime = os.stat(outfile).st_mtime
except OSError, e:
if e.errno != errno.ENOENT:
raise
dst_mtime = time.time()
# The timestamp for __init__.py is the timestamp for the
# workspace itself.
if outfile.endswith("/pkg/__init__.py"):
src_mtime = self.timestamps["."]
else:
src_mtime = self.timestamps.get(
os.path.join("src", infile), self.timestamps["."])
# Force a copy of the file if the source timestamp is different
# from that of the destination, not just if it's newer. This
# allows timestamps in the working directory to regress (for
# instance, following the reversion of a change).
if dst_mtime != src_mtime:
f = self.force
self.force = True
dst, copied = _build_py.copy_file(self, infile, outfile,
preserve_mode, preserve_times, link, level)
self.force = f
else:
dst, copied = outfile, 0
# If we copied the file, then we need to go and readjust the
# timestamp on the file to match what we have in our database.
# Save the filename aside for our version of install_lib.
if copied and dst.endswith(".py"):
os.utime(dst, (src_mtime, src_mtime))
self.copied.append(dst)
return dst, copied
class build_data_func(Command):
description = "build data files whose source isn't in deliverable form"
user_options = []
# As a subclass of distutils.cmd.Command, these methods are required to
# be implemented.
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# Anything that gets created here should get deleted in
# clean_func.run() below.
for f in intl_files:
intltool_merge(f, f[:-3])
for l in help_locales:
path = "gui/help/%s/" % l
xml2po_merge(path + "package-manager.xml.in",
path + "package-manager.xml",
path + "%s.mo" % l)
# create xml for localization
localizablexml("gui/help/C/package-manager.xml",
"gui/help/C/package-manager.localizable.xml")
# generate pkg_help.pot for next translation
xml2po_gen("gui/help/C/package-manager.localizable.xml",
"gui/help/C/pkg_help.pot")
for l in pkg_locales:
msgfmt("po/%s.po" % l, "po/%s.mo" % l)
# generate pkg.pot for next translation
intltool_update_maintain()
intltool_update_pot()
# create __LOCALE__ -> C symlink for omf file
# to make installation with data_files list work
locomf="gui/help/package-manager-__LOCALE__.omf"
if not os.path.exists(locomf):
os.symlink("package-manager-C.omf", locomf)
def rm_f(filepath):
"""Remove a file without caring whether it exists."""
try:
os.unlink(filepath)
except OSError, e:
if e.errno != errno.ENOENT:
raise
class clean_func(_clean):
def initialize_options(self):
_clean.initialize_options(self)
self.build_base = build_dir
def run(self):
_clean.run(self)
rm_f("po/.intltool-merge-cache")
for f in intl_files:
rm_f(f[:-3])
for l in pkg_locales:
rm_f("po/%s.mo" % l)
rm_f("po/pkg.pot")
for l in help_locales:
path = "gui/help/%s/" % l
rm_f(path + "package-manager.xml")
rm_f(path + "%s.mo" % l)
rm_f("gui/help/C/pkg_help.pot")
rm_f("gui/help/package-manager-__LOCALE__.omf")
class clobber_func(Command):
user_options = []
description = "Deletes any and all files created by setup"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# nuke everything
print("deleting " + dist_dir)
shutil.rmtree(dist_dir, True)
print("deleting " + build_dir)
shutil.rmtree(build_dir, True)
print("deleting " + root_dir)
shutil.rmtree(root_dir, True)
print("deleting " + pkgs_dir)
shutil.rmtree(pkgs_dir, True)
print("deleting " + extern_dir)
shutil.rmtree(extern_dir, True)
class test_func(Command):
# NOTE: these options need to be in sync with tests/run.py and the
# list of options stored in initialize_options below. The first entry
# in each tuple must be the exact name of a member variable.
user_options = [
("archivedir=", 'a', "archive failed tests <dir>"),
("baselinefile=", 'b', "baseline file <file>"),
("coverage", "c", "collect code coverage data"),
("genbaseline", 'g', "generate test baseline"),
("only=", "o", "only <regex>"),
("parseable", 'p', "parseable output"),
("port=", "z", "lowest port to start a depot on"),
("timing", "t", "timing file <file>"),
("verbosemode", 'v', "run tests in verbose mode"),
("enableguitests", 'u', "enable IPS GUI tests, disabled by default"),
("stoponerr", 'x', "stop when a baseline mismatch occurs"),
("debugoutput", 'd', "emit debugging output"),
("showonexpectedfail", 'f',
"show all failure info, even for expected fails"),
("startattest=", 's', "start at indicated test"),
("jobs=", 'j', "number of parallel processes to use"),
("quiet", "q", "use the dots as the output format"),
]
description = "Runs unit and functional tests"
def initialize_options(self):
self.only = ""
self.baselinefile = ""
self.verbosemode = 0
self.parseable = 0
self.genbaseline = 0
self.timing = 0
self.coverage = 0
self.stoponerr = 0
self.debugoutput = 0
self.showonexpectedfail = 0
self.startattest = ""
self.archivedir = ""
self.port = 12001
self.jobs = 1
self.quiet = False
def finalize_options(self):
pass
def run(self):
os.putenv('PYEXE', sys.executable)
os.chdir(os.path.join(pwd, "tests"))
# Reconstruct the cmdline and send that to run.py
cmd = [sys.executable, "run.py"]
args = ""
if "test" in sys.argv:
args = sys.argv[sys.argv.index("test")+1:]
cmd.extend(args)
subprocess.call(cmd)
class dist_func(_bdist):
def initialize_options(self):
_bdist.initialize_options(self)
self.dist_dir = dist_dir
# These are set to real values based on the platform, down below
compile_args = None
if osname in ("sunos", "linux", "darwin"):
compile_args = [ "-O3" ]
if osname == "sunos":
link_args = [ "-zstrip-class=nonalloc" ]
else:
link_args = []
ext_modules = [
Extension(
'actions._actions',
_actions_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args
),
Extension(
'actions._common',
_actcomm_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args
),
Extension(
'_varcet',
_varcet_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args
),
Extension(
'solver',
solver_srcs,
include_dirs = include_dirs + ["."],
extra_compile_args = compile_args,
extra_link_args = link_args + solver_link_args,
define_macros = [('_FILE_OFFSET_BITS', '64')]
),
]
elf_libraries = None
data_files = web_files
cmdclasses = {
'install': install_func,
'install_data': install_data_func,
'install_lib': install_lib_func,
'build': build_func,
'build_data': build_data_func,
'build_ext': build_ext_func,
'build_py': build_py_func,
'bdist': dist_func,
'lint': lint_func,
'clint': clint_func,
'pylint': pylint_func,
'pylint_quiet': pylint_func_quiet,
'clean': clean_func,
'clobber': clobber_func,
'test': test_func,
'installfile': installfile,
}
# all builds of IPS should have manpages
data_files += [
(man1_dir, man1_files),
(man1m_dir, man1m_files),
(man5_dir, man5_files),
(man1_ja_JP_dir, man1_ja_files),
(man1m_ja_JP_dir, man1m_ja_files),
(man5_ja_JP_dir, man5_ja_files),
(man1_zh_CN_dir, man1_zh_CN_files),
(man1m_zh_CN_dir, man1m_zh_CN_files),
(man5_zh_CN_dir, man5_zh_CN_files),
(resource_dir, resource_files),
]
# add transforms
data_files += [
(transform_dir, transform_files)
]
if osname == 'sunos':
# Solaris-specific extensions are added here
data_files += [
(smf_app_dir, smf_app_files),
(execattrd_dir, execattrd_files),
(authattrd_dir, authattrd_files),
(sysrepo_dir, sysrepo_files),
(sysrepo_logs_dir, sysrepo_log_stubs),
(sysrepo_cache_dir, {}),
(autostart_dir, autostart_files),
(desktop_dir, desktop_files),
(gconf_dir, gconf_files),
(omf_dir, omf_files),
('usr/share/icons/hicolor/48x48/mimetypes',
['gui/data/gnome-mime-application-vnd.pkg5.info.png']),
('usr/share/mime/packages', ['gui/data/packagemanager-info.xml']),
(pm_share_dir, ['gui/data/packagemanager.ui']),
]
data_files += [
(os.path.join(startpage_dir, locale), files)
for locale, files in startpage_files.iteritems()
]
data_files += [
(os.path.join(help_dir, locale), files)
for locale, files in help_files.iteritems()
]
# install localizable .xml and its .pot file to put into localizable file package
data_files += [
(os.path.join(help_dir, '__LOCALE__'),
[('gui/help/C/package-manager.localizable.xml', 'package-manager.xml'),
('gui/help/C/pkg_help.pot', 'pkg_help.pot')])
]
data_files += [
(os.path.join(locale_dir, locale, 'LC_MESSAGES'),
[('po/%s.mo' % locale, 'pkg.mo')])
for locale in pkg_locales
]
# install English .pot file to put into localizable file package
data_files += [
(os.path.join(locale_dir, '__LOCALE__', 'LC_MESSAGES'),
[('po/pkg.pot', 'pkg.pot')])
]
for t in 'HighContrast', 'HighContrastInverse', '':
for px in '24', '36', '48':
data_files += [(
'%s/icons/%s/%sx%s/actions' % (um_share_dir, t or 'hicolor', px, px),
['um/data/icons/%s/%sx%s/updatemanager.png' % (t, px, px)]
)]
data_files += [(
'%s/icons/%s/16x16/actions' % (pm_share_dir, t or 'hicolor'),
[
'gui/data/icons/%s/16x16/%s.png' % (t, n)
for n in ('filter_all', 'filter_selected', 'progress_checkmark',
'selection', 'status_checkmark', 'status_installed',
'status_newupdate', 'status_notinstalled')
]
)]
data_files += [
('%s/icons/%s/%sx%s/actions' % (pm_share_dir, t or 'hicolor', px, px),
[
'gui/data/icons/%s/%sx%s/%s.png' % (t, px, px, n)
for n in ('pm-install_update', 'pm-refresh',
'pm-remove', 'pm-update_all')
])
for px in (24, 48)
]
data_files += [(
'%s/icons/%s/48x48/actions' % (pm_share_dir, t or 'hicolor'),
['gui/data/icons/%s/48x48/packagemanager.png' % t]
)]
data_files += [
('usr/share/icons/%s/48x48/apps' % (t or 'hicolor'),
[
'um/data/icons/%s/48x48/updatemanager.png' % t,
'gui/data/icons/%s/48x48/packagemanager.png' % t
]),
]
# These two icons don't fit any patterns.
data_files += [
(os.path.join(pm_share_dir, 'icons/hicolor/16x16/actions'), [
'gui/data/icons/16x16/progress_blank.png']),
(os.path.join(pm_share_dir, 'icons/hicolor/24x24/actions'), [
'gui/data/icons/24x24/pm-check.png']),
]
if osname == 'sunos' or osname == "linux":
# Unix platforms which the elf extension has been ported to
# are specified here, so they are built automatically
elf_libraries = ['elf']
ext_modules += [
Extension(
'elf',
elf_srcs,
include_dirs = include_dirs,
libraries = elf_libraries,
extra_compile_args = compile_args,
extra_link_args = link_args
),
]
# Solaris has built-in md library and Solaris-specific arch extension
# All others use OpenSSL and cross-platform arch module
if osname == 'sunos':
elf_libraries += [ 'md' ]
ext_modules += [
Extension(
'arch',
arch_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args,
define_macros = [('_FILE_OFFSET_BITS', '64')]
),
Extension(
'pspawn',
pspawn_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args,
define_macros = [('_FILE_OFFSET_BITS', '64')]
),
Extension(
'syscallat',
syscallat_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args,
define_macros = [('_FILE_OFFSET_BITS', '64')]
),
]
else:
elf_libraries += [ 'ssl' ]
setup(cmdclass = cmdclasses,
name = 'pkg',
version = '0.1',
package_dir = {'pkg':'modules'},
packages = packages,
data_files = data_files,
ext_package = 'pkg',
ext_modules = ext_modules,
)
# We don't support 64-bit yet, but 64-bit _actions.so, _common.so and _varcet.so
# are needed for a system repository mod_wsgi application, sysrepo_p5p.py.
# Remove the others.
remove_libs = ["arch.so",
"elf.so",
"pspawn.so",
"solver.so",
"syscallat.so"
]
pkg_64_path = os.path.join(root_dir, "usr/lib/python2.6/vendor-packages/pkg/64")
for lib in remove_libs:
rm_path = os.path.join(pkg_64_path, lib)
if os.path.exists(rm_path):
log.info("Removing unnecessary 64-bit library: %s" % lib)
os.unlink(rm_path)