예제 #1
0
파일: wppm.py 프로젝트: gyenney/Tools
 def patch_all_shebang(self, to_movable=True, max_exe_size=999999):
     """make all python launchers relatives"""
     import glob
     import os
     for ffname in glob.glob(r'%s\Scripts\*.exe' % self.target):
         size = os.path.getsize(ffname)
         if size <= max_exe_size:
             utils.patch_shebang_line(ffname, to_movable=to_movable)
예제 #2
0
 def patch_all_shebang(self,
                       to_movable=True,
                       max_exe_size=999999,
                       targetdir=""):
     """make all python launchers relatives"""
     import glob
     import os
     for ffname in glob.glob(r'%s\Scripts\*.exe' % self.target):
         size = os.path.getsize(ffname)
         if size <= max_exe_size:
             utils.patch_shebang_line(ffname,
                                      to_movable=to_movable,
                                      targetdir=targetdir)
예제 #3
0
    def install(self, package, install_options=None):
        """Install package in distribution"""
        assert package.is_compatible_with(self)
        tmp_fname = None
        # (tragic if pip) self.uninstall_existing(package)
        if package.fname.endswith(('.tar.gz', '.zip')):
            self._print(package, "Building")
            try:
                fname = utils.source_to_wininst(package.fname,
                          python_exe=osp.join(self.target, 'python.exe'),
                          architecture=self.architecture, verbose=self.verbose)
            except RuntimeError:
                if not self.verbose:
                    print("Failed!")
                raise
            tmp_fname = fname
            package = Package(fname)
            self._print_done()
        # wheel addition
        if package.fname.endswith(('.whl')):
            self.install_bdist_wheel(package, install_options=install_options)

        bname = osp.basename(package.fname)
        if bname.endswith('.exe'):
            if re.match(r'(' + ('|'.join(self.NSIS_PACKAGES)) + r')-', bname):
                self.install_nsis_package(package)
            else:
                self.install_bdist_wininst(package)
        elif bname.endswith('.msi'):
            self.install_bdist_msi(package)
        self.handle_specific_packages(package)
        package.save_log(self.logdir)
        if tmp_fname is not None:
            os.remove(tmp_fname)

        # We minimal post-install pywin (pywin32_postinstall.py do too much)
        if package.name == "pywin32":
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            for name in os.listdir(origin):
                print("shutil.copy ", osp.join(origin, name), " ", osp.join(destin, name))
                shutil.copyfile(osp.join(origin, name), osp.join(destin, name))

        # We patch pip live (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package.name == "get-pip":
            # self.exec_script
            my_script_is = osp.join(self.target, 'Scripts', 'get-pip.py')
            self.install_script(my_script_is, install_options=None)
        # change of method 2014-05-08:
        # touching pip at installation seems not working anymore
        # so brute force method is applied
        if package.name == "pip" or package.name == "get-pip" or 1 == 1:
            import glob
            for ffname in glob.glob(r'%s\Scripts\*.exe' % self.target):
                utils.patch_shebang_line(ffname)
            # ensure pip.exe and easy_install.exe
            problems = [('pip', 'pip'), ('easy_install', 'easy_install-')]
            solutions = [('%s.%s' % sys.version_info[:2]),
                         ('%s' % sys.version_info[0])]
            for p in problems:
                problem = r'%s\Scripts\%s.exe' % (self.target, p[0])
                for s in solutions:
                    solution = r'%s\Scripts\%s%s.exe' % (self.target, p[1], s)
                    if not osp.exists(problem) and osp.exists(solution):
                        shutil.copyfile(solution, problem)

        if package.name == "pip" or package.name == "get-pip":
            utils.patch_sourcefile(
              self.target + (
              r"\Lib\site-packages\pip\_vendor\distlib\scripts.py"),
              " executable = get_executable()",
              " executable = os.path.join(os.path.basename(get_executable()))")
        # We patch IPython\kernel\kernelspec.py live (around line 51) !!!!
        if package.name == "ipython":
            utils.patch_sourcefile(
              self.target + r"\Lib\site-packages\IPython\kernel\kernelspec.py",
              r" kernel_dict = json.load(f)",
              r" kernel_dict = json.loads(('\n'.join(f.readlines())).replace('[WINPYDIR]',(os.environ['WINPYDIR']).replace('\\','\\\\')))"+
              ";" + "from  winpython.utils import patch_julia03; patch_julia03()")
예제 #4
0
파일: wppm.py 프로젝트: psycow/winpython
    def install(self, package, install_options=None):
        """Install package in distribution"""
        assert package.is_compatible_with(self)
        tmp_fname = None

        # wheel addition
        if package.fname.endswith(('.whl', '.tar.gz', '.zip')):
            self.install_bdist_direct(package, install_options=install_options)

        bname = osp.basename(package.fname)
        if bname.endswith('.exe'):
            if re.match(r'(' + ('|'.join(self.NSIS_PACKAGES)) + r')-', bname):
                self.install_nsis_package(package)
            else:
                self.install_bdist_wininst(package)
        elif bname.endswith('.msi'):
            self.install_bdist_msi(package)
        self.handle_specific_packages(package)
        if not package.fname.endswith(('.whl', '.tar.gz', '.zip')):
            package.save_log(self.logdir)
        if tmp_fname is not None:
            os.remove(tmp_fname)

        # We minimal post-install pywin (pywin32_postinstall.py do too much)
        if package.name == "pywin32":
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            for name in os.listdir(origin):
                print("shutil.copy ", osp.join(origin, name), " ",
                      osp.join(destin, name))
                shutil.copyfile(osp.join(origin, name), osp.join(destin, name))

        # We patch pip live (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package.name == "get-pip":
            # self.exec_script
            my_script_is = osp.join(self.target, 'Scripts', 'get-pip.py')
            self.install_script(my_script_is, install_options=None)
        # change of method 2014-05-08:
        # touching pip at installation seems not working anymore
        # so brute force method is applied
        if package.name == "pip" or package.name == "get-pip" or 1 == 1:
            import glob
            for ffname in glob.glob(r'%s\Scripts\*.exe' % self.target):
                utils.patch_shebang_line(ffname)
            # ensure pip.exe and easy_install.exe
            problems = [('pip', 'pip'), ('easy_install', 'easy_install-')]
            solutions = [('%s.%s' % sys.version_info[:2]),
                         ('%s' % sys.version_info[0])]
            for p in problems:
                problem = r'%s\Scripts\%s.exe' % (self.target, p[0])
                for s in solutions:
                    solution = r'%s\Scripts\%s%s.exe' % (self.target, p[1], s)
                    if not osp.exists(problem) and osp.exists(solution):
                        shutil.copyfile(solution, problem)

        if package.name == "pip" or package.name == "get-pip":
            utils.patch_sourcefile(
                self.target +
                (r"\Lib\site-packages\pip\_vendor\distlib\scripts.py"),
                " executable = get_executable()",
                " executable = os.path.join(os.path.basename(get_executable()))"
            )
        # We patch IPython\kernel\kernelspec.py live (around line 51) !!!!
        if package.name == "ipython":
            utils.patch_sourcefile(
                self.target +
                r"\Lib\site-packages\IPython\kernel\kernelspec.py",
                r" kernel_dict = json.load(f)",
                r" kernel_dict = json.loads(('\n'.join(f.readlines())).replace('[WINPYDIR]',(os.environ['WINPYDIR']).replace('\\','\\\\')))"
                + ";" +
                "from  winpython.utils import patch_julia03; patch_julia03()")
예제 #5
0
파일: wppm.py 프로젝트: psycow/winpython
    def install(self, package, install_options=None):
        """Install package in distribution"""
        assert package.is_compatible_with(self)
        tmp_fname = None

        # wheel addition
        if package.fname.endswith((".whl", ".tar.gz", ".zip")):
            self.install_bdist_direct(package, install_options=install_options)

        bname = osp.basename(package.fname)
        if bname.endswith(".exe"):
            if re.match(r"(" + ("|".join(self.NSIS_PACKAGES)) + r")-", bname):
                self.install_nsis_package(package)
            else:
                self.install_bdist_wininst(package)
        elif bname.endswith(".msi"):
            self.install_bdist_msi(package)
        self.handle_specific_packages(package)
        if not package.fname.endswith((".whl", ".tar.gz", ".zip")):
            package.save_log(self.logdir)
        if tmp_fname is not None:
            os.remove(tmp_fname)

        # We minimal post-install pywin (pywin32_postinstall.py do too much)
        if package.name == "pywin32":
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            for name in os.listdir(origin):
                print("shutil.copy ", osp.join(origin, name), " ", osp.join(destin, name))
                shutil.copyfile(osp.join(origin, name), osp.join(destin, name))

        # We patch pip live (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package.name == "get-pip":
            # self.exec_script
            my_script_is = osp.join(self.target, "Scripts", "get-pip.py")
            self.install_script(my_script_is, install_options=None)
        # change of method 2014-05-08:
        # touching pip at installation seems not working anymore
        # so brute force method is applied
        if package.name == "pip" or package.name == "get-pip" or 1 == 1:
            import glob

            for ffname in glob.glob(r"%s\Scripts\*.exe" % self.target):
                utils.patch_shebang_line(ffname)
            # ensure pip.exe and easy_install.exe
            problems = [("pip", "pip"), ("easy_install", "easy_install-")]
            solutions = [("%s.%s" % sys.version_info[:2]), ("%s" % sys.version_info[0])]
            for p in problems:
                problem = r"%s\Scripts\%s.exe" % (self.target, p[0])
                for s in solutions:
                    solution = r"%s\Scripts\%s%s.exe" % (self.target, p[1], s)
                    if not osp.exists(problem) and osp.exists(solution):
                        shutil.copyfile(solution, problem)

        if package.name == "pip" or package.name == "get-pip":
            utils.patch_sourcefile(
                self.target + (r"\Lib\site-packages\pip\_vendor\distlib\scripts.py"),
                " executable = get_executable()",
                " executable = os.path.join(os.path.basename(get_executable()))",
            )
        # We patch IPython\kernel\kernelspec.py live (around line 51) !!!!
        if package.name == "ipython":
            utils.patch_sourcefile(
                self.target + r"\Lib\site-packages\IPython\kernel\kernelspec.py",
                r" kernel_dict = json.load(f)",
                r" kernel_dict = json.loads(('\n'.join(f.readlines())).replace('[WINPYDIR]',(os.environ['WINPYDIR']).replace('\\','\\\\')))"
                + ";"
                + "from  winpython.utils import patch_julia03; patch_julia03()",
            )