setup.py revision 2345
1516N/A#!/usr/bin/python2.6
290N/A#
290N/A# CDDL HEADER START
290N/A#
290N/A# The contents of this file are subject to the terms of the
290N/A# Common Development and Distribution License (the "License").
290N/A# You may not use this file except in compliance with the License.
290N/A#
290N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
290N/A# or http://www.opensolaris.org/os/licensing.
290N/A# See the License for the specific language governing permissions
290N/A# and limitations under the License.
290N/A#
290N/A# When distributing Covered Code, include this CDDL HEADER in each
290N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
290N/A# If applicable, add the following below this CDDL HEADER, with the
290N/A# fields enclosed by brackets "[]" replaced with your own identifying
290N/A# information: Portions Copyright [yyyy] [name of copyright owner]
290N/A#
290N/A# CDDL HEADER END
290N/A#
2223N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
395N/A#
290N/A
883N/Aimport errno
454N/Aimport fnmatch
290N/Aimport os
448N/Aimport platform
290N/Aimport stat
290N/Aimport sys
290N/Aimport shutil
383N/Aimport re
290N/Aimport subprocess
395N/Aimport tarfile
290N/Aimport tempfile
395N/Aimport urllib
849N/Aimport py_compile
1516N/Aimport hashlib
290N/A
849N/Afrom distutils.errors import DistutilsError
290N/Afrom distutils.core import setup, Extension
290N/Afrom distutils.cmd import Command
290N/Afrom distutils.command.install import install as _install
290N/Afrom distutils.command.build import build as _build
383N/Afrom distutils.command.build_py import build_py as _build_py
290N/Afrom distutils.command.bdist import bdist as _bdist
290N/Afrom distutils.command.clean import clean as _clean
290N/Afrom distutils.dist import Distribution
290N/A
290N/Afrom distutils.sysconfig import get_python_inc
290N/Aimport distutils.file_util as file_util
290N/Aimport distutils.dir_util as dir_util
290N/Aimport distutils.util as util
1660N/A
1660N/Aosname = platform.uname()[0].lower()
1660N/Aostype = arch = 'unknown'
1660N/Aif osname == 'sunos':
1660N/A arch = platform.processor()
1660N/A ostype = "posix"
1660N/Aelif osname == 'linux':
1660N/A arch = "linux_" + platform.machine()
1660N/A ostype = "posix"
1660N/Aelif osname == 'windows':
1660N/A arch = osname
1660N/A ostype = "windows"
1660N/Aelif osname == 'darwin':
1660N/A arch = osname
1660N/A ostype = "posix"
1660N/Aelif osname == 'aix':
1660N/A arch = "aix"
1660N/A ostype = "posix"
465N/A
465N/A# 3rd party software required for the build
465N/ACP = 'CherryPy'
1516N/ACPIDIR = 'cherrypy'
465N/ACPVER = '3.1.2'
465N/ACPARC = '%s-%s.tar.gz' % (CP, CPVER)
465N/ACPDIR = '%s-%s' % (CP, CPVER)
1516N/ACPURL = 'http://download.cherrypy.org/cherrypy/%s/%s' % (CPVER, CPARC)
465N/ACPHASH = 'a94aedfd0e675858dbcc32dd250c23d285ee9b88'
465N/A
465N/APO = 'pyOpenSSL'
465N/APOIDIR = 'OpenSSL'
465N/APOVER = '0.7'
465N/APOARC = '%s-%s.tar.gz' % (PO, POVER)
465N/APODIR = '%s-%s' % (PO, POVER)
1099N/APOURL = 'http://downloads.sourceforge.net/pyopenssl/%s' % (POARC)
465N/APOHASH = 'bd072fef8eb36241852d25a9161282a051f0a63e'
1513N/A
1513N/ACOV = 'coveragepy'
2075N/ACOVIDIR = 'coverage'
2180N/ACOVVER = '3.2b2'
2075N/ACOVPVER = '3.2'
2075N/ACOVARC = '%s-%s.tar.gz' % (COVIDIR, COVVER)
2075N/ACOVDIR = '%s-%s' % (COVIDIR, COVVER)
2075N/ACOVURL = 'http://pypi.python.org/packages/source/c/coverage/%s' % COVARC
708N/ACOVHASH = '4710d033b8c6de1efaa562243e5b29e0a31fb8b9'
1391N/A
1391N/ALDTP = 'ldtp'
1391N/ALDTPIDIR = 'ldtp'
1391N/ALDTPVER = '1.7.1'
1391N/ALDTPMINORVER = '1.7.x'
1391N/ALDTPMAJORVER = '1.x'
1391N/ALDTPARC = '%s-%s.tar.gz' % (LDTP, LDTPVER)
1391N/ALDTPDIR = '%s-%s' % (LDTP, LDTPVER)
1391N/ALDTPURL = 'http://download.freedesktop.org/ldtp/%s/%s/%s' % \
1391N/A (LDTPMAJORVER, LDTPMINORVER, LDTPARC)
1391N/ALDTPHASH = 'd31213d2b1449a0dadcace723b9ff7041169f7ce'
742N/A
742N/AMAKO = 'Mako'
742N/AMAKOIDIR = 'mako'
742N/AMAKOVER = '0.2.2'
742N/AMAKOARC = '%s-%s.tar.gz' % (MAKO, MAKOVER)
742N/AMAKODIR = '%s-%s' % (MAKO, MAKOVER)
1099N/AMAKOURL = 'http://www.makotemplates.org/downloads/%s' % (MAKOARC)
742N/AMAKOHASH = '85c04ab3a6a26a1cab47067449712d15a8b29790'
941N/A
941N/APLY = 'ply'
941N/APLYIDIR = 'ply'
941N/APLYVER = '3.1'
941N/APLYARC = '%s-%s.tar.gz' % (PLY, PLYVER)
941N/APLYDIR = '%s-%s' % (PLY, PLYVER)
1099N/APLYURL = 'http://www.dabeaz.com/ply/%s' % (PLYARC)
941N/APLYHASH = '38efe9e03bc39d40ee73fa566eb9c1975f1a8003'
2023N/A
2023N/APBJ = 'pybonjour'
2023N/APBJIDIR = 'pybonjour'
2023N/APBJVER = '1.1.1'
2023N/APBJARC = '%s-%s.tar.gz' % (PBJ, PBJVER)
2023N/APBJDIR = '%s-%s' % (PBJ, PBJVER)
2023N/APBJURL = 'http://pybonjour.googlecode.com/files/%s' % (PBJARC)
2023N/APBJHASH = '92cabd14e04c5f62ce067c47c2057ee3d424d29b'
1191N/A
1513N/APC = 'pycurl'
1191N/APCIDIR = 'curl'
2180N/APCVER = '7.19.0'
1191N/APCPVER= '7.19.0.1'
1191N/APCARC = '%s-%s.tar.gz' % (PC, PCVER)
1191N/APCDIR = '%s-%s' % (PC, PCVER)
1191N/APCURL = 'http://pycurl.sourceforge.net/download/%s' % PCARC
1660N/APCHASH = '3fb59eca1461331bb9e9e8d6fe3b23eda961a416'
1660N/APCENVIRON = {}
1660N/Aif osname in ("sunos", "linux", "darwin"):
290N/A PCENVIRON = {'CFLAGS': '-O3'}
2026N/A
2026N/AM2C = 'M2Crypto'
2263N/AM2CIDIR = 'm2crypto'
2026N/AM2CVER = '0.21.1'
2026N/AM2CARC = '%s-%s.tar.gz' % (M2C, M2CVER)
2026N/AM2CDIR = '%s-%s' % (M2C, M2CVER)
2263N/AM2CURL = 'http://pypi.python.org/packages/source/M/M2Crypto/%s' % (M2CARC)
2026N/AM2CHASH = '3c7135b952092e4f2eee7a94c5153319cccba94e'
448N/A
448N/Apwd = os.path.normpath(sys.path[0])
534N/A
534N/A#
534N/A# Unbuffer stdout and stderr. This helps to ensure that subprocess output
534N/A# is properly interleaved with output from this program.
534N/A#
534N/Asys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)
534N/Asys.stderr = os.fdopen(sys.stderr.fileno(), "w", 0)
290N/A
290N/Adist_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "dist_" + arch))
954N/Abuild_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "build_" + arch))
954N/Aif "ROOT" in os.environ and os.environ["ROOT"] != "":
954N/A root_dir = os.environ["ROOT"]
954N/Aelse:
534N/A root_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "root_" + arch))
1099N/Apkgs_dir = os.path.normpath(os.path.join(pwd, os.pardir, "packages", arch))
290N/Aextern_dir = os.path.normpath(os.path.join(pwd, "extern"))
1516N/A
290N/Apy_install_dir = 'usr/lib/python2.6/vendor-packages'
290N/A
290N/Ascripts_dir = 'usr/bin'
661N/Alib_dir = 'usr/lib'
290N/Asvc_method_dir = 'lib/svc/method'
290N/A
290N/Aman1_dir = 'usr/share/man/cat1'
395N/Aman1m_dir = 'usr/share/man/cat1m'
290N/Aman5_dir = 'usr/share/man/cat5'
2125N/Aresource_dir = 'usr/share/lib/pkg'
290N/Asmf_app_dir = 'lib/svc/manifest/application'
1483N/Asmf_sys_dir = 'lib/svc/manifest/system'
290N/Azones_dir = 'etc/zones'
1498N/Aetcbrand_dir = 'etc/brand/ipkg'
1498N/Abrand_dir = 'usr/lib/brand/ipkg'
290N/Aexecattrd_dir = 'etc/security/exec_attr.d'
1674N/Aauthattrd_dir = 'etc/security/auth_attr.d'
1674N/Asysrepo_dir = 'etc/pkg/sysrepo'
2262N/Asysrepo_logs_dir = 'var/log/pkg/sysrepo'
1674N/Asysrepo_cache_dir = 'var/cache/pkg/sysrepo'
395N/A
430N/A
395N/A# A list of source, destination tuples of modules which should be hardlinked
1544N/A# together if the os supports it and otherwise copied.
1968N/Ahardlink_modules = []
1557N/A
1903N/Ascripts_sunos = {
2046N/A scripts_dir: [
2240N/A ['client.py', 'pkg'],
1506N/A ['pkgdep.py', 'pkgdepend'],
395N/A ['pkgrepo.py', 'pkgrepo'],
395N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
2026N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
424N/A ['util/publish/pkglint.py', 'pkglint'],
1024N/A ['util/publish/pkgmerge.py', 'pkgmerge'],
395N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
395N/A ['publish.py', 'pkgsend'],
395N/A ['pull.py', 'pkgrecv'],
2078N/A ['sign.py', 'pkgsign'],
578N/A ['packagemanager.py', 'packagemanager'],
1172N/A ['updatemanager.py', 'pm-updatemanager'],
395N/A ],
661N/A lib_dir: [
1099N/A ['depot.py', 'pkg.depotd'],
1902N/A ['checkforupdates.py', 'pm-checkforupdates'],
661N/A ['updatemanagernotifier.py', 'updatemanagernotifier'],
395N/A ['launch.py', 'pm-launch'],
849N/A ['sysrepo.py', 'pkg.sysrepo'],
290N/A ],
395N/A svc_method_dir: [
395N/A ['svc/svc-pkg-depot', 'svc-pkg-depot'],
1968N/A ['svc/svc-pkg-mdns', 'svc-pkg-mdns'],
395N/A ['svc/svc-pkg-sysrepo', 'svc-pkg-sysrepo'],
395N/A ],
395N/A }
395N/A
395N/Ascripts_windows = {
395N/A scripts_dir: [
395N/A ['client.py', 'client.py'],
395N/A ['pkgrepo.py', 'pkgrepo.py'],
395N/A ['publish.py', 'publish.py'],
395N/A ['pull.py', 'pull.py'],
395N/A ['scripts/pkg.bat', 'pkg.bat'],
290N/A ['scripts/pkgsend.bat', 'pkgsend.bat'],
290N/A ['scripts/pkgrecv.bat', 'pkgrecv.bat'],
395N/A ],
395N/A lib_dir: [
1231N/A ['depot.py', 'depot.py'],
1557N/A ['scripts/pkg.depotd.bat', 'pkg.depotd.bat'],
1903N/A ],
1557N/A }
395N/A
395N/Ascripts_other_unix = {
395N/A scripts_dir: [
395N/A ['client.py', 'client.py'],
395N/A ['pkgdep.py', 'pkgdep'],
395N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
395N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
395N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
395N/A ['pull.py', 'pull.py'],
395N/A ['publish.py', 'publish.py'],
395N/A ['scripts/pkg.sh', 'pkg'],
290N/A ['scripts/pkgsend.sh', 'pkgsend'],
290N/A ['scripts/pkgrecv.sh', 'pkgrecv'],
430N/A ],
395N/A lib_dir: [
395N/A ['depot.py', 'depot.py'],
395N/A ['scripts/pkg.depotd.sh', 'pkg.depotd'],
395N/A ],
1302N/A }
395N/A
395N/A# indexed by 'osname'
290N/Ascripts = {
395N/A "sunos": scripts_sunos,
1024N/A "linux": scripts_other_unix,
413N/A "windows": scripts_windows,
1544N/A "darwin": scripts_other_unix,
1557N/A "aix" : scripts_other_unix,
1903N/A "unknown": scripts_sunos,
2046N/A }
2240N/A
1506N/Aman1_files = [
413N/A 'man/packagemanager.1',
2026N/A 'man/pkg.1',
413N/A 'man/pkgdepend.1',
1978N/A 'man/pkgdiff.1',
1024N/A 'man/pkgfmt.1',
395N/A 'man/pkglint.1',
395N/A 'man/pkgmerge.1',
413N/A 'man/pkgmogrify.1',
395N/A 'man/pkgsend.1',
395N/A 'man/pkgsign.1',
413N/A 'man/pkgrecv.1',
395N/A 'man/pkgrepo.1',
395N/A 'man/pm-updatemanager.1',
395N/A ]
395N/Aman1m_files = [
395N/A 'man/pkg.depotd.1m',
395N/A 'man/pkg.sysrepo.1m'
1191N/A ]
1452N/Aman5_files = [
1231N/A 'man/pkg.5'
2046N/A ]
395N/Apackages = [
395N/A 'pkg',
424N/A 'pkg.actions',
395N/A 'pkg.bundle',
742N/A 'pkg.client',
742N/A 'pkg.client.linkedimage',
742N/A 'pkg.client.transport',
742N/A 'pkg.file_layout',
742N/A 'pkg.flavor',
742N/A 'pkg.lint',
742N/A 'pkg.portable',
742N/A 'pkg.publish',
742N/A 'pkg.server'
742N/A ]
742N/A
395N/Apylint_targets = [
395N/A 'pkg.altroot',
395N/A 'pkg.client.linkedimage',
395N/A 'pkg.client.pkgdefs',
395N/A ]
954N/A
954N/Aweb_files = []
954N/Afor entry in os.walk("web"):
954N/A web_dir, dirs, files = entry
954N/A if not files:
954N/A continue
954N/A web_files.append((os.path.join(resource_dir, web_dir), [
395N/A os.path.join(web_dir, f) for f in files
1483N/A if f != "Makefile"
1483N/A ]))
1483N/A
1483N/Azones_files = [
395N/A 'brand/SUNWipkg.xml',
1902N/A ]
1099N/Abrand_files = [
1099N/A 'brand/pkgcreatezone',
395N/A 'brand/attach',
2046N/A 'brand/clone',
2223N/A 'brand/detach',
2046N/A 'brand/prestate',
2046N/A 'brand/poststate',
1498N/A 'brand/uninstall',
1498N/A 'brand/common.ksh',
691N/A ]
691N/Aetcbrand_files = [
691N/A 'brand/pkgrm.conf',
395N/A 'brand/smf_disable.conf',
395N/A ]
395N/Asmf_app_files = [
395N/A 'svc/pkg-mdns.xml',
395N/A 'svc/pkg-server.xml',
290N/A 'svc/pkg-system-repository.xml',
395N/A 'svc/pkg-update.xml',
395N/A ]
591N/Asmf_sys_files = [
591N/A 'svc/zoneproxy-client.xml',
591N/A 'svc/zoneproxyd.xml'
1505N/A ]
1505N/Aresource_files = [
1505N/A 'util/opensolaris.org.sections',
1505N/A 'util/pkglintrc',
1632N/A ]
1632N/Asysrepo_files = [
1632N/A 'util/apache2/sysrepo/sysrepo_httpd.conf.mako',
1632N/A 'util/apache2/sysrepo/sysrepo_publisher_response.mako',
395N/A ]
395N/Asysrepo_log_stubs = [
290N/A 'util/apache2/sysrepo/logs/access_log',
290N/A 'util/apache2/sysrepo/logs/error_log',
290N/A ]
290N/Aexecattrd_files = ['util/misc/exec_attr.d/SUNWipkg',
290N/A 'util/misc/exec_attr.d/SUNWipkg-gui']
290N/Aauthattrd_files = ['util/misc/auth_attr.d/SUNWipkg']
290N/Asyscallat_srcs = [
290N/A 'modules/syscallat.c'
290N/A ]
290N/Apspawn_srcs = [
290N/A 'modules/pspawn.c'
290N/A ]
290N/Aelf_srcs = [
290N/A 'modules/elf.c',
395N/A 'modules/elfextract.c',
395N/A 'modules/liblist.c',
290N/A ]
290N/Aarch_srcs = [
290N/A 'modules/arch.c'
290N/A ]
290N/A_actions_srcs = [
395N/A 'modules/actions/_actions.c'
395N/A ]
395N/Asolver_srcs = [
290N/A 'modules/solver/solver.c',
395N/A 'modules/solver/py_solver.c'
395N/A ]
395N/Asolver_link_args = ["-lm", "-lc"]
395N/Aif osname == 'sunos':
591N/A solver_link_args = ["-ztext"] + solver_link_args
591N/A
591N/A# Runs lint on the extension module source code
591N/Aclass pylint_func(Command):
691N/A description = "Runs pylint tools over IPS python source code"
691N/A user_options = []
691N/A
691N/A def initialize_options(self):
290N/A pass
290N/A
290N/A def finalize_options(self):
290N/A pass
290N/A
591N/A # Make string shell-friendly
591N/A @staticmethod
691N/A def escape(astring):
691N/A return astring.replace(' ', '\\ ')
290N/A
395N/A def run(self):
395N/A proto = os.path.join(root_dir, py_install_dir)
290N/A sys.path.insert(0, proto)
395N/A
395N/A # Insert tests directory onto sys.path so any custom checkers
395N/A # can be found.
395N/A sys.path.insert(0, os.path.join(pwd, 'tests'))
290N/A # assumes pylint is accessible on the sys.path
290N/A from pylint import lint
290N/A
395N/A #
395N/A # For some reason, the load-plugins option, when used in the
395N/A # rcfile, does not work, so we put it here instead, to load
395N/A # our custom checkers.
395N/A #
395N/A # Unfortunately, pylint seems pretty fragile and will crash if
290N/A # we try to run it over all the current pkg source. Hence for
290N/A # now we only run it over a subset of the source. As source
290N/A # files are made pylint clean they should be added to the
290N/A # pylint_targets list.
290N/A #
430N/A lint.Run(['--load-plugins=multiplatform', '--rcfile',
290N/A os.path.join(pwd, 'tests', 'pylintrc')] +
290N/A pylint_targets)
395N/A
290N/Ainclude_dirs = [ 'modules' ]
395N/Alint_flags = [ '-u', '-axms', '-erroff=E_NAME_DEF_NOT_USED2' ]
506N/A
506N/A# Runs lint on the extension module source code
506N/Aclass clint_func(Command):
506N/A description = "Runs lint tools over IPS C extension source code"
506N/A user_options = []
506N/A
506N/A def initialize_options(self):
506N/A pass
834N/A
506N/A def finalize_options(self):
506N/A pass
506N/A
513N/A # Make string shell-friendly
506N/A @staticmethod
506N/A def escape(astring):
506N/A return astring.replace(' ', '\\ ')
506N/A
290N/A def run(self):
290N/A # assumes lint is on the $PATH
395N/A if osname == 'sunos' or osname == "linux":
395N/A archcmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
849N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
849N/A ['-I' + self.escape(get_python_inc())] + \
883N/A arch_srcs
883N/A elfcmd = ['lint'] + lint_flags + \
395N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
413N/A ['-I' + self.escape(get_python_inc())] + \
413N/A ["%s%s" % ("-l", k) for k in elf_libraries] + \
413N/A elf_srcs
395N/A _actionscmd = ['lint'] + lint_flags + \
290N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1674N/A ['-I' + self.escape(get_python_inc())] + \
1674N/A _actions_srcs
1674N/A pspawncmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
1674N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1674N/A ['-I' + self.escape(get_python_inc())] + \
1674N/A pspawn_srcs
1674N/A syscallatcmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
1674N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
1674N/A ['-I' + self.escape(get_python_inc())] + \
1674N/A syscallat_srcs
1674N/A
1674N/A print(" ".join(archcmd))
1674N/A os.system(" ".join(archcmd))
1674N/A print(" ".join(elfcmd))
1674N/A os.system(" ".join(elfcmd))
395N/A print(" ".join(_actionscmd))
395N/A os.system(" ".join(_actionscmd))
506N/A print(" ".join(pspawncmd))
506N/A os.system(" ".join(pspawncmd))
395N/A print(" ".join(syscallatcmd))
395N/A os.system(" ".join(syscallatcmd))
395N/A
395N/A
430N/A# Runs both C and Python lint
849N/Aclass lint_func(Command):
834N/A description = "Runs C and Python lint checkers"
290N/A user_options = []
1391N/A
1391N/A def initialize_options(self):
1401N/A pass
1391N/A
1391N/A def finalize_options(self):
1391N/A pass
1391N/A
1391N/A # Make string shell-friendly
1391N/A @staticmethod
1391N/A def escape(astring):
1391N/A return astring.replace(' ', '\\ ')
836N/A
836N/A def run(self):
849N/A clint_func(Distribution()).run()
849N/A pylint_func(Distribution()).run()
849N/A
849N/Aclass install_func(_install):
849N/A def initialize_options(self):
849N/A _install.initialize_options(self)
849N/A
849N/A # PRIVATE_BUILD set in the environment tells us to put the build
849N/A # directory into the .pyc files, rather than the final
849N/A # installation directory.
849N/A private_build = os.getenv("PRIVATE_BUILD", None)
849N/A
1513N/A if private_build is None:
1391N/A self.install_lib = py_install_dir
849N/A self.install_data = os.path.sep
2026N/A self.root = root_dir
2026N/A else:
1513N/A self.install_lib = os.path.join(root_dir, py_install_dir)
1391N/A self.install_data = root_dir
1513N/A
1391N/A # This is used when installing scripts, below, but it isn't a
1391N/A # standard distutils variable.
1660N/A self.root_dir = root_dir
1513N/A
1513N/A def run(self):
2023N/A """
2023N/A At the end of the install function, we need to rename some files
290N/A because distutils provides no way to rename files as they are
883N/A placed in their install locations.
883N/A Also, make sure that cherrypy and other external dependencies
883N/A are installed.
883N/A """
883N/A for f in man1_files + man1m_files + man5_files:
883N/A file_util.copy_file(f + ".txt", f, update=1)
883N/A
883N/A _install.run(self)
883N/A
883N/A for o_src, o_dest in hardlink_modules:
883N/A for e in [".py", ".pyc"]:
883N/A src = util.change_root(self.root_dir, o_src + e)
883N/A dest = util.change_root(
883N/A self.root_dir, o_dest + e)
883N/A if ostype == "posix":
883N/A if os.path.exists(dest) and \
1099N/A os.stat(src)[stat.ST_INO] != \
1099N/A os.stat(dest)[stat.ST_INO]:
1099N/A os.remove(dest)
1099N/A file_util.copy_file(src, dest,
1099N/A link="hard", update=1)
1516N/A else:
1265N/A file_util.copy_file(src, dest, update=1)
1099N/A
1099N/A for d, files in scripts[osname].iteritems():
1099N/A for (srcname, dstname) in files:
1099N/A dst_dir = util.change_root(self.root_dir, d)
1099N/A dst_path = util.change_root(self.root_dir,
1099N/A os.path.join(d, dstname))
1099N/A dir_util.mkpath(dst_dir, verbose = True)
1099N/A file_util.copy_file(srcname, dst_path, update = True)
1099N/A # make scripts executable
1099N/A os.chmod(dst_path,
1208N/A os.stat(dst_path).st_mode
1208N/A | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
1099N/A
1099N/A prep_sw(CP, CPARC, CPDIR, CPURL, CPHASH)
1391N/A install_sw(CP, CPDIR, CPIDIR)
1099N/A if osname == "sunos" and platform.uname()[2] == "5.11":
1099N/A prep_sw(LDTP, LDTPARC, LDTPDIR, LDTPURL,
1099N/A LDTPHASH)
1099N/A saveenv = os.environ.copy()
1099N/A os.environ["LDFLAGS"] = os.environ.get("LDFLAGS", "") + \
465N/A " -lsocket -lnsl"
465N/A install_ldtp(LDTP, LDTPDIR, LDTPIDIR)
395N/A os.environ = saveenv
465N/A
395N/A if "BUILD_PYOPENSSL" in os.environ and \
395N/A os.environ["BUILD_PYOPENSSL"] != "":
2176N/A #
1208N/A # Include /usr/sfw/lib in the build environment
1208N/A # to ensure that this builds and runs on older
465N/A # nevada builds, before openssl moved out of /usr/sfw.
395N/A #
465N/A saveenv = os.environ.copy()
395N/A if osname == "sunos":
465N/A os.environ["CFLAGS"] = "-I/usr/sfw/include " + \
1099N/A os.environ.get("CFLAGS", "")
1099N/A os.environ["LDFLAGS"] = \
1099N/A "-L/usr/sfw/lib -R/usr/sfw/lib " + \
465N/A os.environ.get("LDFLAGS", "")
465N/A prep_sw(PO, POARC, PODIR, POURL, POHASH)
395N/A install_sw(PO, PODIR, POIDIR)
395N/A os.environ = saveenv
1099N/A prep_sw(M2C, M2CARC, M2CDIR, M2CURL, M2CHASH)
395N/A install_sw(M2C, M2CDIR, M2CIDIR)
1191N/A prep_sw(MAKO, MAKOARC, MAKODIR, MAKOURL, MAKOHASH)
1191N/A install_sw(MAKO, MAKODIR, MAKOIDIR)
1191N/A prep_sw(PLY, PLYARC, PLYDIR, PLYURL, PLYHASH)
1191N/A install_sw(PLY, PLYDIR, PLYIDIR)
1191N/A prep_sw(PC, PCARC, PCDIR, PCURL, PCHASH)
1191N/A install_sw(PC, PCDIR, PCIDIR, extra_env=PCENVIRON)
1191N/A prep_sw(COV, COVARC, COVDIR, COVURL, COVHASH)
1191N/A install_sw(COV, COVDIR, COVIDIR)
1191N/A prep_sw(PBJ, PBJARC, PBJDIR, PBJURL, PBJHASH)
1191N/A install_sw(PBJ, PBJDIR, PBJIDIR)
1265N/A
1265N/A # Remove some bits that we're not going to package, but be sure
1265N/A # not to complain if we try to remove them twice.
1208N/A def onerror(func, path, exc_info):
1208N/A if exc_info[1].errno != errno.ENOENT:
1208N/A raise
1208N/A
1208N/A for dir in ("cherrypy/scaffold", "cherrypy/test",
1208N/A "cherrypy/tutorial"):
1208N/A shutil.rmtree(os.path.join(root_dir, py_install_dir, dir),
1191N/A onerror=onerror)
1191N/A try:
1391N/A os.remove(os.path.join(root_dir, "usr/bin/mako-render"))
1391N/A except EnvironmentError, e:
1391N/A if e.errno != errno.ENOENT:
1391N/A raise
1391N/A
1391N/Adef hash_sw(swname, swarc, swhash):
1391N/A if swhash == None:
1394N/A return True
1394N/A
1391N/A print "checksumming %s" % swname
1391N/A hash = hashlib.sha1()
1391N/A f = open(swarc, "rb")
1391N/A while True:
1391N/A data = f.read(65536)
1391N/A if data == "":
1391N/A break
1660N/A hash.update(data)
1391N/A f.close()
465N/A
1660N/A if hash.hexdigest() == swhash:
1660N/A return True
1660N/A else:
1660N/A print >> sys.stderr, "bad checksum! %s != %s" % \
465N/A (swhash, hash.hexdigest())
465N/A return False
1516N/A
498N/Adef prep_sw(swname, swarc, swdir, swurl, swhash):
498N/A swarc = os.path.join(extern_dir, swarc)
849N/A swdir = os.path.join(extern_dir, swdir)
1660N/A if not os.path.exists(extern_dir):
1391N/A os.mkdir(extern_dir)
1660N/A
1660N/A if not os.path.exists(swarc):
1660N/A print "downloading %s" % swname
1660N/A try:
849N/A fname, hdr = urllib.urlretrieve(swurl, swarc)
1208N/A except IOError:
1208N/A pass
1208N/A if not os.path.exists(swarc):
1208N/A print >> sys.stderr, "Unable to retrieve %s.\n" \
849N/A "Please retrieve the file " \
290N/A "and place it at: %s\n" % (swurl, swarc)
465N/A # remove a partial download or error message from proxy
465N/A remove_sw(swname)
1099N/A sys.exit(1)
465N/A if not os.path.exists(swdir):
1099N/A if not hash_sw(swname, swarc, swhash):
1099N/A sys.exit(1)
1099N/A
454N/A print "unpacking %s" % swname
1099N/A tar = tarfile.open(swarc)
849N/A # extractall doesn't exist until python 2.5
290N/A for m in tar.getmembers():
430N/A tar.extract(m, extern_dir)
395N/A tar.close()
395N/A
290N/A # If there are patches, apply them now.
383N/A patchdir = os.path.join("patch", swname)
383N/A already_patched = os.path.join(swdir, ".patched")
395N/A if os.path.exists(patchdir) and not os.path.exists(already_patched):
383N/A patches = os.listdir(patchdir)
383N/A for p in patches:
384N/A patchpath = os.path.join(os.path.pardir,
383N/A os.path.pardir, patchdir, p)
849N/A print "Applying %s to %s" % (p, swname)
849N/A args = ["patch", "-d", swdir, "-i", patchpath, "-p0"]
849N/A if osname == "windows":
849N/A args.append("--binary")
849N/A ret = subprocess.Popen(args).wait()
849N/A if ret != 0:
849N/A print >> sys.stderr, \
849N/A "patch failed and returned %d." % ret
849N/A print >> sys.stderr, \
2242N/A "Command was: %s" % " ".join(args)
2242N/A sys.exit(1)
2242N/A file(already_patched, "w").close()
2242N/A
2242N/Adef install_ldtp(swname, swdir, swidir):
2242N/A swdir = os.path.join(extern_dir, swdir)
2242N/A swinst_file = os.path.join(root_dir, py_install_dir, swidir + ".py")
2242N/A if not os.path.exists(swinst_file):
2242N/A print "installing %s" % swname
2242N/A args_config = ['./configure',
2242N/A '--prefix=/usr',
2242N/A '--bindir=/usr/bin',
849N/A 'PYTHONPATH=""',
849N/A ]
383N/A args_make_install = ['make', 'install',
383N/A 'DESTDIR=%s' % root_dir
383N/A ]
849N/A run_cmd(args_config, swdir)
383N/A run_cmd(args_make_install, swdir)
422N/A
422N/Adef install_sw(swname, swdir, swidir, extra_env=None):
422N/A swdir = os.path.join(extern_dir, swdir)
422N/A swinst_dir = os.path.join(root_dir, py_install_dir, swidir)
422N/A inst_env = os.environ.copy()
422N/A if extra_env:
422N/A inst_env.update(extra_env)
422N/A
422N/A if not os.path.exists(swinst_dir):
422N/A print "installing %s" % swname
422N/A args = ['python2.6', 'setup.py', 'install',
422N/A '--root=%s' % root_dir,
422N/A '--install-lib=%s' % py_install_dir,
422N/A '--install-data=%s' % py_install_dir]
422N/A run_cmd(args, swdir, env=inst_env)
422N/A
422N/Adef run_cmd(args, swdir, env=None):
383N/A if env is None:
422N/A env = os.environ
383N/A ret = subprocess.Popen(args, cwd=swdir, env=env).wait()
383N/A if ret != 0:
383N/A print >> sys.stderr, \
383N/A "install failed and returned %d." % ret
383N/A print >> sys.stderr, \
383N/A "Command was: %s" % " ".join(args)
383N/A sys.exit(1)
422N/A
849N/Adef remove_sw(swname):
849N/A print("deleting %s" % swname)
849N/A for file in os.listdir(extern_dir):
383N/A if fnmatch.fnmatch(file, "%s*" % swname):
383N/A fpath = os.path.join(extern_dir, file)
290N/A if os.path.isfile(fpath):
430N/A os.unlink(fpath)
395N/A else:
395N/A shutil.rmtree(fpath, True)
290N/A
290N/Aclass build_func(_build):
290N/A def initialize_options(self):
290N/A _build.initialize_options(self)
290N/A self.build_base = build_dir
290N/A
290N/Adef get_hg_version():
290N/A try:
290N/A p = subprocess.Popen(['hg', 'id', '-i'], stdout = subprocess.PIPE)
290N/A return p.communicate()[0].strip()
290N/A except OSError:
395N/A print >> sys.stderr, "ERROR: unable to obtain mercurial version"
290N/A return "unknown"
395N/A
290N/Adef syntax_check(filename):
395N/A """ Run python's compiler over the file, and discard the results.
290N/A Arrange to generate an exception if the file does not compile.
534N/A This is needed because distutil's own use of pycompile (in the
534N/A distutils.utils module) is broken, and doesn't stop on error. """
1099N/A try:
1099N/A py_compile.compile(filename, os.devnull, doraise=True)
290N/A except py_compile.PyCompileError, e:
290N/A res = ""
1101N/A for err in e.exc_value:
1101N/A if isinstance(err, basestring):
1101N/A res += err + "\n"
1513N/A continue
1715N/A
1513N/A # Assume it's a tuple of (filename, lineno, col, code)
1513N/A fname, line, col, code = err
448N/A res += "line %d, column %s, in %s:\n%s" % (line,
1513N/A col or "unknown", fname, code)
448N/A
1101N/A raise DistutilsError(res)
1513N/A
1715N/A
1715N/Aclass build_py_func(_build_py):
1716N/A # override the build_module method to do VERSION substitution on pkg/__init__.py
1715N/A def build_module (self, module, module_file, package):
1715N/A
1513N/A if module == "__init__" and package == "pkg":
290N/A versionre = '(?m)^VERSION[^"]*"([^"]*)"'
290N/A # Grab the previously-built version out of the build
290N/A # tree.
448N/A try:
448N/A ocontent = \
430N/A file(self.get_module_outfile(self.build_lib,
448N/A [package], module)).read()
430N/A ov = re.search(versionre, ocontent).group(1)
1101N/A except IOError:
1513N/A ov = None
1715N/A v = get_hg_version()
1715N/A vstr = 'VERSION = "%s"' % v
1716N/A # If the versions haven't changed, there's no need to
1715N/A # recompile.
1715N/A if v == ov:
1101N/A return
290N/A
290N/A mcontent = file(module_file).read()
1101N/A mcontent = re.sub(versionre, vstr, mcontent)
290N/A tmpfd, tmp_file = tempfile.mkstemp()
1101N/A os.write(tmpfd, mcontent)
290N/A os.close(tmpfd)
290N/A print "doing version substitution: ", v
290N/A rv = _build_py.build_module(self, module, tmp_file, package)
448N/A os.unlink(tmp_file)
448N/A return rv
448N/A
448N/A # Will raise a DistutilsError on failure.
448N/A syntax_check(module_file)
430N/A
448N/A return _build_py.build_module(self, module, module_file, package)
290N/A
290N/Aclass clean_func(_clean):
290N/A def initialize_options(self):
430N/A _clean.initialize_options(self)
395N/A self.build_base = build_dir
290N/A
2180N/Aclass clobber_func(Command):
2180N/A user_options = []
2180N/A description = "Deletes any and all files created by setup"
2180N/A
2180N/A def initialize_options(self):
2180N/A pass
2180N/A def finalize_options(self):
2180N/A pass
2180N/A def run(self):
2180N/A # nuke everything
2180N/A print("deleting " + dist_dir)
2180N/A shutil.rmtree(dist_dir, True)
2180N/A print("deleting " + build_dir)
2180N/A shutil.rmtree(build_dir, True)
2180N/A print("deleting " + root_dir)
2180N/A shutil.rmtree(root_dir, True)
2180N/A print("deleting " + pkgs_dir)
2180N/A shutil.rmtree(pkgs_dir, True)
2180N/A print("deleting " + extern_dir)
2180N/A shutil.rmtree(extern_dir, True)
2180N/A
2180N/Aclass test_func(Command):
2180N/A # NOTE: these options need to be in sync with tests/run.py and the
2180N/A # list of options stored in initialize_options below. The first entry
2180N/A # in each tuple must be the exact name of a member variable.
2180N/A user_options = [
2180N/A ("archivedir=", 'a', "archive failed tests <dir>"),
2180N/A ("baselinefile=", 'b', "baseline file <file>"),
290N/A ("coverage", "c", "collect code coverage data"),
290N/A ("genbaseline", 'g', "generate test baseline"),
290N/A ("only=", "o", "only <regex>"),
1637N/A ("parseable", 'p', "parseable output"),
1637N/A ("port=", "z", "lowest port to start a depot on"),
290N/A ("timing", "t", "timing file <file>"),
613N/A ("verbosemode", 'v', "run tests in verbose mode"),
613N/A ("enableguitests", 'u', "enable IPS GUI tests, disabled by default"),
613N/A ("stoponerr", 'x', "stop when a baseline mismatch occurs"),
613N/A ("debugoutput", 'd', "emit debugging output"),
613N/A ("showonexpectedfail", 'f',
613N/A "show all failure info, even for expected fails"),
613N/A ("startattest=", 's', "start at indicated test"),
613N/A ]
1632N/A description = "Runs unit and functional tests"
1632N/A
1632N/A def initialize_options(self):
1632N/A self.only = ""
1632N/A self.baselinefile = ""
1632N/A self.verbosemode = 0
1632N/A self.parseable = 0
1632N/A self.genbaseline = 0
613N/A self.timing = 0
290N/A self.coverage = 0
742N/A self.stoponerr = 0
395N/A self.debugoutput = 0
395N/A self.showonexpectedfail = 0
395N/A self.startattest = ""
395N/A self.archivedir = ""
395N/A self.port = 12001
395N/A
395N/A def finalize_options(self):
395N/A pass
395N/A
2180N/A def run(self):
395N/A
290N/A os.putenv('PYEXE', sys.executable)
383N/A os.chdir(os.path.join(pwd, "tests"))
395N/A
395N/A # Reconstruct the cmdline and send that to run.py
395N/A cmd = [sys.executable, "run.py"]
395N/A args = ""
2046N/A if "test" in sys.argv:
395N/A args = sys.argv[sys.argv.index("test")+1:]
290N/A cmd.extend(args)
290N/A subprocess.call(cmd)
395N/A
395N/Aclass dist_func(_bdist):
395N/A def initialize_options(self):
395N/A _bdist.initialize_options(self)
1483N/A self.dist_dir = dist_dir
395N/A
1498N/Aclass info_func(Command):
1498N/A user_options = [
395N/A ("pkg=", None, "Component package name")
290N/A ]
290N/A description = "Print component information"
395N/A
395N/A def initialize_options(self):
395N/A self.pkg = ""
613N/A
290N/A def finalize_options(self):
395N/A self.pkg = urllib.unquote(self.pkg.rsplit(".", 1)[0])
395N/A
395N/A pkginfo = {
395N/A "library/python-2/cherrypy": (CPVER, CPVER, CPURL),
395N/A "library/python-2/coverage": (COVVER, COVPVER, COVURL),
395N/A "library/python-2/m2crypto": (M2CVER, M2CVER, M2CURL),
395N/A "library/python-2/mako": (MAKOVER, MAKOVER, MAKOURL),
395N/A "library/python-2/ply": (PLYVER, PLYVER, PLYURL),
290N/A "library/python-2/pybonjour": (PBJVER, PBJVER, PBJURL),
395N/A "library/python-2/pycurl": (PCVER, PCPVER, PCURL),
395N/A "system/desktop/ldtp": (LDTPVER, LDTPVER, LDTPURL)
395N/A }
395N/A
395N/A def run(self):
395N/A if self.pkg in self.pkginfo:
430N/A print "-D SOURCE_VER=%s -D PKG_VER=%s " \
395N/A "-D SOURCE_URL=%s" % self.pkginfo[self.pkg]
395N/A
395N/A
395N/A# These are set to real values based on the platform, down below
395N/Acompile_args = None
395N/Aif osname in ("sunos", "linux", "darwin"):
691N/A compile_args = [ "-O3" ]
691N/Alink_args = None
691N/Aext_modules = [
691N/A Extension(
691N/A 'actions._actions',
691N/A _actions_srcs,
691N/A include_dirs = include_dirs,
691N/A extra_compile_args = compile_args,
395N/A extra_link_args = link_args
395N/A ),
395N/A Extension(
395N/A 'solver',
395N/A solver_srcs,
1516N/A include_dirs = include_dirs + ["."],
1516N/A extra_compile_args = compile_args,
395N/A extra_link_args = solver_link_args,
395N/A define_macros = [('_FILE_OFFSET_BITS', '64')]
395N/A ),
395N/A ]
395N/Aelf_libraries = None
395N/Adata_files = web_files
cmdclasses = {
'install': install_func,
'build': build_func,
'build_py': build_py_func,
'bdist': dist_func,
'lint': lint_func,
'clint': clint_func,
'pylint': pylint_func,
'clean': clean_func,
'clobber': clobber_func,
'test': test_func,
'info': info_func,
}
# all builds of IPS should have manpages
data_files += [
(man1_dir, man1_files),
(man1m_dir, man1m_files),
(man5_dir, man5_files),
(resource_dir, resource_files),
]
if osname == 'sunos':
# Solaris-specific extensions are added here
data_files += [
(zones_dir, zones_files),
(brand_dir, brand_files),
(etcbrand_dir, etcbrand_files),
(smf_app_dir, smf_app_files),
(smf_sys_dir, smf_sys_files),
(execattrd_dir, execattrd_files),
(authattrd_dir, authattrd_files),
(sysrepo_dir, sysrepo_files),
(sysrepo_logs_dir, sysrepo_log_stubs),
(sysrepo_cache_dir, {})
]
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,
)