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

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

Hi,

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

Johannes

# HG changeset patch
# User Johannes Ring <[email-masked]>
# Date 1238141602 -3600
# Node ID 4239b0d765ea4efa48e2c48eeeb2c7cc2d6555ae
# Parent  9dde1eac2cc9a9275d171cf5d6a4aca973755cb7
Fix in setup.py for Windows.

diff -r 9dde1eac2cc9 -r 4239b0d765ea setup.py
--- a/setup.py	Fri Mar 20 15:14:22 2009 +0100
+++ b/setup.py	Fri Mar 27 09:13:22 2009 +0100
@@ -1,37 +1,23 @@
 #!/usr/bin/env python
 
 import sys, platform
-from os.path import join, splitext
+from os.path import join, split
 from distutils.core import setup
 
 scripts = [join("etc", "instant-clean"), join("etc", "instant-showcache")]
+
 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 batch files
+    # without a .py extension. A solution is to create batch files
     # that runs the different scripts.
-
-    # 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 files for Windows:
-    for batch_file in ["instant-clean.bat", "instant-showcache.bat"]:
+    batch_files = []
+    for script in scripts:
+        batch_file = script + ".bat"
         f = open(batch_file, "w")
-        f.write("@python %s %%*" % \
-                join(prefix, "Scripts", splitext(batch_file)[0]))
+        f.write('python "%%~dp0\%s" %%*\n' % split(script)[1])
         f.close()
-        scripts.append(batch_file)
+        batch_files.append(batch_file)
+    scripts.extend(batch_files)
 
 setup(name = "instant", version = '0.9.6', 
       description = "Instant Inlining of C/C++ in Python",