[BioPython] Some proposed code-cleanup

Yves Bastide Yves.Bastide at irisa.fr
Wed Jul 2 15:35:40 EDT 2003


Jeffrey Chang wrote:
> 
> On Monday, June 23, 2003, at 01:58  AM, Andreas Kuntzagk wrote:
>> [...]
>>
>> I'm sorry. I tried the regression tests and all seemed fine. What I
>> didn't notice was, the tests used my already installed biopython and not
>> the code from the build-directory. Grr, why do I keep tripping over this
>> errors? Shouldn't the "python setup.py test" use the directory it is
>> positioned in? If it is required to set PYTHONPATH before test, it
>> should be mentioned in the README. I will look into the problems now to
>> see if I could find out.
> 
> 
> Yes, we should do something about this.  It has caused us problems many 
> times.  Probably the best thing to do is to modify run_tests.py to:
> - identify its directory
> - insert the build path (../build/lib.XXX/Bio, etc) to the front of 
> sys.path, if it exists
> - insert the source path (../Bio) to the front of sys.path, if it exists
> 

Here's a patch to run_tests.py.  Should do the right thing...

> Jeff

yves
-------------- next part --------------
Index: Tests/run_tests.py
===================================================================
RCS file: /home/repository/biopython/biopython/Tests/run_tests.py,v
retrieving revision 1.6
diff -u -p -r1.6 run_tests.py
--- Tests/run_tests.py	2001/12/17 21:24:51	1.6
+++ Tests/run_tests.py	2003/07/02 12:31:17
@@ -25,7 +25,24 @@ import getopt
 # PyUnit
 import unittest
 
+import distutils.util
+
 def main(argv):
+    # insert our pathes in sys.path:
+    # ../build/lib.*
+    # ..
+    # Q. Why this order?
+    # A. To find the C modules (which are in ../build/lib.*/Bio)
+    # Q. Then, why ".."?
+    # A. Because Martel may not be in ../build/lib.*
+    test_path = sys.path[0] or "."
+    source_path = os.path.abspath("%s/.." % test_path)
+    sys.path.insert(1, source_path)
+    build_path = os.path.abspath("%s/../build/lib.%s-%s" % (
+        test_path, distutils.util.get_platform(), sys.version[:3]))
+    if os.access(build_path, os.F_OK):
+        sys.path.insert(1, build_path)
+    
     # start off using the GUI
     use_gui = 1
     


More information about the BioPython mailing list