Exemple #1
0
    def patch_standard_packages(self, package_name=''):
        """patch Winpython packages in need"""
        import filecmp
        # 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
        if package_name.lower() == "pywin32" or package_name == '':
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            if osp.isdir(origin):
                for name in os.listdir(origin):
                    here, there = osp.join(origin, name), osp.join(destin, name)
                    if (not os.path.exists(there) or
                       not filecmp.cmp(here, there)):
                        shutil.copyfile(here, there)
        # 'pip' to do movable launchers (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package_name.lower() == "pip" or package_name == '':
            # ensure pip will create movable launchers
            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()))")
            # create movable launchers for previous package installations
            self.patch_all_shebang()

        if package_name.lower() == "spyder" or package_name == '':
            # spyder don't goes on internet without I ask
            utils.patch_sourcefile(
              self.target + (
              r"\Lib\site-packages\spyderlib\config\main.py"),
              "'check_updates_on_startup': True,",
              "'check_updates_on_startup': False,")

        # workaround bad installers
        if package_name.lower() == "theano" or package_name == '':
            self.create_pybat(['theano-cache', 'theano-nose', 'theano-test'])
        if package_name.lower() == "numba" or package_name == '':
            self.create_pybat(['numba', 'pycc'])
        for checklist in("odo", "vitables", "cxfreeze"):
            if package_name.lower() == checklist or package_name == '':
                self.create_pybat(checklist)
Exemple #2
0
    def patch_standard_packages(self, package_name=''):
        """patch Winpython packages in need"""
        import filecmp
        # 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
        if package_name.lower() == "pywin32" or package_name == '':
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            if osp.isdir(origin):
                for name in os.listdir(origin):
                    here, there = osp.join(origin,
                                           name), osp.join(destin, name)
                    if (not os.path.exists(there)
                            or not filecmp.cmp(here, there)):
                        shutil.copyfile(here, there)
        # 'pip' to do movable launchers (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package_name.lower() == "pip" or package_name == '':
            # ensure pip will create movable launchers
            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()))"
            )
            # create movable launchers for previous package installations
            self.patch_all_shebang()

        if package_name.lower() == "spyder" or package_name == '':
            # spyder don't goes on internet without I ask
            utils.patch_sourcefile(
                self.target + (r"\Lib\site-packages\spyderlib\config\main.py"),
                "'check_updates_on_startup': True,",
                "'check_updates_on_startup': False,")

        if package_name.lower() == "pyqt5" or package_name == '':
            # workaround Qt5.5.0 bug
            utils.patch_sourcefile(
                self.target +
                (r"\Lib\site-packages\PyQt5\examples\qtdemo\demoitemanimation.py"
                 ), ".__init__(item, 'pos')", ".__init__(item, b'pos')")

        # workaround bad installers
        if package_name.lower() == "theano" or package_name == '':
            self.create_pybat(['theano-cache', 'theano-nose', 'theano-test'])
        if package_name.lower() == "numba" or package_name == '':
            self.create_pybat(['numba', 'pycc'])
        for checklist in ("odo", "vitables", "cxfreeze"):
            if package_name.lower() == checklist or package_name == '':
                self.create_pybat(checklist)
Exemple #3
0
    def patch_standard_packages(self, package_name='', to_movable=True):
        """patch Winpython packages in need"""
        import filecmp
        # 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
        if package_name.lower() == "pywin32" or package_name == '':
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            if osp.isdir(origin):
                for name in os.listdir(origin):
                    here, there = osp.join(origin,
                                           name), osp.join(destin, name)
                    if (not os.path.exists(there)
                            or not filecmp.cmp(here, there)):
                        shutil.copyfile(here, there)
        # 'pip' to do movable launchers (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package_name.lower() == "pip" or package_name == '':
            # ensure pip will create movable launchers
            # sheb_mov1 = classic way up to WinPython 2016-01
            # sheb_mov2 = tried  way, but doesn't work for pip (at least)
            sheb_fix = " executable = get_executable()"
            sheb_mov1 = " executable = os.path.join(os.path.basename(get_executable()))"
            sheb_mov2 = " executable = os.path.join('..',os.path.basename(get_executable()))"
            if to_movable:
                utils.patch_sourcefile(
                    self.target +
                    r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                    sheb_fix, sheb_mov1)
                utils.patch_sourcefile(
                    self.target +
                    r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                    sheb_mov2, sheb_mov1)
            else:
                utils.patch_sourcefile(
                    self.target +
                    r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                    sheb_mov1, sheb_fix)
                utils.patch_sourcefile(
                    self.target +
                    r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                    sheb_mov2, sheb_fix)

            # ensure pip wheel will register relative PATH in 'RECORD' files
            # will be in standard pip 8.0.3
            utils.patch_sourcefile(
                self.target + (r"\Lib\site-packages\pip\wheel.py"),
                " writer.writerow((f, h, l))",
                " writer.writerow((normpath(f, lib_dir), h, l))")

            # create movable launchers for previous package installations
            self.patch_all_shebang(to_movable=to_movable)

        if package_name.lower() == "spyder" or package_name == '':
            # spyder don't goes on internet without I ask
            utils.patch_sourcefile(
                self.target + (r"\Lib\site-packages\spyderlib\config\main.py"),
                "'check_updates_on_startup': True,",
                "'check_updates_on_startup': False,")
            utils.patch_sourcefile(
                self.target + (r"\Lib\site-packages\spyder\config\main.py"),
                "'check_updates_on_startup': True,",
                "'check_updates_on_startup': False,")

        # workaround bad installers
        if package_name.lower() == "numba":
            self.create_pybat(['numba', 'pycc'])
        else:
            self.create_pybat(package_name.lower())
Exemple #4
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()")
Exemple #5
0
    def patch_standard_packages(self, package_name='', to_movable=True):
        """patch Winpython packages in need"""
        import filecmp
        # 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
        if package_name.lower() == "pywin32" or package_name == '':
            origin = self.target + (r"\Lib\site-packages\pywin32_system32")
            destin = self.target
            if osp.isdir(origin):
                for name in os.listdir(origin):
                    here, there = osp.join(origin, name), osp.join(destin, name)
                    if (not os.path.exists(there) or
                       not filecmp.cmp(here, there)):
                        shutil.copyfile(here, there)
        # 'pip' to do movable launchers (around line 100) !!!!
        # rational: https://github.com/pypa/pip/issues/2328
        if package_name.lower() == "pip" or package_name == '':
            # ensure pip will create movable launchers
            # sheb_mov1 = classic way up to WinPython 2016-01
            # sheb_mov2 = tried  way, but doesn't work for pip (at least)
            sheb_fix = " executable = get_executable()"
            sheb_mov1 = " executable = os.path.join(os.path.basename(get_executable()))"
            sheb_mov2 = " executable = os.path.join('..',os.path.basename(get_executable()))"
            if to_movable:
                utils.patch_sourcefile(self.target +
                r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                sheb_fix, sheb_mov1)
                utils.patch_sourcefile(self.target +
                r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                sheb_mov2, sheb_mov1)
            else:
                utils.patch_sourcefile(self.target +
                r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                sheb_mov1, sheb_fix)
                utils.patch_sourcefile(self.target +
                r"\Lib\site-packages\pip\_vendor\distlib\scripts.py",
                sheb_mov2, sheb_fix)
                
            # ensure pip wheel will register relative PATH in 'RECORD' files
            # will be in standard pip 8.0.3
            utils.patch_sourcefile(
              self.target + (
              r"\Lib\site-packages\pip\wheel.py"),
              " writer.writerow((f, h, l))",
              " writer.writerow((normpath(f, lib_dir), h, l))")

            # create movable launchers for previous package installations
            self.patch_all_shebang(to_movable=to_movable)

        if package_name.lower() == "spyder" or package_name == '':
            # spyder don't goes on internet without I ask
            utils.patch_sourcefile(
              self.target + (
              r"\Lib\site-packages\spyderlib\config\main.py"),
              "'check_updates_on_startup': True,",
              "'check_updates_on_startup': False,")
            utils.patch_sourcefile(
              self.target + (
              r"\Lib\site-packages\spyder\config\main.py"),
              "'check_updates_on_startup': True,",
              "'check_updates_on_startup': False,")

        # workaround bad installers
        if package_name.lower() == "numba":
            self.create_pybat(['numba', 'pycc'])
        else:
            self.create_pybat(package_name.lower())
Exemple #6
0
    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()")
Exemple #7
0
    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()",
            )