aboutsummaryrefslogtreecommitdiff
path: root/pywrap
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2010-12-28 19:14:25 +0000
committerRob Austein <sra@hactrn.net>2010-12-28 19:14:25 +0000
commit31e451b448ad5bad4237776172675fc6a74e0205 (patch)
tree27cb301578c614656f3e2ab10758a00d842c64a6 /pywrap
parente53a56120ca7aeafa2c85bfb6dc502709fbef74f (diff)
Conditionalize which subdirectories we build, based on what configure
finds and what configure options are enabled. Building with system OpenSSL doesn't quite work yet, still too many hardwired paths in Makefiles. svn path=/Makefile.in; revision=3578
Diffstat (limited to 'pywrap')
-rw-r--r--pywrap/Makefile9
-rw-r--r--pywrap/build.py54
-rw-r--r--pywrap/pywrap.c6
3 files changed, 69 insertions, 0 deletions
diff --git a/pywrap/Makefile b/pywrap/Makefile
new file mode 100644
index 00000000..7c37faab
--- /dev/null
+++ b/pywrap/Makefile
@@ -0,0 +1,9 @@
+# $Id$
+
+all: pywrap
+
+pywrap: pywrap.c
+ python build.py
+
+clean:
+ rm -f *.o pywrap
diff --git a/pywrap/build.py b/pywrap/build.py
new file mode 100644
index 00000000..23bd4cdf
--- /dev/null
+++ b/pywrap/build.py
@@ -0,0 +1,54 @@
+"""
+Hack to build our Python wrapper. Basic problem here is that we need
+a bunch of arguments that were given to ./configure when Python itself
+was built, and there appears to be no real consistancy about how
+different unix-like distributions use the various parameters, so even
+the standard python-config script is not smart enough to figure out
+which arguments we need on every platform. Feh.
+
+This script is an attempt to pull the relevant information out of the
+distutils.sysconfig module. If I understood distutils better, I could
+probably figure out some way to wrap this whole thing up nicely in the
+distutils framework; if you understand how to do this, please do so
+and send me the code.
+
+As it is, this is a minimal hack to get the job done, and probably a
+bit fragile. Much of the code is taken from python-config. If
+there's any real documentation on how to do this sort of thing, I have
+not found it yet. YMMV. Beware Of Dog.
+
+$Id$
+"""
+
+import os, subprocess, sys
+
+from distutils.sysconfig import (get_config_var as getvar,
+ get_python_inc as getinc)
+
+openssl_dir = os.path.realpath(os.path.join(os.getcwd(), "../openssl/openssl"))
+
+cmd = getvar("CC").split()
+
+cmd.append("-o")
+cmd.append("pywrap")
+cmd.append("pywrap.c")
+
+cmd.append("-Wl,-rpath,%s" % openssl_dir)
+cmd.append("-L%s" % openssl_dir)
+cmd.append("-lcrypto")
+cmd.append("-lssl")
+
+cmd.append("-I%s" % getinc(plat_specific = False))
+cmd.append("-I%s" % getinc(plat_specific = True))
+
+if not getvar("Py_ENABLE_SHARED"):
+ cmd.append("-L%s" % getvar("LIBPL"))
+
+for var in ("CFLAGS", "LIBS", "SYSLIBS", "LDFLAGS"):
+ cmd.extend(getvar(var).split())
+
+cmd.append("-lpython%s" % getvar("VERSION"))
+
+print " ".join(cmd)
+
+sys.exit(subprocess.call(cmd))
diff --git a/pywrap/pywrap.c b/pywrap/pywrap.c
new file mode 100644
index 00000000..10638721
--- /dev/null
+++ b/pywrap/pywrap.c
@@ -0,0 +1,6 @@
+#include <Python.h>
+
+int main(int argc, char **argv)
+{
+ return Py_Main(argc, argv);
+}