setup.py revision 883
1516N/A#!/usr/bin/python2.4
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#
2339N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
395N/A# Use is subject to license terms.
290N/A#
883N/A
454N/Aimport errno
290N/Aimport fnmatch
448N/Aimport os
290N/Aimport platform
290N/Aimport stat
290N/Aimport sys
383N/Aimport shutil
290N/Aimport re
395N/Aimport subprocess
290N/Aimport tarfile
395N/Aimport tempfile
849N/Aimport urllib
1516N/Aimport py_compile
2508N/A
290N/Afrom distutils.errors import DistutilsError
849N/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
290N/Afrom distutils.command.build_py import build_py as _build_py
2508N/Afrom distutils.command.bdist import bdist as _bdist
383N/Afrom distutils.command.clean import clean as _clean
290N/A
290N/Afrom distutils.sysconfig import get_python_inc
2339N/Aimport distutils.file_util as file_util
290N/Aimport distutils.dir_util as dir_util
290N/Aimport distutils.util as util
290N/A
290N/A# 3rd party software required for the build
290N/ACP = 'CherryPy'
2508N/ACPIDIR = 'cherrypy'
2508N/ACPVER = '3.1.1'
290N/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/A
1660N/APO = 'pyOpenSSL'
1660N/APOIDIR = 'OpenSSL'
1660N/APOVER = '0.7'
1660N/APOARC = '%s-%s.tar.gz' % (PO, POVER)
1660N/APODIR = '%s-%s' % (PO, POVER)
1660N/APOURL = 'http://downloads.sourceforge.net/pyopenssl/%s' % (POARC)
1660N/A
1660N/AFL = 'figleaf'
1660N/AFLIDIR = 'figleaf'
1660N/AFLVER = 'latest'
1660N/AFLARC = '%s-%s.tar.gz' % (FL, FLVER)
1660N/AFLDIR = '%s-%s' % (FL, FLVER)
1660N/AFLURL = 'http://darcs.idyll.org/~t/projects/%s' % FLARC
1660N/A
1660N/AMAKO = 'Mako'
448N/AMAKOIDIR = 'mako'
448N/AMAKOVER = '0.2.2'
534N/AMAKOARC = '%s-%s.tar.gz' % (MAKO, MAKOVER)
534N/AMAKODIR = '%s-%s' % (MAKO, MAKOVER)
534N/AMAKOURL = 'http://www.makotemplates.org/downloads/%s' % (MAKOARC)
534N/A
534N/Aosname = platform.uname()[0].lower()
534N/Aostype = arch = 'unknown'
534N/Aif osname == 'sunos':
290N/A arch = platform.processor()
290N/A ostype = "posix"
954N/Aelif osname == 'linux':
954N/A arch = "linux_" + platform.machine()
954N/A ostype = "posix"
954N/Aelif osname == 'windows':
534N/A arch = osname
1099N/A ostype = "windows"
290N/Aelif osname == 'darwin':
1516N/A arch = osname
290N/A ostype = "posix"
290N/A
290N/Apwd = os.path.normpath(sys.path[0])
661N/A
290N/A#
2494N/A# Unbuffer stdout and stderr. This helps to ensure that subprocess output
2494N/A# is properly interleaved with output from this program.
2494N/A#
2516N/Asys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)
2516N/Asys.stderr = os.fdopen(sys.stderr.fileno(), "w", 0)
2516N/A
2516N/Adist_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "dist_" + arch))
2516N/Abuild_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "build_" + arch))
2516N/Aroot_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "root_" + arch))
2516N/Apkgs_dir = os.path.normpath(os.path.join(pwd, os.pardir, "packages", arch))
290N/A
2523N/Apy_install_dir = 'usr/lib/python2.4/vendor-packages'
2390N/A
1498N/Ascripts_dir = 'usr/bin'
1498N/Alib_dir = 'usr/lib'
2310N/Asvc_method_dir = 'lib/svc/method'
2310N/A
2310N/Aman1_dir = 'usr/share/man/cat1'
2310N/Aman1m_dir = 'usr/share/man/cat1m'
290N/Aman5_dir = 'usr/share/man/cat5'
1674N/Aresource_dir = 'usr/share/lib/pkg'
1674N/Asmf_dir = 'var/svc/manifest/application'
2262N/Azones_dir = 'etc/zones'
1674N/Abrand_dir = 'usr/lib/brand/ipkg'
395N/A
430N/Ascripts_sunos = {
395N/A scripts_dir: [
1544N/A ['client.py', 'pkg'],
1968N/A ['publish.py', 'pkgsend'],
1557N/A ['pull.py', 'pkgrecv'],
1903N/A ['packagemanager.py', 'packagemanager'],
2046N/A ['updatemanager.py', 'updatemanager'],
2240N/A ],
1506N/A lib_dir: [
395N/A ['depot.py', 'pkg.depotd'],
395N/A ['updatemanagernotifier.py', 'updatemanagernotifier'],
2026N/A ],
424N/A svc_method_dir: [
1024N/A ['svc-pkg-depot', 'svc-pkg-depot'],
395N/A ],
395N/A }
395N/A
2078N/Ascripts_windows = {
578N/A scripts_dir: [
1172N/A ['client.py', 'client.py'],
2310N/A ['publish.py', 'publish.py'],
395N/A ['pull.py', 'pull.py'],
661N/A ['scripts/pkg.bat', 'pkg.bat'],
1099N/A ['scripts/pkgsend.bat', 'pkgsend.bat'],
1902N/A ['scripts/pkgrecv.bat', 'pkgrecv.bat'],
2310N/A ],
661N/A lib_dir: [
395N/A ['depot.py', 'depot.py'],
849N/A ['scripts/pkg.depotd.bat', 'pkg.depotd.bat'],
290N/A ],
395N/A }
395N/A
1968N/Ascripts_other_unix = {
395N/A scripts_dir: [
395N/A ['client.py', 'client.py'],
395N/A ['pull.py', 'pull.py'],
395N/A ['publish.py', 'publish.py'],
395N/A ['scripts/pkg.sh', 'pkg'],
395N/A ['scripts/pkgsend.sh', 'pkgsend'],
395N/A ['scripts/pkgrecv.sh', 'pkgrecv'],
395N/A ],
395N/A lib_dir: [
395N/A ['depot.py', 'depot.py'],
395N/A ['scripts/pkg.depotd.sh', 'pkg.depotd'],
290N/A ],
290N/A }
395N/A
395N/A# indexed by 'osname'
1231N/Ascripts = {
1557N/A "sunos": scripts_sunos,
1903N/A "linux": scripts_other_unix,
1557N/A "windows": scripts_windows,
395N/A "darwin": scripts_other_unix,
395N/A "unknown": scripts_sunos,
395N/A }
395N/A
395N/Aman1_files = [
395N/A 'man/pkg.1',
395N/A 'man/pkgsend.1',
395N/A 'man/pkgrecv.1',
395N/A ]
395N/Aman1m_files = [
395N/A 'man/pkg.depotd.1m'
290N/A ]
290N/Aman5_files = [
430N/A 'man/pkg.5'
395N/A ]
395N/Apackages = [
395N/A 'pkg',
395N/A 'pkg.actions',
1302N/A 'pkg.bundle',
395N/A 'pkg.client',
395N/A 'pkg.portable',
290N/A 'pkg.publish',
395N/A 'pkg.server'
1024N/A ]
413N/A
1544N/Aweb_files = []
1557N/Afor entry in os.walk("web"):
1903N/A web_dir, dirs, files = entry
2046N/A if not files:
2240N/A continue
1506N/A web_files.append((os.path.join(resource_dir, web_dir), [
413N/A os.path.join(web_dir, f) for f in files
2026N/A if f != "Makefile"
413N/A ]))
1978N/A
1024N/Azones_files = [
395N/A 'brand/SUNWipkg.xml',
395N/A ]
2310N/Abrand_files = [
2310N/A 'brand/config.xml',
395N/A 'brand/platform.xml',
395N/A 'brand/pkgcreatezone',
413N/A ]
395N/Asmf_files = [
2516N/A 'pkg-server.xml',
2516N/A 'pkg-update.xml',
2516N/A ]
2516N/Apspawn_srcs = [
2516N/A 'modules/pspawn.c'
2516N/A ]
2516N/Aelf_srcs = [
2516N/A 'modules/elf.c',
2516N/A 'modules/elfextract.c',
2516N/A 'modules/liblist.c',
2516N/A ]
2516N/Aarch_srcs = [
2516N/A 'modules/arch.c'
2516N/A ]
2516N/A_actions_srcs = [
2516N/A 'modules/actions/_actions.c'
2516N/A ]
2516N/Ainclude_dirs = [ 'modules' ]
2516N/Alint_flags = [ '-u', '-axms', '-erroff=E_NAME_DEF_NOT_USED2' ]
2516N/A
2516N/A# Runs the test suite with the code coverage suite (figleaf) turned on, and
2516N/A# outputs a coverage report.
2516N/A# TODO: Make the cov report format an option (html, ast, cov, etc)
2516N/Aclass cov_func(Command):
2516N/A description = "Runs figleaf code coverage suite"
2516N/A user_options = []
2516N/A def initialize_options(self):
2516N/A pass
2516N/A def finalize_options(self):
2516N/A pass
2516N/A def run(self):
2516N/A if not os.path.isdir(FLDIR):
2516N/A install_sw(FL, FLVER, FLARC, FLDIR, FLURL, FLIDIR)
2516N/A # Run the test suite with coverage enabled
2516N/A os.putenv('PYEXE', sys.executable)
2516N/A os.chdir(os.path.join(pwd, "tests"))
2516N/A # Reconstruct the cmdline and send that to run.py
2516N/A os.environ["PKGCOVERAGE"] = "1"
2516N/A cmd = [sys.executable, "run.py"]
2516N/A subprocess.call(cmd)
2516N/A print "Generating coverage report in directory: '%s/cov_report'" % \
2516N/A pwd
2516N/A os.system("figleaf2html -d cov_report .figleaf")
2516N/A
2516N/A# Runs lint on the extension module source code
2516N/Aclass lint_func(Command):
2516N/A description = "Runs various lint tools over IPS extension source code"
395N/A user_options = []
395N/A
395N/A def initialize_options(self):
395N/A pass
395N/A
2339N/A def finalize_options(self):
1191N/A pass
1452N/A
1231N/A # Make string shell-friendly
2046N/A @staticmethod
395N/A def escape(astring):
395N/A return astring.replace(' ', '\\ ')
424N/A
395N/A def run(self):
742N/A # assumes lint is on the $PATH
2339N/A if osname == 'sunos' or osname == "linux":
2339N/A archcmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
2339N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
2339N/A ['-I' + self.escape(get_python_inc())] + \
2339N/A arch_srcs
2339N/A elfcmd = ['lint'] + lint_flags + \
742N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
742N/A ['-I' + self.escape(get_python_inc())] + \
742N/A ["%s%s" % ("-l", k) for k in elf_libraries] + \
742N/A elf_srcs
742N/A _actionscmd = ['lint'] + lint_flags + \
742N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
742N/A ['-I' + self.escape(get_python_inc())] + \
742N/A _actions_srcs
742N/A pspawncmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
742N/A ["%s%s" % ("-I", k) for k in include_dirs] + \
2310N/A ['-I' + self.escape(get_python_inc())] + \
1902N/A pspawn_srcs
1099N/A
2390N/A print(" ".join(archcmd))
2335N/A os.system(" ".join(archcmd))
2338N/A print(" ".join(elfcmd))
2338N/A os.system(" ".join(elfcmd))
2310N/A print(" ".join(_actionscmd))
2046N/A os.system(" ".join(_actionscmd))
2223N/A print(" ".join(pspawncmd))
2046N/A os.system(" ".join(pspawncmd))
2046N/A
2523N/A proto = os.path.join(root_dir, py_install_dir)
2523N/A sys.path.insert(0, proto)
2523N/A
2523N/A # Insert tests directory onto sys.path so any custom checkers
2523N/A # can be found.
2523N/A sys.path.insert(0, os.path.join(pwd, 'tests'))
2310N/A print(sys.path)
2310N/A
2310N/A # assumes pylint is accessible on the sys.path
2310N/A from pylint import lint
2310N/A scriptlist = [ 'setup.py' ]
2310N/A for d, m in scripts_sunos.items():
2310N/A for a in m:
2310N/A # specify the filenames of the scripts, in addition
2508N/A # to the package names themselves
2508N/A scriptlist.append(os.path.join(root_dir, d, a[1]))
2508N/A
2508N/A # For some reason, the load-plugins option, when used in the
2508N/A # rcfile, does not work, so we put it here instead, to load
2339N/A # our custom checkers.
2339N/A lint.Run(['--load-plugins=multiplatform', '--rcfile',
2339N/A os.path.join(pwd, 'tests', 'pylintrc')] +
691N/A scriptlist + packages)
691N/A
691N/Aclass install_func(_install):
395N/A def initialize_options(self):
395N/A _install.initialize_options(self)
395N/A
395N/A # PRIVATE_BUILD set in the environment tells us to put the build
395N/A # directory into the .pyc files, rather than the final
290N/A # installation directory.
395N/A private_build = os.getenv("PRIVATE_BUILD", None)
395N/A
591N/A if private_build is None:
591N/A self.install_lib = py_install_dir
591N/A self.install_data = os.path.sep
1505N/A self.root = root_dir
2516N/A else:
1505N/A self.install_lib = os.path.join(root_dir, py_install_dir)
1505N/A self.install_data = root_dir
1632N/A
1632N/A # This is used when installing scripts, below, but it isn't a
1632N/A # standard distutils variable.
1632N/A self.root_dir = root_dir
2339N/A
2339N/A def run(self):
2339N/A """
2339N/A At the end of the install function, we need to rename some files
2339N/A because distutils provides no way to rename files as they are
2339N/A placed in their install locations.
2339N/A Also, make sure that cherrypy and other external dependencies
2339N/A are installed.
2339N/A """
2339N/A for f in man1_files + man1m_files + man5_files:
2339N/A file_util.copy_file(f + ".txt", f, update=1)
2339N/A
2339N/A _install.run(self)
2339N/A
2339N/A for d, files in scripts[osname].iteritems():
2339N/A for (srcname, dstname) in files:
2364N/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,
2339N/A os.stat(dst_path).st_mode
2339N/A | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
2339N/A
2339N/A install_sw(CP, CPVER, CPARC, CPDIR, CPURL, CPIDIR)
2339N/A if "BUILD_PYOPENSSL" in os.environ and \
2339N/A os.environ["BUILD_PYOPENSSL"] != "":
2339N/A #
2339N/A # Include /usr/sfw/lib in the build environment
2339N/A # to ensure that this builds and runs on older
2339N/A # nevada builds, before openssl moved out of /usr/sfw.
2339N/A #
2339N/A saveenv = os.environ.copy()
2339N/A if osname == "sunos":
2339N/A os.environ["CFLAGS"] = "-I/usr/sfw/include " + \
2364N/A os.environ.get("CFLAGS", "")
2364N/A os.environ["LDFLAGS"] = \
2364N/A "-L/usr/sfw/lib -R/usr/sfw/lib " + \
2364N/A os.environ.get("LDFLAGS", "")
2364N/A install_sw(PO, POVER, POARC, PODIR, POURL, POIDIR)
2364N/A os.environ = saveenv
2364N/A install_sw(MAKO, MAKOVER, MAKOARC, MAKODIR, MAKOURL, MAKOIDIR)
2364N/A
2364N/A # Remove some bits that we're not going to package, but be sure
2364N/A # not to complain if we try to remove them twice.
2364N/A def onerror(func, path, exc_info):
2364N/A if exc_info[1].errno != errno.ENOENT:
2364N/A raise
2339N/A
395N/A for dir in ("cherrypy/scaffold", "cherrypy/test",
395N/A "cherrypy/tutorial"):
290N/A shutil.rmtree(os.path.join(root_dir, py_install_dir, dir),
290N/A onerror=onerror)
2339N/A try:
2339N/A os.remove(os.path.join(root_dir, "usr/bin/mako-render"))
290N/A except EnvironmentError, e:
290N/A if e.errno != errno.ENOENT:
290N/A raise
290N/A
290N/Adef install_sw(swname, swver, swarc, swdir, swurl, swidir):
290N/A if not os.path.exists(swarc):
290N/A print "downloading %s" % swname
290N/A try:
290N/A fname, hdr = urllib.urlretrieve(swurl, swarc)
290N/A except IOError:
395N/A pass
395N/A if not os.path.exists(swarc) or \
290N/A (hdr.gettype() != "application/x-gzip" and
290N/A hdr.gettype() != "application/x-tar"):
290N/A print "Unable to retrieve %s.\nPlease retrieve the file " \
290N/A "and place it at: %s\n" % (swurl, swarc)
290N/A # remove a partial download or error message from proxy
395N/A remove_sw(swname)
395N/A sys.exit(1)
395N/A if not os.path.exists(swdir):
290N/A print "unpacking %s" % swname
395N/A tar = tarfile.open(swarc)
395N/A # extractall doesn't exist until python 2.5
395N/A for m in tar.getmembers():
395N/A tar.extract(m)
591N/A tar.close()
591N/A swinst_dir = os.path.join(root_dir, py_install_dir, swidir)
591N/A if not os.path.exists(swinst_dir):
591N/A print "installing %s" % swname
691N/A args = ['python', 'setup.py', 'install',
691N/A '--root=%s' % root_dir,
691N/A '--install-lib=%s' % py_install_dir,
691N/A '--install-data=%s' % py_install_dir]
2339N/A ret = subprocess.Popen(args, cwd = swdir).wait()
2339N/A if ret != 0:
2339N/A print "install failed and returned %d." % ret
2339N/A print "Command was: %s" % " ".join(args)
290N/A sys.exit(1)
290N/A
290N/A
290N/Adef remove_sw(swname):
290N/A print("deleting %s" % swname)
591N/A for file in os.listdir("."):
591N/A if fnmatch.fnmatch(file, "%s*" % swname):
691N/A if os.path.isfile(file):
691N/A os.unlink(file)
2339N/A else:
2339N/A shutil.rmtree(file, True)
290N/A
290N/Aclass build_func(_build):
2339N/A def initialize_options(self):
2339N/A _build.initialize_options(self)
2339N/A self.build_base = build_dir
2339N/A
2339N/Adef get_hg_version():
2339N/A try:
2339N/A p = subprocess.Popen(['hg', 'id', '-i'], stdout = subprocess.PIPE)
290N/A return p.communicate()[0].strip()
2339N/A except OSError:
2339N/A print >> sys.stderr, "ERROR: unable to obtain mercurial version"
290N/A return "unknown"
2339N/A
2339N/Adef syntax_check(filename):
2339N/A """ Run python's compiler over the file, and discard the results.
2339N/A Arrange to generate an exception if the file does not compile.
2339N/A This is needed because distutil's own use of pycompile (in the
2339N/A distutils.utils module) is broken, and doesn't stop on error. """
2339N/A try:
2339N/A py_compile.compile(filename, os.devnull, doraise=True)
290N/A except py_compile.PyCompileError, e:
395N/A raise DistutilsError("%s: failed syntax check: %s" %
290N/A (filename, e))
395N/A
506N/A
506N/Aclass build_py_func(_build_py):
506N/A # override the build_module method to do VERSION substitution on pkg/__init__.py
506N/A def build_module (self, module, module_file, package):
506N/A
506N/A if module == "__init__" and package == "pkg":
506N/A versionre = '(?m)^VERSION[^"]*"([^"]*)"'
506N/A # Grab the previously-built version out of the build
834N/A # tree.
506N/A try:
506N/A ocontent = \
506N/A file(self.get_module_outfile(self.build_lib,
513N/A [package], module)).read()
506N/A ov = re.search(versionre, ocontent).group(1)
506N/A except IOError:
506N/A ov = None
506N/A v = get_hg_version()
290N/A vstr = 'VERSION = "%s"' % v
290N/A # If the versions haven't changed, there's no need to
395N/A # recompile.
395N/A if v == ov:
849N/A return
849N/A
883N/A mcontent = file(module_file).read()
883N/A mcontent = re.sub(versionre, vstr, mcontent)
395N/A tmpfd, tmp_file = tempfile.mkstemp()
413N/A os.write(tmpfd, mcontent)
395N/A os.close(tmpfd)
290N/A print "doing version substitution: ", v
1674N/A rv = _build_py.build_module(self, module, tmp_file, package)
1674N/A os.unlink(tmp_file)
1674N/A return rv
1674N/A
1674N/A # Will raise a DistutilsError on failure.
1674N/A syntax_check(module_file)
1674N/A
1674N/A return _build_py.build_module(self, module, module_file, package)
1674N/A
1674N/Aclass clean_func(_clean):
1674N/A def initialize_options(self):
1674N/A _clean.initialize_options(self)
1674N/A self.build_base = build_dir
1674N/A
1674N/Aclass clobber_func(Command):
395N/A user_options = []
395N/A description = "Deletes any and all files created by setup"
506N/A
506N/A def initialize_options(self):
395N/A pass
395N/A def finalize_options(self):
395N/A pass
395N/A def run(self):
430N/A # nuke everything
849N/A print("deleting " + dist_dir)
834N/A shutil.rmtree(dist_dir, True)
290N/A print("deleting " + build_dir)
1099N/A shutil.rmtree(build_dir, True)
1099N/A print("deleting " + root_dir)
1099N/A shutil.rmtree(root_dir, True)
1099N/A print("deleting " + pkgs_dir)
1099N/A shutil.rmtree(pkgs_dir, True)
1516N/A remove_sw(CP)
1265N/A remove_sw(PO)
1099N/A remove_sw(MAKO)
1099N/A
1099N/Aclass test_func(Command):
1099N/A # NOTE: these options need to be in sync with tests/run.py
1099N/A user_options = [("verbosemode", 'v', "run tests in verbose mode"),
1099N/A ("genbaseline", 'g', "generate test baseline"),
1099N/A ("parseable", 'p', "parseable output"),
1099N/A ("baselinefile=", 'b', "baseline file <file>"),
1099N/A ("only=", "o", "only <regex>")]
1099N/A description = "Runs unit and functional tests"
1208N/A
1208N/A def initialize_options(self):
1099N/A self.only = ""
1099N/A self.baselinefile = ""
1391N/A self.verbosemode = 0
1099N/A self.parseable = 0
1099N/A self.genbaseline = 0
1099N/A def finalize_options(self):
1099N/A pass
1099N/A def run(self):
465N/A os.putenv('PYEXE', sys.executable)
465N/A os.chdir(os.path.join(pwd, "tests"))
395N/A
465N/A # Reconstruct the cmdline and send that to run.py
395N/A cmd = [sys.executable, "run.py"]
395N/A args = ""
2176N/A if "test" in sys.argv:
1208N/A args = sys.argv[sys.argv.index("test")+1:]
1208N/A cmd.extend(args)
465N/A subprocess.call(cmd)
395N/A
465N/Aclass dist_func(_bdist):
395N/A def initialize_options(self):
465N/A _bdist.initialize_options(self)
1099N/A self.dist_dir = dist_dir
1099N/A
1099N/A
465N/A# These are set to real values based on the platform, down below
465N/Acompile_args = None
395N/Alink_args = None
395N/Aext_modules = [
1099N/A Extension(
395N/A 'actions._actions',
1191N/A _actions_srcs,
1191N/A include_dirs = include_dirs,
1191N/A extra_compile_args = compile_args,
1191N/A extra_link_args = link_args
1191N/A ),
1191N/A ]
1191N/Aelf_libraries = None
1191N/Adata_files = web_files
1191N/Acmdclasses = {
1191N/A 'install': install_func,
1265N/A 'build': build_func,
1265N/A 'build_py': build_py_func,
1265N/A 'bdist': dist_func,
1208N/A 'lint': lint_func,
1208N/A 'clean': clean_func,
1208N/A 'clobber': clobber_func,
1208N/A 'coverage': cov_func,
1208N/A 'test': test_func,
1208N/A }
1208N/A
1191N/A# all builds of IPS should have manpages
1191N/Adata_files += [
1660N/A (man1_dir, man1_files),
1660N/A (man1m_dir, man1m_files),
1660N/A (man5_dir, man5_files),
1660N/A ]
849N/A
1208N/Aif osname == 'sunos':
1208N/A # Solaris-specific extensions are added here
1208N/A data_files += [
1208N/A (zones_dir, zones_files),
849N/A (brand_dir, brand_files),
290N/A (smf_dir, smf_files),
465N/A ]
465N/A
1099N/Aif osname == 'sunos' or osname == "linux":
465N/A # Unix platforms which the elf extension has been ported to
1099N/A # are specified here, so they are built automatically
1099N/A elf_libraries = ['elf']
1099N/A ext_modules += [
454N/A Extension(
1099N/A 'elf',
849N/A elf_srcs,
290N/A include_dirs = include_dirs,
430N/A libraries = elf_libraries,
395N/A extra_compile_args = compile_args,
395N/A extra_link_args = link_args
290N/A ),
383N/A ]
383N/A
395N/A # Solaris has built-in md library and Solaris-specific arch extension
383N/A # All others use OpenSSL and cross-platform arch module
383N/A if osname == 'sunos':
384N/A elf_libraries += [ 'md' ]
383N/A ext_modules += [
849N/A Extension(
849N/A 'arch',
849N/A arch_srcs,
849N/A include_dirs = include_dirs,
849N/A extra_compile_args = compile_args,
849N/A extra_link_args = link_args,
849N/A define_macros = [('_FILE_OFFSET_BITS', '64')]
849N/A ),
849N/A Extension(
2242N/A 'pspawn',
2242N/A pspawn_srcs,
2242N/A include_dirs = include_dirs,
2242N/A extra_compile_args = compile_args,
2242N/A extra_link_args = link_args,
2242N/A define_macros = [('_FILE_OFFSET_BITS', '64')]
2242N/A ),
2242N/A ]
2337N/A else:
2337N/A elf_libraries += [ 'ssl' ]
2242N/A
2242N/Asetup(cmdclass = cmdclasses,
849N/A name = 'ips',
2508N/A version = '1.0',
2508N/A package_dir = {'pkg':'modules'},
2508N/A packages = packages,
2508N/A data_files = data_files,
2508N/A ext_package = 'pkg',
2508N/A ext_modules = ext_modules,
2508N/A )
2508N/A