[py-svn] r23304 - py/dist/py/misc

hpk at codespeak.net hpk at codespeak.net
Tue Feb 14 00:55:16 CET 2006


Author: hpk
Date: Tue Feb 14 00:55:15 2006
New Revision: 23304

Modified:
   py/dist/py/misc/dynpkg.py
Log:
bailing out Jan's patch of using distutils.* 
to determine the library path - it is not reliable
(we had failures while starting mailwitness daemons)
this is a clean bail out of revision 23231
let's worry about this later. 



Modified: py/dist/py/misc/dynpkg.py
==============================================================================
--- py/dist/py/misc/dynpkg.py	(original)
+++ py/dist/py/misc/dynpkg.py	Tue Feb 14 00:55:15 2006
@@ -10,7 +10,7 @@
                  debug=py.log.STDOUT,
                  command=None) # py.log.STDOUT)
 
-import distutils.core
+from distutils import util
 
 class DistPython: 
     def __init__(self, location=None, python=None): 
@@ -20,6 +20,7 @@
         if location is None:
             location = py.path.local()
         self.location = location 
+        self.plat_specifier = '.%s-%s' % (util.get_platform(), sys.version[0:3])
 
     def clean(self):
         out = self._exec("clean -a")
@@ -41,24 +42,28 @@
         return out 
 
     def get_package_path(self, pkgname):
-        path = self._get_package_path(pkgname) 
-        if not path.check(exists=True):
+        pkg = self._get_package_path(pkgname) 
+        if pkg is None:
             #self.clean()
             self.build()
-            path = self._get_package_path(pkgname)
-        print path
-        assert path.check(exists=1) 
-        return path 
+            pkg = self._get_package_path(pkgname)
+        assert pkg is not None 
+        return pkg 
 
     def _get_package_path(self, pkgname):
-        # process all config files and commandline args
-        dist = distutils.core.run_setup(self.location.join('setup.py').strpath,
-                                        script_args=['-q', 'build'],
-                                        stop_after='commandline')
-        create_if_necessary = True
-        build_command = dist.get_command_obj('build', create_if_necessary)
-        build_command.ensure_finalized()
-        return self.location.join(build_command.build_lib, pkgname)
+        major, minor = py.std.sys.version_info[:2]
+        #assert major >=2 and minor in (3,4,5)
+        suffix = "%s.%s" %(major, minor)
+        location = self.location
+        for base in [location.join('build', 'lib'),
+                     location.join('build', 'lib'+ self.plat_specifier)]:
+            if base.check(dir=1):
+                for pkg in base.visit(lambda x: x.check(dir=1)):
+                    if pkg.basename == pkgname:
+                        # 
+                        if pkg.dirpath().basename ==  'lib'+ self.plat_specifier or \
+                           pkg.dirpath().basename == 'lib':
+                            return pkg
 
 def setpkg(finalpkgname, distdir):
     assert distdir.check(dir=1)



More information about the pytest-commit mailing list