Exemplo n.º 1
0
    def symlink(self):
        install_dir = os.path.realpath(self.install_dir)
        if self.options.framework:
            # create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
            bin_dir = os.path.join(install_dir, 'bin')
            if os.path.exists(bin_dir):
                rm_r(bin_dir)
            m = re.match(r'\d\.\d', self.pkg.version)
            if m:
                version = m.group(0)
            symlink(
                os.path.join(install_dir, 'Frameworks',
                             'Python.framework', 'Versions', version, 'bin'),
                os.path.join(bin_dir))

        path_python = os.path.join(install_dir, 'bin', 'python')
        if not os.path.isfile(path_python):
            src = None
            for d in os.listdir(os.path.join(install_dir, 'bin')):
                if re.match(r'python\d\.\d', d):
                    src = d
                    break
            if src:
                path_src = os.path.join(install_dir, 'bin', src)
                symlink(path_src, path_python)
Exemplo n.º 2
0
    def symlink(self):
        install_dir = os.path.realpath(self.install_dir)
        if self.options.framework:
            # create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
            bin_dir = os.path.join(install_dir, "bin")
            if os.path.exists(bin_dir):
                rm_r(bin_dir)
            m = re.match(r"\d\.\d", self.pkg.version)
            if m:
                version = m.group(0)
            symlink(
                os.path.join(install_dir, "Frameworks", "Python.framework", "Versions", version, "bin"),
                os.path.join(bin_dir),
            )

        path_python = os.path.join(install_dir, "bin", "python")
        if not os.path.isfile(path_python):
            src = None
            for d in os.listdir(os.path.join(install_dir, "bin")):
                if re.match(r"python\d\.\d", d):
                    src = d
                    break
            if src:
                path_src = os.path.join(install_dir, "bin", src)
                symlink(path_src, path_python)
Exemplo n.º 3
0
 def _symlink(self, srcbin, dstbin, pkgname):
     """Create a symlink.
     """
     src = os.path.join(PATH_PYTHONS, pkgname, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.info("%s: File not found" % src)
Exemplo n.º 4
0
 def _symlink(self, srcbin, dstbin, pkgname):
     """Create a symlink.
     """
     src = os.path.join(PATH_PYTHONS, pkgname, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.error("%s was not found in your path." % src)
Exemplo n.º 5
0
 def _symlink_venv(self, srcbin, dstbin, venv_dir):
     """Create a symlink.
     """
     src = os.path.join(venv_dir, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.error("%s was not found in your path." % src)
Exemplo n.º 6
0
 def _symlink(self, srcbin, dstbin, pkgname):
     """Create a symlink.
     """
     src = os.path.join(PATH_PYTHONS, pkgname, 'bin', srcbin)
     dst = os.path.join(PATH_BIN, dstbin)
     if os.path.isfile(src):
         symlink(src, dst)
     else:
         logger.error("%s was not found in your path." % src)
Exemplo n.º 7
0
 def symlink(self):
     install_dir = os.path.realpath(self.install_dir)
     path_python = os.path.join(install_dir,'bin','python')
     if not os.path.isfile(path_python):
         path_python3 = os.path.join(install_dir,'bin','python3')
         path_python3_0 = os.path.join(install_dir,'bin','python3.0')
         if os.path.isfile(path_python3):
             symlink(path_python3, path_python)
         elif os.path.isfile(path_python3_0):
             symlink(path_python3_0, path_python)
Exemplo n.º 8
0
    def install(self, installer_root):
        makedirs(PATH_PYTHONS)
        makedirs(PATH_BUILD)
        makedirs(PATH_DISTS)
        makedirs(PATH_ETC)
        makedirs(PATH_BIN)
        makedirs(PATH_LOG)
        
        rm_r(PATH_SCRIPTS)
        makedirs(PATH_SCRIPTS)
        makedirs(PATH_SCRIPTS_PYTHONBREW)
        makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS)
        
        for path in glob.glob(os.path.join(installer_root,"*.py")):
            shutil.copy(path, PATH_SCRIPTS_PYTHONBREW)
    
        for path in glob.glob(os.path.join(installer_root,"commands","*.py")):
            shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS)
        
        rm_r(PATH_PATCHES)
        shutil.copytree(os.path.join(installer_root,"patches"), PATH_PATCHES)
        
        fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w")
        fp.write("""import pythonbrew
if __name__ == "__main__":
    pythonbrew.main()
""")
        fp.close()
    
        fp = open(PATH_BIN_PYTHONBREW, "w")
        fp.write("""#!/usr/bin/env bash
%s %s/pythonbrew_main.py "$@"
""" % (sys.executable, PATH_SCRIPTS))
        fp.close()
        os.chmod(PATH_BIN_PYTHONBREW, 0755)
        symlink(PATH_BIN_PYTHONBREW, PATH_BIN_PYBREW) # pybrew is symbolic pythonbrew
        
        fp = open(os.path.join(PATH_ETC,'bashrc'), 'w')
        for line in open(os.path.join(installer_root,'scripts','bashrc')):
            line = line.replace('@ROOT@', ROOT)
            fp.write(line)
        fp.close()
        os.system("echo 'setenv PATH %s/bin:%s/current/bin:$PATH' > %s/cshrc" % (ROOT, PATH_PYTHONS, PATH_ETC))
Exemplo n.º 9
0
 def _switch_dir(self, pkgdir):
     off()
     symlink(pkgdir, "%s/current" % PATH_PYTHONS)
     for root, dirs, files in os.walk("%s/current/bin/" % PATH_PYTHONS):
         for f in files:
             symlink("%s%s" % (root, f), "%s/%s" % (PATH_BIN, f))
         break
     # I want better code
     if not os.path.isfile("%s/python" % PATH_BIN):
         if os.path.isfile("%s/python3" % PATH_BIN):
             symlink(os.path.realpath("%s/python3" % PATH_BIN), "%s/python" % PATH_BIN)
         elif os.path.isfile("%s/python3.0" % PATH_BIN):
             symlink(os.path.realpath("%s/python3.0" % PATH_BIN), "%s/python" % PATH_BIN)
Exemplo n.º 10
0
    def symlink(self):
        install_dir = os.path.realpath(self.install_dir)
        if self.options.framework:
            # create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
            bin_dir = os.path.join(install_dir, 'bin')
            if os.path.exists(bin_dir):
                rm_r(bin_dir)
            m = re.match(r'\d\.\d', self.pkg.version)
            if m:
                version = m.group(0)
            symlink(os.path.join(install_dir,'Frameworks','Python.framework','Versions',version,'bin'),
                    os.path.join(bin_dir))

        path_python = os.path.join(install_dir,'bin','python')
        if not os.path.isfile(path_python):
            src = None
            for d in os.listdir(os.path.join(install_dir,'bin')):
                if re.match(r'python\d\.\d', d):
                    src = d
                    break
            if src:
                path_src = os.path.join(install_dir,'bin',src)
                symlink(path_src, path_python)