setup.py revision 2499
0N/A#!/usr/bin/python2.6
20N/A#
20N/A# CDDL HEADER START
20N/A#
20N/A# The contents of this file are subject to the terms of the
20N/A# Common Development and Distribution License (the "License").
20N/A# You may not use this file except in compliance with the License.
20N/A#
20N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20N/A# or http://www.opensolaris.org/os/licensing.
20N/A# See the License for the specific language governing permissions
20N/A# and limitations under the License.
20N/A#
20N/A# When distributing Covered Code, include this CDDL HEADER in each
20N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20N/A# If applicable, add the following below this CDDL HEADER, with the
20N/A# fields enclosed by brackets "[]" replaced with your own identifying
20N/A# information: Portions Copyright [yyyy] [name of copyright owner]
20N/A#
20N/A# CDDL HEADER END
20N/A#
20N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
20N/A#
20N/A
20N/Aimport errno
22N/Aimport fnmatch
0N/Aimport os
50N/Aimport platform
50N/Aimport stat
50N/Aimport sys
50N/Aimport shutil
50N/Aimport re
50N/Aimport subprocess
50N/Aimport tarfile
50N/Aimport tempfile
50N/Aimport urllib
50N/Aimport py_compile
50N/Aimport hashlib
50N/A
50N/Afrom distutils.errors import DistutilsError
50N/Afrom distutils.core import setup, Extension
50N/Afrom distutils.cmd import Command
50N/Afrom distutils.command.install import install as _install
0N/Afrom distutils.command.build import build as _build
55N/Afrom distutils.command.build_py import build_py as _build_py
54N/Afrom distutils.command.bdist import bdist as _bdist
26N/Afrom distutils.command.clean import clean as _clean
0N/Afrom distutils.dist import Distribution
0N/A
0N/Afrom distutils.sysconfig import get_python_inc
0N/Aimport distutils.file_util as file_util
52N/Aimport distutils.dir_util as dir_util
0N/Aimport distutils.util as util
22N/A
119N/Aosname = platform.uname()[0].lower()
119N/Aostype = arch = 'unknown'
145N/Aif osname == 'sunos':
0N/A arch = platform.processor()
34N/A ostype = "posix"
22N/Aelif osname == 'linux':
22N/A arch = "linux_" + platform.machine()
46N/A ostype = "posix"
34N/Aelif osname == 'windows':
22N/A arch = osname
22N/A ostype = "windows"
114N/Aelif osname == 'darwin':
26N/A arch = osname
23N/A ostype = "posix"
23N/Aelif osname == 'aix':
26N/A arch = "aix"
26N/A ostype = "posix"
135N/A
135N/Apwd = os.path.normpath(sys.path[0])
26N/A
135N/A#
14N/A# Unbuffer stdout and stderr. This helps to ensure that subprocess output
145N/A# is properly interleaved with output from this program.
145N/A#
145N/Asys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)
145N/Asys.stderr = os.fdopen(sys.stderr.fileno(), "w", 0)
145N/A
145N/Adist_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "dist_" + arch))
145N/Abuild_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "build_" + arch))
145N/Aif "ROOT" in os.environ and os.environ["ROOT"] != "":
145N/A root_dir = os.environ["ROOT"]
145N/Aelse:
145N/A root_dir = os.path.normpath(os.path.join(pwd, os.pardir, "proto", "root_" + arch))
30N/Apkgs_dir = os.path.normpath(os.path.join(pwd, os.pardir, "packages", arch))
14N/Aextern_dir = os.path.normpath(os.path.join(pwd, "extern"))
0N/A
25N/Apy_install_dir = 'usr/lib/python2.6/vendor-packages'
0N/A
26N/Ascripts_dir = 'usr/bin'
26N/Alib_dir = 'usr/lib'
145N/Asvc_method_dir = 'lib/svc/method'
30N/A
50N/Aman1_dir = 'usr/share/man/man1'
50N/Aman1m_dir = 'usr/share/man/man1m'
50N/Aman5_dir = 'usr/share/man/man5'
30N/Aresource_dir = 'usr/share/lib/pkg'
30N/Asmf_app_dir = 'lib/svc/manifest/application/pkg'
30N/Aexecattrd_dir = 'etc/security/exec_attr.d'
30N/Aauthattrd_dir = 'etc/security/auth_attr.d'
145N/Asysrepo_dir = 'etc/pkg/sysrepo'
30N/Asysrepo_logs_dir = 'var/log/pkg/sysrepo'
30N/Asysrepo_cache_dir = 'var/cache/pkg/sysrepo'
50N/A
45N/A
30N/A# A list of source, destination tuples of modules which should be hardlinked
50N/A# together if the os supports it and otherwise copied.
45N/Ahardlink_modules = []
30N/A
30N/Ascripts_sunos = {
30N/A scripts_dir: [
30N/A ['client.py', 'pkg'],
45N/A ['pkgdep.py', 'pkgdepend'],
30N/A ['pkgrepo.py', 'pkgrepo'],
145N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
119N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
119N/A ['util/publish/pkglint.py', 'pkglint'],
119N/A ['util/publish/pkgmerge.py', 'pkgmerge'],
119N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
119N/A ['publish.py', 'pkgsend'],
119N/A ['pull.py', 'pkgrecv'],
119N/A ['sign.py', 'pkgsign'],
119N/A ['packagemanager.py', 'packagemanager'],
119N/A ['updatemanager.py', 'pm-updatemanager'],
119N/A ],
119N/A lib_dir: [
119N/A ['depot.py', 'pkg.depotd'],
119N/A ['checkforupdates.py', 'pm-checkforupdates'],
119N/A ['updatemanagernotifier.py', 'updatemanagernotifier'],
119N/A ['launch.py', 'pm-launch'],
119N/A ['sysrepo.py', 'pkg.sysrepo'],
119N/A ],
119N/A svc_method_dir: [
119N/A ['svc/svc-pkg-depot', 'svc-pkg-depot'],
119N/A ['svc/svc-pkg-mdns', 'svc-pkg-mdns'],
119N/A ['svc/svc-pkg-sysrepo', 'svc-pkg-sysrepo'],
119N/A ],
119N/A }
119N/A
119N/Ascripts_windows = {
119N/A scripts_dir: [
119N/A ['client.py', 'client.py'],
119N/A ['pkgrepo.py', 'pkgrepo.py'],
119N/A ['publish.py', 'publish.py'],
119N/A ['pull.py', 'pull.py'],
119N/A ['scripts/pkg.bat', 'pkg.bat'],
145N/A ['scripts/pkgsend.bat', 'pkgsend.bat'],
30N/A ['scripts/pkgrecv.bat', 'pkgrecv.bat'],
30N/A ],
30N/A lib_dir: [
145N/A ['depot.py', 'depot.py'],
30N/A ['scripts/pkg.depotd.bat', 'pkg.depotd.bat'],
30N/A ],
54N/A }
119N/A
119N/Ascripts_other_unix = {
54N/A scripts_dir: [
54N/A ['client.py', 'client.py'],
54N/A ['pkgdep.py', 'pkgdep'],
54N/A ['util/publish/pkgdiff.py', 'pkgdiff'],
54N/A ['util/publish/pkgfmt.py', 'pkgfmt'],
54N/A ['util/publish/pkgmogrify.py', 'pkgmogrify'],
54N/A ['pull.py', 'pull.py'],
30N/A ['publish.py', 'publish.py'],
30N/A ['scripts/pkg.sh', 'pkg'],
30N/A ['scripts/pkgsend.sh', 'pkgsend'],
30N/A ['scripts/pkgrecv.sh', 'pkgrecv'],
30N/A ],
30N/A lib_dir: [
0N/A ['depot.py', 'depot.py'],
145N/A ['scripts/pkg.depotd.sh', 'pkg.depotd'],
22N/A ],
22N/A }
135N/A
135N/A# indexed by 'osname'
135N/Ascripts = {
135N/A "sunos": scripts_sunos,
22N/A "linux": scripts_other_unix,
22N/A "windows": scripts_windows,
22N/A "darwin": scripts_other_unix,
22N/A "aix" : scripts_other_unix,
26N/A "unknown": scripts_sunos,
0N/A }
22N/A
22N/Aman1_files = [
22N/A 'man/packagemanager.1',
22N/A 'man/pkg.1',
22N/A 'man/pkgdepend.1',
22N/A 'man/pkgdiff.1',
22N/A 'man/pkgfmt.1',
22N/A 'man/pkglint.1',
0N/A 'man/pkgmerge.1',
0N/A 'man/pkgmogrify.1',
145N/A 'man/pkgsend.1',
135N/A 'man/pkgsign.1',
135N/A 'man/pkgrecv.1',
135N/A 'man/pkgrepo.1',
135N/A 'man/pm-updatemanager.1',
0N/A ]
145N/Aman1m_files = [
0N/A 'man/pkg.depotd.1m',
0N/A 'man/pkg.sysrepo.1m'
22N/A ]
26N/Aman5_files = [
22N/A 'man/pkg.5'
26N/A ]
22N/Apackages = [
145N/A 'pkg',
135N/A 'pkg.actions',
135N/A 'pkg.bundle',
135N/A 'pkg.client',
135N/A 'pkg.client.linkedimage',
22N/A 'pkg.client.transport',
145N/A 'pkg.file_layout',
22N/A 'pkg.flavor',
22N/A 'pkg.lint',
26N/A 'pkg.portable',
22N/A 'pkg.publish',
26N/A 'pkg.server'
0N/A ]
145N/A
135N/Apylint_targets = [
135N/A 'pkg.altroot',
135N/A 'pkg.client.linkedimage',
135N/A 'pkg.client.pkgdefs',
145N/A ]
0N/A
0N/Aweb_files = []
0N/Afor entry in os.walk("web"):
26N/A web_dir, dirs, files = entry
22N/A if not files:
0N/A continue
20N/A web_files.append((os.path.join(resource_dir, web_dir), [
34N/A os.path.join(web_dir, f) for f in files
21N/A if f != "Makefile"
34N/A ]))
0N/A
145N/Asmf_app_files = [
145N/A 'svc/pkg-mdns.xml',
145N/A 'svc/pkg-server.xml',
145N/A 'svc/pkg-update.xml',
145N/A 'svc/pkg-system-repository.xml',
145N/A 'svc/zoneproxy-client.xml',
145N/A 'svc/zoneproxyd.xml'
145N/A ]
145N/Aresource_files = [
145N/A 'util/opensolaris.org.sections',
145N/A 'util/pkglintrc',
145N/A ]
145N/Asysrepo_files = [
145N/A 'util/apache2/sysrepo/sysrepo_httpd.conf.mako',
145N/A 'util/apache2/sysrepo/sysrepo_publisher_response.mako',
145N/A ]
145N/Asysrepo_log_stubs = [
145N/A 'util/apache2/sysrepo/logs/access_log',
0N/A 'util/apache2/sysrepo/logs/error_log',
0N/A ]
0N/Aexecattrd_files = ['util/misc/exec_attr.d/SUNWipkg',
145N/A 'util/misc/exec_attr.d/SUNWipkg-gui']
145N/Aauthattrd_files = ['util/misc/auth_attr.d/SUNWipkg']
145N/Asyscallat_srcs = [
145N/A 'modules/syscallat.c'
145N/A ]
145N/Apspawn_srcs = [
145N/A 'modules/pspawn.c'
145N/A ]
145N/Aelf_srcs = [
26N/A 'modules/elf.c',
145N/A 'modules/elfextract.c',
145N/A 'modules/liblist.c',
145N/A ]
145N/Aarch_srcs = [
145N/A 'modules/arch.c'
145N/A ]
145N/A_actions_srcs = [
145N/A 'modules/actions/_actions.c'
145N/A ]
145N/Asolver_srcs = [
145N/A 'modules/solver/solver.c',
145N/A 'modules/solver/py_solver.c'
145N/A ]
145N/Asolver_link_args = ["-lm", "-lc"]
145N/Aif osname == 'sunos':
26N/A solver_link_args = ["-ztext"] + solver_link_args
145N/A
145N/A# Runs lint on the extension module source code
145N/Aclass pylint_func(Command):
145N/A description = "Runs pylint tools over IPS python source code"
145N/A user_options = []
145N/A
145N/A def initialize_options(self):
145N/A pass
145N/A
145N/A def finalize_options(self):
145N/A pass
145N/A
145N/A # Make string shell-friendly
145N/A @staticmethod
145N/A def escape(astring):
145N/A return astring.replace(' ', '\\ ')
145N/A
145N/A def run(self, quiet=False):
145N/A proto = os.path.join(root_dir, py_install_dir)
145N/A sys.path.insert(0, proto)
145N/A
145N/A # Insert tests directory onto sys.path so any custom checkers
0N/A # can be found.
0N/A sys.path.insert(0, os.path.join(pwd, 'tests'))
0N/A # assumes pylint is accessible on the sys.path
25N/A from pylint import lint
0N/A
30N/A #
30N/A # For some reason, the load-plugins option, when used in the
0N/A # rcfile, does not work, so we put it here instead, to load
0N/A # our custom checkers.
0N/A #
25N/A # Unfortunately, pylint seems pretty fragile and will crash if
0N/A # we try to run it over all the current pkg source. Hence for
30N/A # now we only run it over a subset of the source. As source
30N/A # files are made pylint clean they should be added to the
0N/A # pylint_targets list.
55N/A #
55N/A args = ['--load-plugins=multiplatform']
55N/A if quiet:
55N/A args += ['--reports=no']
145N/A args += ['--rcfile', os.path.join(pwd, 'tests', 'pylintrc')]
145N/A args += pylint_targets
22N/A lint.Run(args)
135N/A
135N/A
135N/Aclass pylint_func_quiet(pylint_func):
135N/A
135N/A def run(self, quiet=False):
135N/A pylint_func.run(self, quiet=True)
135N/A
135N/A
135N/Ainclude_dirs = [ 'modules' ]
135N/Alint_flags = [ '-u', '-axms', '-erroff=E_NAME_DEF_NOT_USED2' ]
135N/A
135N/A# Runs lint on the extension module source code
135N/Aclass clint_func(Command):
135N/A description = "Runs lint tools over IPS C extension source code"
135N/A user_options = []
135N/A
135N/A def initialize_options(self):
22N/A pass
26N/A
26N/A def finalize_options(self):
26N/A pass
145N/A
145N/A # Make string shell-friendly
82N/A @staticmethod
22N/A def escape(astring):
return astring.replace(' ', '\\ ')
def run(self):
# assumes lint is on the $PATH
if osname == 'sunos' or osname == "linux":
archcmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
["%s%s" % ("-I", k) for k in include_dirs] + \
['-I' + self.escape(get_python_inc())] + \
arch_srcs
elfcmd = ['lint'] + lint_flags + \
["%s%s" % ("-I", k) for k in include_dirs] + \
['-I' + self.escape(get_python_inc())] + \
["%s%s" % ("-l", k) for k in elf_libraries] + \
elf_srcs
_actionscmd = ['lint'] + lint_flags + \
["%s%s" % ("-I", k) for k in include_dirs] + \
['-I' + self.escape(get_python_inc())] + \
_actions_srcs
pspawncmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
["%s%s" % ("-I", k) for k in include_dirs] + \
['-I' + self.escape(get_python_inc())] + \
pspawn_srcs
syscallatcmd = ['lint'] + lint_flags + ['-D_FILE_OFFSET_BITS=64'] + \
["%s%s" % ("-I", k) for k in include_dirs] + \
['-I' + self.escape(get_python_inc())] + \
syscallat_srcs
print(" ".join(archcmd))
os.system(" ".join(archcmd))
print(" ".join(elfcmd))
os.system(" ".join(elfcmd))
print(" ".join(_actionscmd))
os.system(" ".join(_actionscmd))
print(" ".join(pspawncmd))
os.system(" ".join(pspawncmd))
print(" ".join(syscallatcmd))
os.system(" ".join(syscallatcmd))
# Runs both C and Python lint
class lint_func(Command):
description = "Runs C and Python lint checkers"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
# Make string shell-friendly
@staticmethod
def escape(astring):
return astring.replace(' ', '\\ ')
def run(self):
clint_func(Distribution()).run()
pylint_func(Distribution()).run()
class install_func(_install):
def initialize_options(self):
_install.initialize_options(self)
# PRIVATE_BUILD set in the environment tells us to put the build
# directory into the .pyc files, rather than the final
# installation directory.
private_build = os.getenv("PRIVATE_BUILD", None)
if private_build is None:
self.install_lib = py_install_dir
self.install_data = os.path.sep
self.root = root_dir
else:
self.install_lib = os.path.join(root_dir, py_install_dir)
self.install_data = root_dir
# This is used when installing scripts, below, but it isn't a
# standard distutils variable.
self.root_dir = root_dir
def run(self):
"""
At the end of the install function, we need to rename some files
because distutils provides no way to rename files as they are
placed in their install locations.
Also, make sure that cherrypy and other external dependencies
are installed.
"""
_install.run(self)
for o_src, o_dest in hardlink_modules:
for e in [".py", ".pyc"]:
src = util.change_root(self.root_dir, o_src + e)
dest = util.change_root(
self.root_dir, o_dest + e)
if ostype == "posix":
if os.path.exists(dest) and \
os.stat(src)[stat.ST_INO] != \
os.stat(dest)[stat.ST_INO]:
os.remove(dest)
file_util.copy_file(src, dest,
link="hard", update=1)
else:
file_util.copy_file(src, dest, update=1)
for d, files in scripts[osname].iteritems():
for (srcname, dstname) in files:
dst_dir = util.change_root(self.root_dir, d)
dst_path = util.change_root(self.root_dir,
os.path.join(d, dstname))
dir_util.mkpath(dst_dir, verbose = True)
file_util.copy_file(srcname, dst_path, update = True)
# make scripts executable
os.chmod(dst_path,
os.stat(dst_path).st_mode
| stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
def hash_sw(swname, swarc, swhash):
if swhash == None:
return True
print "checksumming %s" % swname
hash = hashlib.sha1()
f = open(swarc, "rb")
while True:
data = f.read(65536)
if data == "":
break
hash.update(data)
f.close()
if hash.hexdigest() == swhash:
return True
else:
print >> sys.stderr, "bad checksum! %s != %s" % \
(swhash, hash.hexdigest())
return False
def prep_sw(swname, swarc, swdir, swurl, swhash):
swarc = os.path.join(extern_dir, swarc)
swdir = os.path.join(extern_dir, swdir)
if not os.path.exists(extern_dir):
os.mkdir(extern_dir)
if not os.path.exists(swarc):
print "downloading %s" % swname
try:
fname, hdr = urllib.urlretrieve(swurl, swarc)
except IOError:
pass
if not os.path.exists(swarc):
print >> sys.stderr, "Unable to retrieve %s.\n" \
"Please retrieve the file " \
"and place it at: %s\n" % (swurl, swarc)
# remove a partial download or error message from proxy
remove_sw(swname)
sys.exit(1)
if not os.path.exists(swdir):
if not hash_sw(swname, swarc, swhash):
sys.exit(1)
print "unpacking %s" % swname
tar = tarfile.open(swarc)
# extractall doesn't exist until python 2.5
for m in tar.getmembers():
tar.extract(m, extern_dir)
tar.close()
# If there are patches, apply them now.
patchdir = os.path.join("patch", swname)
already_patched = os.path.join(swdir, ".patched")
if os.path.exists(patchdir) and not os.path.exists(already_patched):
patches = os.listdir(patchdir)
for p in patches:
patchpath = os.path.join(os.path.pardir,
os.path.pardir, patchdir, p)
print "Applying %s to %s" % (p, swname)
args = ["patch", "-d", swdir, "-i", patchpath, "-p0"]
if osname == "windows":
args.append("--binary")
ret = subprocess.Popen(args).wait()
if ret != 0:
print >> sys.stderr, \
"patch failed and returned %d." % ret
print >> sys.stderr, \
"Command was: %s" % " ".join(args)
sys.exit(1)
file(already_patched, "w").close()
def run_cmd(args, swdir, env=None):
if env is None:
env = os.environ
ret = subprocess.Popen(args, cwd=swdir, env=env).wait()
if ret != 0:
print >> sys.stderr, \
"install failed and returned %d." % ret
print >> sys.stderr, \
"Command was: %s" % " ".join(args)
sys.exit(1)
def remove_sw(swname):
print("deleting %s" % swname)
for file in os.listdir(extern_dir):
if fnmatch.fnmatch(file, "%s*" % swname):
fpath = os.path.join(extern_dir, file)
if os.path.isfile(fpath):
os.unlink(fpath)
else:
shutil.rmtree(fpath, True)
class build_func(_build):
def initialize_options(self):
_build.initialize_options(self)
self.build_base = build_dir
def get_hg_version():
try:
p = subprocess.Popen(['hg', 'id', '-i'], stdout = subprocess.PIPE)
return p.communicate()[0].strip()
except OSError:
print >> sys.stderr, "ERROR: unable to obtain mercurial version"
return "unknown"
def syntax_check(filename):
""" Run python's compiler over the file, and discard the results.
Arrange to generate an exception if the file does not compile.
This is needed because distutil's own use of pycompile (in the
distutils.utils module) is broken, and doesn't stop on error. """
try:
py_compile.compile(filename, os.devnull, doraise=True)
except py_compile.PyCompileError, e:
res = ""
for err in e.exc_value:
if isinstance(err, basestring):
res += err + "\n"
continue
# Assume it's a tuple of (filename, lineno, col, code)
fname, line, col, code = err
res += "line %d, column %s, in %s:\n%s" % (line,
col or "unknown", fname, code)
raise DistutilsError(res)
class build_py_func(_build_py):
# override the build_module method to do VERSION substitution on pkg/__init__.py
def build_module (self, module, module_file, package):
if module == "__init__" and package == "pkg":
versionre = '(?m)^VERSION[^"]*"([^"]*)"'
# Grab the previously-built version out of the build
# tree.
try:
ocontent = \
file(self.get_module_outfile(self.build_lib,
[package], module)).read()
ov = re.search(versionre, ocontent).group(1)
except IOError:
ov = None
v = get_hg_version()
vstr = 'VERSION = "%s"' % v
# If the versions haven't changed, there's no need to
# recompile.
if v == ov:
return
mcontent = file(module_file).read()
mcontent = re.sub(versionre, vstr, mcontent)
tmpfd, tmp_file = tempfile.mkstemp()
os.write(tmpfd, mcontent)
os.close(tmpfd)
print "doing version substitution: ", v
rv = _build_py.build_module(self, module, tmp_file, package)
os.unlink(tmp_file)
return rv
# Will raise a DistutilsError on failure.
syntax_check(module_file)
return _build_py.build_module(self, module, module_file, package)
class clean_func(_clean):
def initialize_options(self):
_clean.initialize_options(self)
self.build_base = build_dir
class clobber_func(Command):
user_options = []
description = "Deletes any and all files created by setup"
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# nuke everything
print("deleting " + dist_dir)
shutil.rmtree(dist_dir, True)
print("deleting " + build_dir)
shutil.rmtree(build_dir, True)
print("deleting " + root_dir)
shutil.rmtree(root_dir, True)
print("deleting " + pkgs_dir)
shutil.rmtree(pkgs_dir, True)
print("deleting " + extern_dir)
shutil.rmtree(extern_dir, True)
class test_func(Command):
# NOTE: these options need to be in sync with tests/run.py and the
# list of options stored in initialize_options below. The first entry
# in each tuple must be the exact name of a member variable.
user_options = [
("archivedir=", 'a', "archive failed tests <dir>"),
("baselinefile=", 'b', "baseline file <file>"),
("coverage", "c", "collect code coverage data"),
("genbaseline", 'g', "generate test baseline"),
("only=", "o", "only <regex>"),
("parseable", 'p', "parseable output"),
("port=", "z", "lowest port to start a depot on"),
("timing", "t", "timing file <file>"),
("verbosemode", 'v', "run tests in verbose mode"),
("enableguitests", 'u', "enable IPS GUI tests, disabled by default"),
("stoponerr", 'x', "stop when a baseline mismatch occurs"),
("debugoutput", 'd', "emit debugging output"),
("showonexpectedfail", 'f',
"show all failure info, even for expected fails"),
("startattest=", 's', "start at indicated test"),
("jobs=", 'j', "number of parallel processes to use"),
("quiet", "q", "use the dots as the output format"),
]
description = "Runs unit and functional tests"
def initialize_options(self):
self.only = ""
self.baselinefile = ""
self.verbosemode = 0
self.parseable = 0
self.genbaseline = 0
self.timing = 0
self.coverage = 0
self.stoponerr = 0
self.debugoutput = 0
self.showonexpectedfail = 0
self.startattest = ""
self.archivedir = ""
self.port = 12001
self.jobs = 1
self.quiet = False
def finalize_options(self):
pass
def run(self):
os.putenv('PYEXE', sys.executable)
os.chdir(os.path.join(pwd, "tests"))
# Reconstruct the cmdline and send that to run.py
cmd = [sys.executable, "run.py"]
args = ""
if "test" in sys.argv:
args = sys.argv[sys.argv.index("test")+1:]
cmd.extend(args)
subprocess.call(cmd)
class dist_func(_bdist):
def initialize_options(self):
_bdist.initialize_options(self)
self.dist_dir = dist_dir
# These are set to real values based on the platform, down below
compile_args = None
if osname in ("sunos", "linux", "darwin"):
compile_args = [ "-O3" ]
link_args = None
ext_modules = [
Extension(
'actions._actions',
_actions_srcs,
include_dirs = include_dirs,
extra_compile_args = compile_args,
extra_link_args = link_args
),
Extension(
'solver',
solver_srcs,
include_dirs = include_dirs + ["."],
extra_compile_args = compile_args,
extra_link_args = solver_link_args,
define_macros = [('_FILE_OFFSET_BITS', '64')]
),
]
elf_libraries = None
data_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,
'pylint_quiet': pylint_func_quiet,
'clean': clean_func,
'clobber': clobber_func,
'test': test_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 += [
(smf_app_dir, smf_app_files),
(execattrd_dir, execattrd_files),
(authattrd_dir, authattrd_files),
(sysrepo_dir, sysrepo_files),
(sysrepo_logs_dir, sysrepo_log_stubs),
(sysrepo_cache_dir, {})
]
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,
)