From 07fd8766d183713ffc36241ba31bcc82ac2308f4 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Thu, 14 Dec 2006 03:59:51 -0700
Subject: [PATCH] Makefile: add correct generated build/lib.linux-i686-2.4
 directory to PYTHONPATH for tests

---
 Makefile    | 21 ++++++++++++++++++---
 builddir.py | 10 ++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 builddir.py

diff --git a/Makefile b/Makefile
index 8df28c0f..6e635f6c 100644
--- a/Makefile
+++ b/Makefile
@@ -12,17 +12,32 @@ run-client2:
 run-client3:
 	cd client-basedir3 && PYTHONPATH=.. twistd -noy ../client.tac
 
-test:
-	trial allmydata
+.PHONY: build
+build:
+	python setup.py build
+# where does this go? in a platform-specific directory under build/ . Use
+# builddir.py to locate it.
+
+ifneq ($(PYTHONPATH),)
+PP=PYTHONPATH=${PYTHONPATH}:$(shell python ./builddir.py)
+else
+PP=PYTHONPATH=$(shell python ./builddir.py)
+endif
+
+test: build
+	$(PP) trial allmydata
 
 test-figleaf:
-	trial --reporter=bwverbose-figleaf allmydata
+	$(PP) trial --reporter=bwverbose-figleaf allmydata
 	figleaf2html -d coverage-html -x allmydata/test/figleaf.excludes
 # after doing test-figleaf, point your browser at coverage-html/index.html
 
 figleaf-output:
 	figleaf2html -d coverage-html -x allmydata/test/figleaf.excludes
 
+clean:
+	rm -rf build
+
 create_dirs:
 	mkdir -p queen-basedir
 	mkdir -p client-basedir
diff --git a/builddir.py b/builddir.py
new file mode 100644
index 00000000..dc777786
--- /dev/null
+++ b/builddir.py
@@ -0,0 +1,10 @@
+#! /usr/bin/python
+
+import sys, os.path
+from distutils.util import get_platform
+
+# because we use extension modules, we need a platform+version-specific
+# libdir. If we were using a pure-python module, this would just be "lib".
+plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
+libdir = os.path.join("build", "lib" + plat_specifier)
+print libdir
-- 
2.45.2