From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Mon, 15 Oct 2007 18:52:26 +0000 (-0700)
Subject: setup: use the new find_exe module to find trial
X-Git-Tag: allmydata-tahoe-0.6.1~10
X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/FOOURL?a=commitdiff_plain;h=bf3f629a683fd4cbfb9bb36c3eeb8acf0573cdb6;p=tahoe-lafs%2Ftahoe-lafs.git

setup: use the new find_exe module to find trial
---

diff --git a/Makefile b/Makefile
index a9537b54..ac39b2be 100644
--- a/Makefile
+++ b/Makefile
@@ -6,26 +6,15 @@ default: build
 PYTHON=python
 PATHSEP=$(shell python -c 'import os ; print os.pathsep')
 OSSEP=$(shell python -c 'import os ; print os.sep')
-TRIALPATH=$(shell which trial.py 2>/dev/null)
-ifeq ($(TRIALPATH),)
-TRIALPATH=$(shell which trial 2>/dev/null)
-endif
-ifeq ($(TRIALPATH),)
-TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial.py\"))")
-endif
-ifeq ($(TRIALPATH),)
-TRIALPATH=$(shell $(PYTHON) -c "import os, sys; print repr(os.path.join(sys.prefix, \"Scripts\", \"trial\"))")
-endif
 
 REACTOR=
 
 PLAT = $(strip $(shell python -c "import sys ; print sys.platform"))
 ifeq ($(PLAT),win32)
  # The platform is Windows with cygwin build tools and the native Python interpreter.
- TRIALPATH := $(shell cygpath -w $(TRIALPATH))
  SUPPORT = $(shell cygpath -w $(shell pwd))\support
  SUPPORTLIB := $(SUPPORT)\Lib\site-packages
- SRCPATH := $(shell cygpath -w $(shell pwd))\src
+ SRCPATH := $(shell cygpath -w $(shell pwd)/src)
  CHECK_PYWIN32_DEP := check-pywin32-dep
 else
  PYVER=$(shell $(PYTHON) misc/pyver.py)
@@ -35,6 +24,8 @@ else
  CHECK_PYWIN32_DEP := 
 endif
 
+TRIALCMD := $(shell PYTHONPATH="$(PYTHONPATH)$(PATHSEP)$(SRCPATH)" $(PYTHON) misc/find_trial.py)
+
 ifeq ($(PLAT),cygwin)
 REACTOR = poll
 endif
@@ -45,7 +36,7 @@ else
 	REACTOROPT := 
 endif
 
-TRIAL=$(PYTHON) -u "$(TRIALPATH)" --rterrors $(REACTOROPT)
+TRIAL=PYTHONUNBUFFERED=1 $(TRIALCMD) --rterrors $(REACTOROPT)
 
 # build-deps wants setuptools to have been built first. It's easiest to
 # accomplish this by depending upon the tahoe compile.
diff --git a/misc/find_trial.py b/misc/find_trial.py
new file mode 100644
index 00000000..2a6d817e
--- /dev/null
+++ b/misc/find_trial.py
@@ -0,0 +1,10 @@
+import sys
+
+from allmydata.util import find_exe
+
+if __name__ == "__main__":
+    cmd = find_exe.find_exe("trial")
+    if cmd:
+        print " ".join(cmd).replace("\\", "/")
+    else:
+        sys.exit(1)