[py-svn] py-trunk commit f13c96e6ec1f: moving py/bin to rootlevel bin/ and fixing tests

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Oct 29 18:09:44 CET 2009


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1256831582 -3600
# Node ID f13c96e6ec1fa4313d7b10bbddb24ccc74d67b05
# Parent 88cd8639f646211cf2e0b60020fae3d684718211
moving py/bin to rootlevel bin/ and fixing tests

--- /dev/null
+++ b/bin/env.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import sys, os, os.path
+
+progpath = sys.argv[0]
+packagedir = os.path.dirname(os.path.dirname(os.path.abspath(progpath)))
+packagename = os.path.basename(packagedir)
+bindir = os.path.join(packagedir, 'bin')
+if sys.platform == 'win32':
+    bindir = os.path.join(bindir, 'win32')
+rootdir = os.path.dirname(packagedir)
+
+def prepend_path(name, value):
+    sep = os.path.pathsep
+    curpath = os.environ.get(name, '')
+    newpath = [value] + [ x for x in curpath.split(sep) if x and x != value ]
+    return setenv(name, sep.join(newpath))
+
+def setenv(name, value):
+    shell = os.environ.get('SHELL', '')
+    comspec = os.environ.get('COMSPEC', '')
+    if shell.endswith('csh'):
+        cmd = 'setenv %s "%s"' % (name, value)
+    elif shell.endswith('sh'):
+        cmd = '%s="%s"; export %s' % (name, value, name)
+    elif comspec.endswith('cmd.exe'):
+        cmd = 'set %s=%s' % (name, value)
+    else:
+        assert False, 'Shell not supported.'
+    return cmd
+
+print(prepend_path('PATH', bindir))
+print(prepend_path('PYTHONPATH', rootdir))

--- a/py/bin/py.lookup
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pylookup()

--- /dev/null
+++ b/bin/win32/py.test.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.test" %*

--- a/py/bin/win32/py.svnwcrevert.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.svnwcrevert" %*

--- /dev/null
+++ b/bin/py.which
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pywhich()

--- /dev/null
+++ b/bin/win32/py.lookup.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.lookup" %*

--- /dev/null
+++ b/bin/py.cleanup
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pycleanup()

--- /dev/null
+++ b/bin/py.convert_unittest
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pyconvert_unittest()

--- /dev/null
+++ b/bin/win32/py.svnwcrevert.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.svnwcrevert" %*

--- /dev/null
+++ b/bin/win32/py.countloc.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.countloc" %*

--- a/py/bin/win32/py.lookup.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.lookup" %*

--- /dev/null
+++ b/bin/py.lookup
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pylookup()

--- a/testing/cmdline/test_generic.py
+++ b/testing/cmdline/test_generic.py
@@ -1,10 +1,12 @@
 import py
 import sys
 
-binpath = py.path.local(py.__file__).dirpath("bin")
-binwinpath = binpath.join("win32")
 
 def setup_module(mod):
+    mod.binpath = py._impldir.dirpath('bin')
+    if not mod.binpath.check():
+        py.test.skip("bin-source scripts not installed")
+    mod.binwinpath = binpath.join("win32")
     mod.tmpdir = py.test.ensuretemp(__name__)
     mod.iswin32 = sys.platform == "win32"
 

--- a/py/bin/py.convert_unittest
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pyconvert_unittest()

--- a/py/bin/win32/py.convert_unittest.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.convert_unittest" %*

--- a/py/bin/win32/py.test.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.test" %*

--- a/py/bin/env.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, os.path
-
-progpath = sys.argv[0]
-packagedir = os.path.dirname(os.path.dirname(os.path.abspath(progpath)))
-packagename = os.path.basename(packagedir)
-bindir = os.path.join(packagedir, 'bin')
-if sys.platform == 'win32':
-    bindir = os.path.join(bindir, 'win32')
-rootdir = os.path.dirname(packagedir)
-
-def prepend_path(name, value):
-    sep = os.path.pathsep
-    curpath = os.environ.get(name, '')
-    newpath = [value] + [ x for x in curpath.split(sep) if x and x != value ]
-    return setenv(name, sep.join(newpath))
-
-def setenv(name, value):
-    shell = os.environ.get('SHELL', '')
-    comspec = os.environ.get('COMSPEC', '')
-    if shell.endswith('csh'):
-        cmd = 'setenv %s "%s"' % (name, value)
-    elif shell.endswith('sh'):
-        cmd = '%s="%s"; export %s' % (name, value, name)
-    elif comspec.endswith('cmd.exe'):
-        cmd = 'set %s=%s' % (name, value)
-    else:
-        assert False, 'Shell not supported.'
-    return cmd
-
-print(prepend_path('PATH', bindir))
-print(prepend_path('PYTHONPATH', rootdir))

--- /dev/null
+++ b/bin/_findpy.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python 
+
+#
+# find and import a version of 'py'
+#
+import sys
+import os
+from os.path import dirname as opd, exists, join, basename, abspath
+
+def searchpy(current):
+    while 1:
+        last = current
+        initpy = join(current, '__init__.py')
+        if not exists(initpy):
+            pydir = join(current, 'py')
+            # recognize py-package and ensure it is importable
+            if exists(pydir) and exists(join(pydir, '__init__.py')):
+                #for p in sys.path:
+                #    if p == current:
+                #        return True
+                if current != sys.path[0]:  # if we are already first, then ok
+                    sys.stderr.write("inserting into sys.path: %s\n" % current)
+                    sys.path.insert(0, current)
+                return True
+        current = opd(current)
+        if last == current:
+            return False
+
+if not searchpy(abspath(os.curdir)):
+    if not searchpy(opd(abspath(sys.argv[0]))):
+        if not searchpy(opd(__file__)):
+            pass # let's hope it is just on sys.path 
+
+import py
+
+if __name__ == '__main__': 
+    print ("py lib is at %s" % py.__file__)

--- a/py/bin/py.which
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pywhich()

--- /dev/null
+++ b/bin/win32/py.cleanup.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.cleanup" %*

--- a/py/bin/py.cleanup
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pycleanup()

--- a/_py/test/plugin/pytest_pytester.py
+++ b/_py/test/plugin/pytest_pytester.py
@@ -301,7 +301,7 @@ class TmpTestdir:
         return self.run(*fullargs)
 
     def _getpybinargs(self, scriptname):
-        bindir = py.path.local(py.__file__).dirpath("bin")
+        bindir = py._impldir.dirpath('bin')
         script = bindir.join(scriptname)
         assert script.check()
         return py.std.sys.executable, script

--- /dev/null
+++ b/bin/py.svnwcrevert
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pysvnwcrevert()

--- a/py/bin/_findpy.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python 
-
-#
-# find and import a version of 'py'
-#
-import sys
-import os
-from os.path import dirname as opd, exists, join, basename, abspath
-
-def searchpy(current):
-    while 1:
-        last = current
-        initpy = join(current, '__init__.py')
-        if not exists(initpy):
-            pydir = join(current, 'py')
-            # recognize py-package and ensure it is importable
-            if exists(pydir) and exists(join(pydir, '__init__.py')):
-                #for p in sys.path:
-                #    if p == current:
-                #        return True
-                if current != sys.path[0]:  # if we are already first, then ok
-                    sys.stderr.write("inserting into sys.path: %s\n" % current)
-                    sys.path.insert(0, current)
-                return True
-        current = opd(current)
-        if last == current:
-            return False
-
-if not searchpy(abspath(os.curdir)):
-    if not searchpy(opd(abspath(sys.argv[0]))):
-        if not searchpy(opd(__file__)):
-            pass # let's hope it is just on sys.path 
-
-import py
-
-if __name__ == '__main__': 
-    print ("py lib is at %s" % py.__file__)

--- /dev/null
+++ b/bin/win32/py.convert_unittest.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.convert_unittest" %*

--- a/py/bin/win32/py.countloc.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.countloc" %*

--- a/py/bin/env.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-for /F "usebackq delims=" %%i in (`python "%~dp0\env.py"`) do %%i

--- /dev/null
+++ b/bin/py.test
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pytest()

--- a/py/bin/win32/py.cleanup.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.cleanup" %*

--- a/py/bin/py.test
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pytest()

--- /dev/null
+++ b/bin/env.cmd
@@ -0,0 +1,2 @@
+ at echo off
+for /F "usebackq delims=" %%i in (`python "%~dp0\env.py"`) do %%i

--- a/py/bin/win32/py.which.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
- at echo off
-python "%~dp0\..\py.which" %*

--- a/py/bin/py.countloc
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pycountloc()

--- /dev/null
+++ b/bin/win32/py.which.cmd
@@ -0,0 +1,2 @@
+ at echo off
+python "%~dp0\..\py.which" %*

--- /dev/null
+++ b/bin/py.countloc
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import py
+py.cmdline.pycountloc()

--- a/py/bin/py.svnwcrevert
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-from _findpy import py
-py.cmdline.pysvnwcrevert()



More information about the pytest-commit mailing list