Example #1
0
    def test_install(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))
        if os.path.exists(os.path.join(temp, "jsdifflib-master")):
            for _ in os.listdir(os.path.join(temp, "jsdifflib-master")):
                os.remove(
                    os.path.join(
                        os.path.join(
                            temp,
                            "jsdifflib-master"),
                        _))

        m = ModuleInstall("jsdifflib", "github", gitrepo="cemerick", fLOG=fLOG)
        files = m.download(temp_folder=temp, unzipFile=True, source="2")
        assert len(files) > 0
        for _ in files:
            assert os.path.exists(_)
    def test_install_numpy(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_numpy")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win") and sys.version_info[0] >= 3:
            m = ModuleInstall(
                "numpy",
                "wheel",
                fLOG=fLOG)
            name = m.get_exewheel_url_link(wheel=True)
            fLOG(m.existing_version)
            r = compare_version(m.existing_version, "1.10.1")
            assert r >= 0
            assert "unoptimized" not in name[0]
            whl = m.download(temp_folder=temp, source="2")
            fLOG(m.version)
            assert os.path.exists(whl)
            assert "unoptimized" not in whl
    def test_install_tables(self):
        fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_download_tables")

        if sys.platform.startswith("win"):
            m = ModuleInstall("tables", "wheel", fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
    def test_module_version(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("pep8", "pip", fLOG=fLOG)
        assert mod.is_installed_local()
        assert mod.is_installed_local_cmd()
    def test_module_version(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("pep8", "pip", fLOG=fLOG)
        assert mod.is_installed_local()
        assert mod.is_installed_local_cmd()
Example #6
0
    def test_install_tables(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        temp = get_temp_folder(__file__, "temp_download_tables")

        if sys.platform.startswith("win"):
            m = ModuleInstall("tables", "wheel", fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
    def test_pipy_bug_flask(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mod = ModuleInstall(
            'flask-sqlalchemy', 'pip', mname='flask.ext.sqlalchemy')
        vers = mod.get_pypi_version()
        assert vers is not None
Example #8
0
    def test_pipy_bug_flask(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mod = ModuleInstall('flask-sqlalchemy',
                            'pip',
                            mname='flask.ext.sqlalchemy')
        vers = mod.get_pypi_version()
        assert vers is not None
Example #9
0
    def test_pipy_bug_ipython(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mod = ModuleInstall('ipython', 'wheel', mname='IPython')
        try:
            vers = mod.get_pypi_version()
        except MissingVersionOnPyPiException:
            vers = "no release version"
            warnings.warn("IPython is is unstable, transitionning to jupyter")
        assert vers is not None
Example #10
0
 def test_install_pip_deps(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     fold = get_temp_folder(__file__, "temp_download_pip_deps")
     m = ModuleInstall("pyquickhelper", "pip", fLOG=fLOG)
     out = m.download(temp_folder=fold, deps=True)
     assert os.path.exists(out)
     assert "pyquickhelper" in out
     out = m.download(temp_folder=fold)
     assert os.path.exists(out)
     assert "pyquickhelper" in out
    def test_pipy_bug_ipython(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mod = ModuleInstall(
            'ipython', 'wheel', mname='IPython')
        try:
            vers = mod.get_pypi_version()
        except MissingVersionOnPyPiException:
            vers = "no release version"
            warnings.warn("IPython is is unstable, transitionning to jupyter")
        assert vers is not None
Example #12
0
 def test_install_pip_deps(self):
     fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
     if sys.version_info[0] == 2:
         # disabled on python 2.7
         return
     fold = get_temp_folder(__file__, "temp_download_pip_deps")
     # This test can fail if the latest version of pyquickhelper is not
     # available for Python 2.7
     m = ModuleInstall("pyquickhelper", "pip", fLOG=fLOG)
     out = m.download(temp_folder=fold, deps=True)
     assert os.path.exists(out)
     assert "pyquickhelper" in out
     out = m.download(temp_folder=fold, source="2")
     assert os.path.exists(out)
     assert "pyquickhelper" in out
Example #13
0
    def test_install_mlpy(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_mlpy")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            m = ModuleInstall("mlpy", "wheel", fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
Example #14
0
    def test_install_mlpy(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_mlpy")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            m = ModuleInstall("mlpy", "wheel", fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
 def test_install_pip_deps(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     if sys.version_info[0] == 2:
         # disabled on python 2.7
         return
     fold = get_temp_folder(__file__, "temp_download_pip_deps")
     # This test can fail if the latest version of pyquickhelper is not
     # available for Python 2.7
     m = ModuleInstall("pyquickhelper", "pip", fLOG=fLOG)
     out = m.download(temp_folder=fold, deps=True)
     assert os.path.exists(out)
     assert "pyquickhelper" in out
     out = m.download(temp_folder=fold, source="2")
     assert os.path.exists(out)
     assert "pyquickhelper" in out
Example #16
0
    def test_install_pycuda(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_pycuda")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            fLOG("install", "h5py")
            m = ModuleInstall("pycuda", "wheel", fLOG=fLOG)
            exe = m.download(temp_folder=temp,
                             file_save=os.path.join(temp, "out_page.html"),
                             source="2")
            assert os.path.exists(exe)
Example #17
0
    def test_install(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))
        if os.path.exists(os.path.join(temp, "jsdifflib-master")):
            for _ in os.listdir(os.path.join(temp, "jsdifflib-master")):
                os.remove(
                    os.path.join(os.path.join(temp, "jsdifflib-master"), _))

        m = ModuleInstall("jsdifflib", "github", gitrepo="cemerick", fLOG=fLOG)
        files = m.download(temp_folder=temp, unzipFile=True, source="2")
        assert len(files) > 0
        for _ in files:
            assert os.path.exists(_)
Example #18
0
    def test_install_scikit(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_scikit")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            m = ModuleInstall("scikit-learn",
                              "wheel",
                              mname="sklearn",
                              fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
            if os.stat(whl).st_size < 1000:
                raise Exception("small file: " + whl)
    def test_installed_version(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("jinja2", "pip")
        res = mod.is_installed_version()
        if not res:
            fLOG(mod)
            fLOG(mod.get_installed_version())
            for k, v in get_module_version(None).items():
                if k[0] in ("j", "J"):
                    fLOG("+++", k, v)
            assert False

        mod = ModuleInstall("pandas", "wheel")
        res = mod.is_installed_version()
        assert res
        fLOG("****", mod.get_installed_version(), mod.get_pypi_version())
        if mod.get_installed_version() != mod.get_pypi_version():
            assert mod.has_update()
    def test_install_pyqt(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_pyqt")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            fLOG("install", "pyqt")
            m = ModuleInstall("PyQt", "wheel", mname="pyqt", fLOG=fLOG)
            exe = m.download(
                temp_folder=temp,
                file_save=os.path.join(
                    temp,
                    "out_page.html"), source="2")
            assert os.path.exists(exe)
Example #21
0
    def test_install_scikit(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_scikit")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win"):
            m = ModuleInstall(
                "scikit-learn",
                "wheel",
                mname="sklearn",
                fLOG=fLOG)
            whl = m.download(temp_folder=temp, source="2")
            assert os.path.exists(whl)
            if os.stat(whl).st_size < 1000:
                raise Exception("small file: " + whl)
    def test_install_numpy(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        fold = os.path.abspath(os.path.split(__file__)[0])
        temp = os.path.join(fold, "temp_download_numpy")
        if not os.path.exists(temp):
            os.mkdir(temp)
        for _ in os.listdir(temp):
            if os.path.isfile(os.path.join(temp, _)):
                os.remove(os.path.join(temp, _))

        if sys.platform.startswith("win") and sys.version_info[0] >= 3:
            m = ModuleInstall("numpy", "wheel", fLOG=fLOG)
            name = m.get_exewheel_url_link(wheel=True)
            fLOG(m.existing_version)
            r = compare_version(m.existing_version, "1.10.1")
            assert r >= 0
            assert "unoptimized" not in name[0]
            whl = m.download(temp_folder=temp, source="2")
            fLOG(m.version)
            assert os.path.exists(whl)
            assert "unoptimized" not in whl
Example #23
0
 def test_install(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     if sys.version_info[0] == 2 or "conda" in sys.version:
         # disabled on python 2.7 and anaconda
         return
     m = ModuleInstall("pip", "pip")
     assert m.install()
     m = ModuleInstall("pip", "exe")
     assert m.install()
    def test_pypi_version(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("sphinx", "pip")
        vers = mod.get_pypi_version()
        assert vers >= "1.3.1"

        mod = ModuleInstall("scikit-learn", "wheel", mname="sklearn")
        fLOG(mod)
        vers = mod.get_pypi_version()
        assert vers >= "0.16.1"
        update = mod.has_update()
        fLOG("scikit-learn", update)

        if sys.version_info[0] == 2:
            # we don't test it for Python 2.7
            return

        mod = ModuleInstall("pandas", "wheel")
        vers = mod.get_pypi_version()
        if vers is None or vers < "0.16.1":
            raise Exception("{0}: {1}".format(mod.name, vers))

        mod = ModuleInstall("openpyxl", "pip", version="2.3.5")
        fLOG(mod)
        vers = mod.get_pypi_version()
        if vers is None or vers < "2.3.5":
            raise Exception("{0}: {1}".format(mod.name, vers))

        update = mod.has_update()
        if update:
            vers = mod.get_pypi_numeric_version()
            fLOG(vers)
        fLOG(update)
    def test_installed_version(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("jinja2", "pip")
        res = mod.is_installed_version()
        if not res:
            fLOG(mod)
            fLOG(mod.get_installed_version())
            for k, v in get_module_version(None).items():
                if k[0] in ("j", "J"):
                    fLOG("+++", k, v)
            assert False

        mod = ModuleInstall("pandas", "wheel")
        res = mod.is_installed_version()
        assert res
        fLOG("****", mod.get_installed_version(), mod.get_pypi_version())
        if mod.get_installed_version() != mod.get_pypi_version():
            assert mod.has_update()
    def test_update_module(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_update_module")

        if sys.version_info[0] >= 3:
            vers = get_pypi_version("pymyinstall", True)
            fLOG(vers)
            assert len(vers) > 0

            try:
                mod = ModuleInstall("joblib", "pip", fLOG=fLOG)
                mod.update(temp_folder=temp, source="2")
            except MissingInstalledPackageException:
                # not installed
                pass

            mod = ModuleInstall("pandas", "wheel", fLOG=fLOG)
            mod.update(temp_folder=temp, source="2")

            mod = ModuleInstall("xlrd", "pip", fLOG=fLOG)
            mod.update(temp_folder=temp, source="2")
    def test_pypi_version(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        mod = ModuleInstall("sphinx", "pip")
        vers = mod.get_pypi_version()
        assert vers >= "1.3.1"

        mod = ModuleInstall("scikit-learn", "wheel", mname="sklearn")
        fLOG(mod)
        vers = mod.get_pypi_version()
        assert vers >= "0.16.1"
        update = mod.has_update()
        fLOG("scikit-learn", update)

        if sys.version_info[0] == 2:
            # we don't test it for Python 2.7
            return

        mod = ModuleInstall("pandas", "wheel")
        vers = mod.get_pypi_version()
        if vers is None or vers < "0.16.1":
            raise Exception("{0}: {1}".format(mod.name, vers))

        mod = ModuleInstall("openpyxl", "pip", version="2.3.5")
        fLOG(mod)
        vers = mod.get_pypi_version()
        if vers is None or vers < "2.3.5":
            raise Exception("{0}: {1}".format(mod.name, vers))

        update = mod.has_update()
        if update:
            vers = mod.get_pypi_numeric_version()
            fLOG(vers)
        fLOG(update)