import sys
import os
import stat

from bento.core \
    import \
        PackageDescription
from bento.core.utils \
    import \
        pprint

from bento.commands.script_utils \
    import \
        create_posix_script, create_win32_script

# We cannot use octal literal for compat with python 3.x
MODE_755 = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | \
    stat.S_IROTH | stat.S_IXOTH

def install_inplace(pkg):
    """Install scripts of pkg in the current directory."""
    for name, executable in pkg.executables.items():
        if sys.platform == "win32":
            section = create_win32_script(name, executable, ".")
        else:
            section = create_posix_script(name, executable, ".")
            for f, g in section.files:
                os.chmod(g, MODE_755)
        installed = ",".join([g for f, g in section.files])
        pprint("GREEN", "installing %s in current directory" % installed)

if __name__ == "__main__":
    from setup_common import generate_version_py
    generate_version_py("bento/__dev_version.py")

    pkg = PackageDescription.from_file("bento.info")
    if pkg.executables:
        install_inplace(pkg)

@@ -422,103 +422,16 @@
 def 
-install_inplace(pkg):%0A    %22%22%22Install scripts of pkg in the current directory.%22%22%22%0A    for name, 
+_create_
 exec
@@ -440,16 +440,15 @@
 able
- in pkg.
+(name, 
 exec
@@ -457,27 +457,15 @@
 able
-s.items(
 ):%0A    
- 
-   
 if s
@@ -488,20 +488,16 @@
 win32%22:%0A
-    
         
@@ -545,28 +545,24 @@
 table, %22.%22)%0A
-    
     else:%0A  
@@ -559,20 +559,16 @@
   else:%0A
-    
         
@@ -628,20 +628,16 @@
         
-    
 for f, g
@@ -667,20 +667,16 @@
         
-    
 os.chmod
@@ -689,16 +689,379 @@
 DE_755)%0A
+    return section%0A%0Adef install_inplace(pkg):%0A    %22%22%22Install scripts of pkg in the current directory.%22%22%22%0A    for basename, executable in pkg.executables.items():%0A        version_str = %22.%22.join(%5Bstr(i) for i in sys.version_info%5B:2%5D%5D)%0A        for name in %5Bbasename, %22%25s-%25s%22 %25 (basename, version_str)%5D:%0A            section = _create_executable(name, executable)%0A    
         
@@ -1112,16 +1112,20 @@
 files%5D)%0A
+    
         

create python-specific versions of bentomaker.