Rev 1314: Merge support for more apr configs. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Mon Jun 23 14:24:16 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1314
revision-id: jelmer at samba.org-20080623132415-nzadc6yk8wzh6bij
parent: jelmer at samba.org-20080623132028-fvaugcbyuuemjipy
parent: martin.vgagern at gmx.net-20080623075445-grjvd3ith3wsjn7k
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-06-23 15:24:15 +0200
message:
Merge support for more apr configs.
modified:
setup.py setup.py-20060502115218-86950492da22353f
------------------------------------------------------------
revno: 1267.1.1
revision-id: martin.vgagern at gmx.net-20080623075445-grjvd3ith3wsjn7k
parent: jelmer at samba.org-20080622085156-0i0l7dprgs9flztq
committer: Martin von Gagern <Martin.vGagern at gmx.net>
branch nick: apr-config-autodetect
timestamp: Mon 2008-06-23 09:54:45 +0200
message:
Autodetect apr-config and apr-1-config, override with APR_CONFIG environment
setting.
modified:
setup.py setup.py-20060502115218-86950492da22353f
=== modified file 'setup.py'
--- a/setup.py 2008-06-23 12:24:55 +0000
+++ b/setup.py 2008-06-23 13:24:15 +0000
@@ -6,12 +6,58 @@
from distutils.extension import Extension
import os
+class CommandException(Exception):
+ """Encapsulate exit status of apr-config execution"""
+ def __init__(self, msg, cmd, arg, status, val):
+ self.message = msg % (cmd, val)
+ super(CommandException, self).__init__(self.message)
+ self.cmd = cmd
+ self.arg = arg
+ self.status = status
+ def not_found(self):
+ return os.WIFEXITED(self.status) and os.WEXITSTATUS(self.status) == 127
+
+def run_cmd(cmd, arg):
+ """Run specified command with given arguments, handling status"""
+ f = os.popen("'%s' %s" % (cmd, arg))
+ dir = f.read().rstrip("\n")
+ status = f.close()
+ if status is None:
+ return dir
+ if os.WIFEXITED(status):
+ code = os.WEXITSTATUS(status)
+ if code == 0:
+ return dir
+ raise CommandException("%s exited with status %d",
+ cmd, arg, status, code)
+ if os.WIFSIGNALED(status):
+ signal = os.WTERMSIG(status)
+ raise CommandException("%s killed by signal %d",
+ cmd, arg, status, signal)
+ raise CommandException("%s terminated abnormally (%d)",
+ cmd, arg, status, status)
+
+def apr_config(arg):
+ apr_config_cmd = os.getenv("APR_CONFIG")
+ if apr_config_cmd is None:
+ cmds = ["apr-config", "apr-1-config"]
+ for cmd in cmds:
+ try:
+ res = run_cmd(cmd, arg)
+ apr_config_cmd = cmd
+ break
+ except CommandException, e:
+ if not e.not_found():
+ raise
+ else:
+ raise Exception("apr-config not found."
+ " Please set APR_CONFIG environment variable")
+ else:
+ res = run_cmd(apr_config_cmd, arg)
+ return res
+
def apr_build_data():
"""Determine the APR header file location."""
- def apr_config(arg):
- f = os.popen("apr-config %s" % arg)
- dir = f.read().rstrip("\n")
- return dir
includedir = apr_config("--includedir")
if not os.path.isdir(includedir):
raise Exception("APR development headers not found")
More information about the bazaar-commits
mailing list