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