[py-svn] r57348 - py/release/0.9.x

hpk at codespeak.net hpk at codespeak.net
Sun Aug 17 14:48:19 CEST 2008


Author: hpk
Date: Sun Aug 17 14:48:14 2008
New Revision: 57348

Modified:
   py/release/0.9.x/setup.py
Log:
a different way to handle the script problem on windows

Modified: py/release/0.9.x/setup.py
==============================================================================
--- py/release/0.9.x/setup.py	(original)
+++ py/release/0.9.x/setup.py	Sun Aug 17 14:48:14 2008
@@ -177,6 +177,7 @@
 def on_win32_add_to_PATH():
     if sys.platform != 'win32' or not winextensions:
         return 
+    assert 0
     # Add py/bin to PATH environment variable
     bindir = os.path.join(sysconfig.get_python_lib(), "py", "bin", "win32")
     reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
@@ -184,7 +185,7 @@
     path = get_registry_value(reg, key, "Path")
     if bindir in path:
         return 
-    path += ";" + bindir
+    path = bindir + ";" + path
     print "Setting PATH to:", path
     set_registry_value(reg, key, "Path", path)
     #print "Current PATH is:", get_registry_value(reg, key, "Path")
@@ -222,12 +223,30 @@
     _winreg.SetValueEx(k, value_name, 0, value_type, value)
     _winreg.CloseKey(k)
 
-from distutils.command.install import install 
-class my_install(install):
-    def finalize_other(self):
-        install.finalize_other(self)
-        on_win32_add_to_PATH()
-cmdclass = {'install': my_install}
+from distutils.command.install_scripts import install_scripts
+class my_install_scripts(install_scripts):
+    def run(self):
+        install_scripts.run(self)
+        print self.outfiles
+        for fn in self.outfiles:
+            basename = os.path.basename(fn)
+            if "." in basename:
+                #print "tackling", fn
+                newbasename = basename.replace(".", "_")
+                newfn = os.path.join(os.path.dirname(fn), newbasename)
+                if os.path.exists(newfn):
+                    os.remove(newfn)
+                os.rename(fn, newfn)
+                newname = fn + ".cmd"
+                if os.path.exists(newname):
+                   os.remove(newname)
+                f = open(newname, 'w')
+                f.write("@echo off\n")
+                f.write('python "~dp0\%s" %%*\n' % basename)
+                f.close()
+        
+
+cmdclass = {'install_scripts': my_install_scripts}
         
 if __name__ == '__main__':
     main()



More information about the pytest-commit mailing list