Subject: [Viper-dev] Patch for setup.py

From: "Johannes Ring" <[email-masked]>
Date: Fri, 27 Mar 2009 09:25:55 +0100 (CET)

Hi,

Please apply the attached patch for setup.py (Windows fix).

Johannes

# HG changeset patch
# User Johannes Ring <[email-masked]>
# Date 1238142096 -3600
# Node ID b9fe8be10b7ae006d8c2d859bf8a761e6d59615d
# Parent  376741cf5dbf94ce6d45ac22f5ed984e9800fc7a
Fix in setup.py for Windows.

diff -r 376741cf5dbf -r b9fe8be10b7a setup.py
--- a/setup.py	Wed Mar 25 12:22:02 2009 +0100
+++ b/setup.py	Fri Mar 27 09:21:36 2009 +0100
@@ -1,35 +1,23 @@
 from  distutils.core import setup
 from distutils import sysconfig
 import sys, os, glob
-from os.path import join
+from os.path import join, split
 import platform
 
 scripts = [join("src", "bin", "viper")]
+
 if platform.system() == "Windows" or "bdist_wininst" in sys.argv:
     # In the Windows command prompt we can't execute Python scripts 
-    # without the .py extension. A solution is to create a batch file
-    # that runs the viper script.
-
-    # try to determine the installation prefix
-    # first set up a default prefix:
-    if platform.system() == "Windows":
-        prefix = sys.prefix
-    else:
-        # we are running bdist_wininst on a non-Windows platform
-        pymajor, pyminor = sysconfig.get_python_version().split(".")
-        prefix = "C:\\Python%s%s" % (pymajor, pyminor)
-
-    # if --prefix is specified we use this instead of the default:
-    for arg in sys.argv:
-        if "--prefix" in arg:
-            prefix = arg.split("=")[1]
-            break
-
-    # create batch file for Windows:
-    f = open("viper.bat", "w")
-    f.write("@python %s %%*" % join(prefix, "Scripts", "viper"))
-    f.close()
-    scripts.append("viper.bat")
+    # without a .py extension. A solution is to create batch files
+    # that runs the different scripts.
+    batch_files = []
+    for script in scripts:
+        batch_file = script + ".bat"
+        f = open(batch_file, "w")
+        f.write('python "%%~dp0\%s" %%*\n' % split(script)[1])
+        f.close()
+        batch_files.append(batch_file)
+    scripts.extend(batch_files)
     
 setup(name='viper',
     version='0.4.2',