Commits

Michal Dvorak  committed 990db87

Removed hard-coded dependency on python section

  • Participants
  • Parent commits 80d25e9

Comments (0)

Files changed (1)

File setup_recipe/__init__.py

-import os, re
+import os, re, sys
 
 class Recipe(object):
     """
             if len(dir):
                 self.develop.append(os.path.abspath(dir))
 
+    def __escape(self, s):
+        return s.replace('\\', '\\\\').replace('\n', ' ')
+
     def install(self):
         # Read settings
-        bin = self.buildout['python']['bin-directory']
-        python = self.buildout['python']['executable']
+        bin = os.path.join(self.buildout['buildout']['directory'], 'bin')
+        python = sys.executable
         output = os.path.join(bin, self.name)
         interpreter = os.path.join(bin, self.options.get('use-interpreter', python))
         command = self.options.get('command')
         f.write('from subprocess import call\n\n')
 
         # Write settings
-        f.write('INTERPRETER = "' + interpreter + '"\n')
+        f.write('INTERPRETER = "' + self.__escape(interpreter) + '"\n')
         f.write('DEVELOP = ' + str(self.develop) + '\n')
-        f.write('SCRIPT = "' + script + '"\n')
+        f.write('SCRIPT = "' + self.__escape(script) + '"\n')
 
         if command:
-            f.write('CMD = ["' + command + '"]\n')
+            f.write('CMD = ["' + self.__escape(command) + '"]\n')
         else:
             f.write('CMD = []\n')