示例#1
0
 def run(self):
     if self.user is None:
         raise ValueError("user cannot be None")
     if self.password is None:
         raise ValueError("password cannot be None")
     from pyquickhelper.pycode import process_standard_options_for_setup
     parameters = self.get_parameters()
     parameters['argv'] = [
         'local_jenkins', self.user, self.password, self.location, self.url
     ]
     parameters['argv'] = [_ for _ in parameters['argv'] if _]
     process_standard_options_for_setup(**parameters)
示例#2
0
 def run(self):
     from pyquickhelper.pycode import process_standard_options_for_setup
     parameters = self.get_parameters()
     parameters['argv'] = ['write_version']
     print("project_var_name=%r" % parameters['project_var_name'])
     print("file_or_folder=%r" % parameters['file_or_folder'])
     print("module_name=%r" % parameters['module_name'])
     if 'github_owner' in parameters:
         print("github_owner=%r" % parameters['github_owner'])
     process_standard_options_for_setup(**parameters)
     if os.path.exists("version.txt"):
         with open("version.txt", "r") as f:
             content = f.read().strip(" \r\n")
         print("version=%s" % content)
示例#3
0
 def run(self):
     from pyquickhelper.pycode import process_standard_options_for_setup
     parameters = self.get_parameters()
     parameters['argv'] = ['unittests']
     if self.covtoken is not None:
         parameters['covtoken'] = self.covtoken
     if self.covtoken is not None:
         parameters['covtoken'] = (self.covtoken,
                                   "'%s' in outfile" % self.covcond)
     if self.d is not None:
         parameters['argv'].extend(['-d', '%s' % self.d])
     if self.e is not None:
         parameters['argv'].extend(['-e', '"%s"' % self.e])
     if self.g is not None:
         parameters['argv'].extend(['-g', '"%s"' % self.g])
     process_standard_options_for_setup(**parameters)
示例#4
0
    def skip_function(name, code, duration):
        if "notebook test" in code:
            return True
        if "test notebook" in code:
            return True
        return default_skip_function(name, code, duration)

    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=deps,
        requirements=deps,
        additional_local_path=deps,
        blog_list=os.path.abspath(
            os.path.join("src", project_var_name,
                         package_data[project_var_name][0])),
        covtoken=("5e030cea-7d27-46e7-bb2e-2fc3db0ae9f6",
                  "'_UT_36_std' in outfile"),
        nbformats=nbformats,
        layout=layout,
        fLOG=logging_function)

    if "build_script" in sys.argv and sys.platform.startswith("win"):
        pres = """
            :presentation:
            %pythonexe% -u setup.py build_pres
            if %errorlevel% neq 0 exit /b %errorlevel%
            %pythonexe% -u setup.py build_pres_2A
            if %errorlevel% neq 0 exit /b %errorlevel%
示例#5
0
    if must_build() and not ask_help():
        out = run_build_ext(__file__)
        print(out)

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=[
            "pyquickhelper", "cpyquickhelper", "jyquickhelper",
            "pandas_streaming"
        ],
        additional_local_path=[
            "pyquickhelper", "cpyquickhelper", "jyquickhelper",
            "pandas_streaming"
        ],
        requirements=["pyquickhelper", "jyquickhelper", "pandas_streaming"],
        layout=["html"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function,
        github_owner='sdpython',
        covtoken=("1ac0b95d-6722-4f29-804a-e4e0d5295497",
                  "'_UT_37_std' in outfile"))
    if not r and not (build_commmands & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
if "--verbose" in sys.argv:
    verbose()

if is_local():
    from pyquickhelper import get_fLOG
    logging_function = get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        extra_ext=["tohelp"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function,
        covtoken=("ce1fc48d-9081-44b3-ae09-8b4665e28e86",
                  "'_UT_36_std' in outfile"),
        layout=[
            "rst", "pdf", "epub", "html",
            ("html", "build2", {
                "html_theme": "alabaster"
            }, "source/phdoc_static2")
        ])
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
    def test_full_unit_test(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if __name__ != "__main__" or not os.path.exists("temp2_full_unit_test"):
            temp_ = get_temp_folder(__file__, "temp2_full_unit_test")
            temp = os.path.join(temp_, "python3_module_template")
            if not os.path.exists(temp):
                os.mkdir(temp)
            git_clone(temp, "github.com", "sdpython",
                      "python3_module_template")
            wait = 0
            while not os.path.exists(os.path.join(temp, "python3_module_template")) and wait < 5:
                fLOG("wait", wait)
                time.sleep(1000)
                wait += 1
        else:
            temp = os.path.abspath(os.path.join(
                "temp2_full_unit_test", "python3_module_template"))
        root = temp

        with sys_path_append(os.path.join(root, "src")):
            setup = os.path.join(root, "setup.py")
            pyq = os.path.join(os.path.dirname(pyquickhelper.__file__), "..")

            def skip_function(name, code, duration):
                return "test_example" not in name

            pyq_folder = os.path.normpath(os.path.abspath(
                os.path.join(os.path.dirname(pyq_location), '..')))

            blog_list = """
                <?xml version="1.0" encoding="UTF-8"?>
                <opml version="1.0">
                    <head>
                        <title>blog</title>
                    </head>
                    <body>
                        <outline text="python3_module_template"
                            title="python3_module_template"
                            type="rss"
                            xmlUrl="http://www.xavierdupre.fr/app/pyquickhelper/python3_module_template/_downloads/rss.xml"
                            htmlUrl="http://www.xavierdupre.fr/app/pyquickhelper/python3_module_template/blog/main_0000.html" />
                    </body>
                </opml>
                """

            stdout = StringIO()
            stderr = StringIO()
            fLOG("setup", setup)
            thispath = os.path.abspath(os.path.dirname(__file__))
            thispath = os.path.normpath(
                os.path.join(thispath, "..", "..", "src"))
            import jyquickhelper

            fLOG("unit tests", root)
            for command in ["version", "write_version", "clean_pyd",
                            "setup_hook", "build_script", "copy27",
                            "run_pylint .*((myex)|(example_ext)).*[.]py$ "
                            "-iC0103 -iR0201 -iC0123 -iC0111 -iW0611 -iE0401 -iE0611 -iE0401",
                            "unittests -e .*code_style.*",
                            "unittests -g .*((ext)|(code_style)|(run_notebooks)).*",
                            "unittests_LONG", "unittests_SKIP",
                            "build_sphinx"]:
                if command == "build_sphinx" and is_travis_or_appveyor() in ('travis', 'appveyor'):
                    # InkScape not installed for AppVeyor or travis.
                    continue
                if command == "build_sphinx" and is_travis_or_appveyor() in ('azurepip', ):
                    # AttributeError: type object 'Callable' has no attribute '_abc_registry'
                    continue

                fLOG("#######################################################")
                fLOG("#######################################################")
                fLOG(command)
                fLOG("#######################################################")
                rem = False
                PYTHONPATH = os.environ.get("PYTHONPATH", "")
                sep = ";" if sys.platform.startswith("win") else ":"
                new_val = PYTHONPATH + sep + thispath
                new_val_src = new_val + sep + 'src'
                if os.path.exists(new_val_src):
                    new_val = new_val_src
                os.environ["PYTHONPATH"] = new_val.strip(sep)
                if command == "build_sphinx":
                    if thispath not in sys.path:
                        sys.path.append(thispath)
                        fLOG("UT add", thispath)
                        rem = True
                log_lines = []

                def logging_custom(*l, **p):
                    log_lines.append(l)
                lcmd = command.split() if ' ' in command else [command]
                stdout2 = StringIO()
                stderr2 = StringIO()

                pos_remove = None
                if command == "unittests -e .*code_style.*":
                    if pyq_folder not in sys.path:
                        pos_remove = len(sys.path)
                        sys.path.append(pyq_folder)
                        fLOG("ADD='{0}'".format(pyq_folder))

                try:
                    r = process_standard_options_for_setup(
                        lcmd, setup, "python3_module_template",
                        port=8067, requirements=["pyquickhelper"], blog_list=blog_list,
                        fLOG=logging_custom, additional_ut_path=[
                            pyq, (root, True)],
                        skip_function=skip_function, coverage_options={
                            "disable_coverage": True},
                        hook_print=False, stdout=stdout2, stderr=stderr2, use_run_cmd=True)
                    goon = True
                except TestWrappedException as e:
                    if "test_coverage_combine.py" in str(e):
                        goon = False
                    else:
                        raise e
                except NotImplementedError:
                    # Maybe not implemented on linux or windows.
                    goon = False

                if goon:
                    if command == "unittests -e .*code_style.*" and pos_remove:
                        if sys.path[pos_remove] != pyq_folder:
                            raise Exception(
                                "sys.path has changed at position {0}".format(pos_remove))
                        del sys.path[pos_remove]
                        fLOG("REMOVE='{0}'".format(pyq_folder))
                elif pos_remove:
                    del sys.path[pos_remove]

                vout = stdout2.getvalue()
                stdout.write(vout)
                verr = stderr2.getvalue()
                stderr.write(verr)

                if "unittests" in command:
                    if not r:
                        raise Exception("{0}-{1}".format(r, command))
                    for line in log_lines:
                        fLOG("  ", line)
                    if len(log_lines) == 0:
                        raise Exception(
                            "command1={0}\n--OUT--\n{1}\n--ERR--\n{2}".format(command, vout, verr))
                    if "-e" in command and "running test   1, ut_module/test_convert_notebooks.py" in vout:
                        raise Exception(vout)
                    if "-e" in command and "_ext" not in vout and "code_style" not in command:
                        raise Exception(
                            "command3={0}\n--OUT--\n{1}".format(command, vout))
                    if "LONG" in command and "running test   1, ut_module/test_convert_notebooks.py" in vout:
                        raise Exception(vout)
                if rem:
                    del sys.path[sys.path.index(thispath)]
                os.environ["PYTHONPATH"] = PYTHONPATH

            fLOG("#######################################################")
            fLOG("#######################################################")
            fLOG("OUT:\n", stdout.getvalue())
            fLOG("ERR:\n", stderr.getvalue())

            out = os.path.join(temp, "_unittests", "unittests.out")
            if not os.path.exists(out):
                raise Exception("not found: " + out)
示例#8
0
    if "build_sphinx" in sys.argv and not sys.platform.startswith("win"):
        # There is an issue with matplotlib and notebook gallery on linux
        # _tkinter.TclError: no display name and no $DISPLAY environment variable
        import matplotlib
        matplotlib.use('agg')

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=[
            "pyquickhelper", "jyquickhelper", "mlinsights"
        ],
        additional_local_path=["pyquickhelper", "jyquickhelper", "mlinsights"],
        requirements=["pyquickhelper", "jyquickhelper"],
        layout=["html"],
        github_owner="sdpython",
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function,
        covtoken=("add92ff0-d57a-46f5-872b-9ac527c94917",
                  "'_UT_39_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
示例#9
0
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        # not need for the regular setup, just for the documentation, unit
        layout=["html"],
        # tests
        requirements=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper"],
        additional_local_path=["pyquickhelper"],
        unittest_modules=["pyquickhelper"], fLOG=logging_function,
        covtoken=("b67b3051-8c5d-460b-b2fa-51d81ab7008c", "'_UT_35_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
    if "build_script" in sys.argv and sys.platform.startswith("win"):
        this = os.path.dirname(__file__)
        with open(os.path.join(this, "auto_setup_build_sphinx.bat"), "r") as f:
            content = f.read()
        code = "%pythonexe% -u -c \"import sys;sys.path.append('src');from pymyinstall.packaged import update_all;update_all(temp_folder='build/update_modules', verbose=True, source='2')\""
        content = content.replace("%pythonexe% -u setup.py build_sphinx", code)
        with open(os.path.join(this, "auto_update_modules.bat"), "w") as f:
示例#10
0
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        # not need for the regular setup, just for the documentation, unit
        layout=["html"],
        # tests
        requirements=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper"],
        additional_local_path=["pyquickhelper"],
        unittest_modules=["pyquickhelper"], fLOG=logging_function,
        covtoken=("b67b3051-8c5d-460b-b2fa-51d81ab7008c", "'_UT_35_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        pyquickhelper = import_pyquickhelper()
        from pyquickhelper.pycode import process_standard_options_for_setup_help
示例#11
0
        long_description += f.read()

if "--verbose" in sys.argv:
    verbose()

if is_local():
    from pyquickhelper import get_fLOG
    logging_function = get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        extra_ext=["tohelp"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner=project_owner,
        fLOG=logging_function,
        covtoken=("c9394f94-fc82-4fe5-a4d4-268593b8d897",
                  "'_UT_39_std' in outfile"),
        layout=["rst", "html"])
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands", ):
示例#12
0
    with open(readme, "r", encoding='utf-8-sig') as f:
        long_description = f.read()
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name, port=8067,
        requirements=requirements, blog_list=pyquickhelper.__blog__,
        layout=["html"], additional_notebook_path=["jyquickhelper"],
        fLOG=logging_function, covtoken=("69193a28-dc79-4a24-98ed-aedf441a8249", "'_UT_35_std' in outfile"))

    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        pyquickhelper = import_pyquickhelper()
        from pyquickhelper.pycode import process_standard_options_for_setup_help
        process_standard_options_for_setup_help(sys.argv)
示例#13
0
    logging_function(OutputPrint=True)
    must_build, run_build_ext = get_insetup_functions()

    if must_build():
        out = run_build_ext(__file__)
        print(out)

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        extra_ext=["cs"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner=project_owner,
        fLOG=logging_function,
        covtoken=("d911f0bb-f250-415d-860b-19b342a4f168",
                  "'_UT_39_std' in outfile"),
        requirements=["pyquickhelper", "jyquickhelper", "csharpy"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper", "csharpy"],
        additional_local_path=["pyquickhelper", "jyquickhelper", "csharpy"],
        copy_add_ext=["dll", 'so'],
        layout=["html"])
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
示例#14
0
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    from pyquickhelper.loghelper import fLOG as logging_function
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper"],
        additional_local_path=["pyquickhelper"],
        requirements=["pyquickhelper"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function, covtoken=("ab2da06c-1ff3-4875-97fa-145e594bd7f9", "'jenkins' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if len(sys.argv) == 1 and "--help" in sys.argv:
    pyquickhelper = import_pyquickhelper()
    from pyquickhelper.pycode import process_standard_options_for_setup_help
    process_standard_options_for_setup_help()
示例#15
0
    with open(history, "r", encoding='utf-8-sig') as f:
        long_description += f.read()

if "--verbose" in sys.argv:
    verbose()

if is_local():
    from pyquickhelper import get_fLOG
    logging_function = get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        extra_ext=["tohelp"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner=project_owner,
        fLOG=logging_function, covtoken=(
            "ce1fc48d-9081-44b3-ae09-8b4665e28e86", "'_UT_37_std' in outfile"),
        layout=["rst", "pdf", "html"])
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        from pyquickhelper.pycode import process_standard_options_for_setup_help
        process_standard_options_for_setup_help(sys.argv)
示例#16
0
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        layout=["html"],
        unittest_modules=["pyquickhelper", "pymyinstall"],
        requirements=["pyquickhelper", "pymyinstall"],
        additional_notebook_path=["pyquickhelper"],
        coverage_options=dict(
            omit=["*Parser.py", "*Listener.py", "*Lexer.py"]),
        fLOG=logging_function, covtoken=("f929c9b3-bf00-4928-906a-b1dc54d5a5d9", "'_UT_35_std' in outfile"))
    if not r and "update_grammars" in sys.argv:
        # expecting python setup.py update_grammars file
        ind = sys.argv.index("update_grammars")
        if len(sys.argv) <= ind:
            raise Exception(
                "expecting a grammar file: python setup.py update_grammars R.g4")
        grammar = sys.argv[ind + 1]
        if not os.path.exists(grammar):
            g2 = os.path.join("src", "pyensae", "languages", grammar)
            if not os.path.exists(g2):
                raise FileNotFoundError(grammar)
示例#17
0
    verbose()

if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=[
            "pyquickhelper", "pandas_streaming", "pymyinstall", "jyquickhelper"
        ],
        additional_local_path=[
            "pyquickhelper", "pandas_streaming", "pymyinstall", "jyquickhelper"
        ],
        requirements=["pyquickhelper", "pymyinstall"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner="sdpython",
        fLOG=logging_function,
        covtoken=("983adc1c-d7b1-4afa-8673-4345163704d2",
                  "'_UT_37_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
    def test_full_unit_test(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if __name__ != "__main__" or not os.path.exists("temp2_full_unit_test_history"):
            temp_ = get_temp_folder(__file__, "temp2_full_unit_test_history")
            temp = os.path.join(temp_, "python3_module_template")
            if not os.path.exists(temp):
                os.mkdir(temp)
            git_clone(temp, "github.com", "sdpython",
                      "python3_module_template")
            wait = 0
            while not os.path.exists(os.path.join(temp, "python3_module_template")) and wait < 5:
                fLOG("wait", wait)
                time.sleep(1000)
                wait += 1
        else:
            temp = os.path.abspath(os.path.join(
                "temp2_full_unit_test", "python3_module_template"))
        root = temp

        with sys_path_append(os.path.join(root)):
            setup = os.path.join(root, "setup.py")
            pyq = os.path.join(os.path.dirname(pyquickhelper.__file__), "..")

            def skip_function(name, code, duration):
                return "test_example" not in name

            pyq_folder = os.path.normpath(os.path.abspath(
                os.path.join(os.path.dirname(pyq_location), '..')))

            stdout = StringIO()
            stderr = StringIO()
            fLOG("setup", setup)
            thispath = os.path.abspath(os.path.dirname(__file__))
            thispath = os.path.normpath(
                os.path.join(thispath, "..", "..", "src"))
            import jyquickhelper

            fLOG("unit tests", root)
            for command in ["build_history"]:
                fLOG("#######################################################")
                fLOG("#######################################################")
                fLOG(command)
                fLOG("#######################################################")
                rem = False
                PYTHONPATH = os.environ.get("PYTHONPATH", "")
                sep = ";" if sys.platform.startswith("win") else ":"
                new_val = PYTHONPATH + sep + thispath
                os.environ["PYTHONPATH"] = new_val.strip(sep)
                log_lines = []

                def logging_custom(*l, **p):
                    log_lines.append(l)
                lcmd = command.split() if ' ' in command else [command]
                stdout2 = StringIO()
                stderr2 = StringIO()

                r = process_standard_options_for_setup(
                    lcmd, setup, "python3_module_template",
                    port=8067, requirements=["pyquickhelper"], blog_list=None,
                    fLOG=logging_custom, additional_ut_path=[
                        pyq, (root, True)],
                    skip_function=skip_function, coverage_options={
                        "disable_coverage": True},
                    hook_print=False, stdout=stdout2, stderr=stderr2, use_run_cmd=True)

                vout = stdout2.getvalue()
                stdout.write(vout)
                verr = stderr2.getvalue()
                stderr.write(verr)
                if rem:
                    del sys.path[sys.path.index(thispath)]
                os.environ["PYTHONPATH"] = PYTHONPATH

            fLOG("#######################################################")
            fLOG("#######################################################")
            sout = stdout.getvalue()
            fLOG("--OUT--\n", sout)
            fLOG("--ERR--\n", stderr.getvalue())
            if len(sout) == 0:
                fLOG("Empty output. thispath='{}'".format(thispath))
示例#19
0
 def run(self):
     from pyquickhelper.pycode import process_standard_options_for_setup
     parameters = self.get_parameters()
     parameters['argv'] = ['build_sphinx']
     parameters['layout'] = self.layout.split(',')
     process_standard_options_for_setup(**parameters)
示例#20
0
    else:
        nbformats = ['ipynb', 'html', 'python',
                     'rst', 'slides', 'github']

    def skip_function(name, code, duration):
        if "notebook test" in code:
            return True
        if "test notebook" in code:
            return True
        return default_skip_function(name, code, duration)

    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name, unittest_modules=[
            "pyquickhelper"],
        additional_notebook_path=deps, requirements=deps, additional_local_path=deps,
        blog_list=os.path.abspath(os.path.join(
            "src", project_var_name, package_data[project_var_name][0])),
        covtoken=("5e030cea-7d27-46e7-bb2e-2fc3db0ae9f6",
                  "'_UT_37_std' in outfile"),
        nbformats=nbformats, layout=layout,
        fLOG=logging_function, github_owner="sdpython")
else:
    r = False

if ask_help():
    from pyquickhelper.pycode import process_standard_options_for_setup_help
    process_standard_options_for_setup_help(sys.argv)

if not r:

    if "try_import" in sys.argv:
        sys.path.append("src")
示例#21
0
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper"],
        requirements=["pyquickhelper", "jyquickhelper",
                      "pyensae", "pyrsslocal", "pymyinstall"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper",
                                  "pyensae", "pyrsslocal", "pymyinstall"],
        additional_local_path=["pyquickhelper", "jyquickhelper",
                               "pyensae", "pyrsslocal", "pymyinstall"],
        copy_add_ext=["enc"], fLOG=logging_function, layout=['html'],
        covtoken=("ad448134-a962-480b-85c6-a899999575d5", "'_UT_35_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        pyquickhelper = import_pyquickhelper()
示例#22
0
文件: setup.py 项目: gaardhus/pyensae
if "--verbose" in sys.argv:
    verbose()

if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        layout=["html"],
        unittest_modules=["pyquickhelper", "jyquickhelper", "pymyinstall"],
        requirements=["pyquickhelper", "jyquickhelper", "pymyinstall"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper"],
        coverage_options=dict(
            omit=["*Parser.py", "*Listener.py", "*Lexer.py"]),
        github_owner='sdpython',
        fLOG=logging_function,
        covtoken=("f929c9b3-bf00-4928-906a-b1dc54d5a5d9",
                  "'_UT_39_std' in outfile"))
    if not r and "update_grammars" in sys.argv:
        # expecting python setup.py update_grammars file
        ind = sys.argv.index("update_grammars")
        if len(sys.argv) <= ind:
            raise Exception(
                "expecting a grammar file: python setup.py update_grammars R.g4"
            )
        grammar = sys.argv[ind + 1]
        try:
示例#23
0
    if "build_sphinx" in sys.argv and not sys.platform.startswith("win"):
        # There is an issue with matplotlib and notebook gallery on linux
        # _tkinter.TclError: no display name and no $DISPLAY environment variable
        import matplotlib
        matplotlib.use('agg')

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper"],
        additional_local_path=["pyquickhelper", "jyquickhelper"],
        requirements=["pyquickhelper", "jyquickhelper"],
        layout=["html"],
        github_owner="sdpython",
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function,
        covtoken=("f2a30eb6-439e-4a94-97e4-1eb48e40d3aa",
                  "'_UT_37_std' in outfile"),
        skip_issues=[36])
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
示例#24
0
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    from pyquickhelper import get_fLOG
    logging_function = get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        extra_ext=["tohelp"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function, covtoken=(
            "ce1fc48d-9081-44b3-ae09-8b4665e28e86", "'_UT_35_std' in outfile"),
        layout=["pdf", "epub", "html",
                ("html", "build2", {"html_theme": "alabaster"}, "source/phdoc_static2")])
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        from pyquickhelper.pycode import process_standard_options_for_setup_help
        process_standard_options_for_setup_help(sys.argv)
示例#25
0
文件: setup.py 项目: sdpython/csharpy
    logging_function(OutputPrint=True)
    must_build, run_build_ext = get_insetup_functions()

    if must_build():
        out = run_build_ext(__file__)
        print(out)

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        extra_ext=["cs"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner=project_owner,
        fLOG=logging_function,
        covtoken=("80f56646-c804-4fb7-8476-2211bb9108d1",
                  "'_UT_39_std' in outfile"),
        requirements=["pyquickhelper", "jyquickhelper"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper"],
        additional_local_path=["pyquickhelper", "jyquickhelper"],
        copy_add_ext=["dll", 'so'],
        layout=["pdf", "html"])
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
示例#26
0
if "--verbose" in sys.argv:
    verbose()

if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper", "jyquickhelper", "mlinsights"],
        additional_notebook_path=["pyquickhelper", "pyensae", "cpyquickhelper",
                                  "pymyinstall", "jyquickhelper", "mlinsights"],
        additional_local_path=["pyquickhelper", "pyensae", "cpyquickhelper",
                               "pymyinstall", "jyquickhelper", "mlinsights"],
        requirements=["pyquickhelper", "pymyinstall", "cpyquickhelper",
                      "jyquickhelper", "pyensae", "mlinsights"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner="sdpython",
        fLOG=logging_function, covtoken=("ab2da06c-1ff3-4875-97fa-145e594bd7f9", "'_UT_37_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if ask_help():
    from pyquickhelper.pycode import process_standard_options_for_setup_help
示例#27
0
        # _tkinter.TclError: no display name and no $DISPLAY environment variable
        import matplotlib
        matplotlib.use('agg')

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper", "pyensae"],
        additional_notebook_path=[
            "pyquickhelper", "jyquickhelper", "pandas_streaming", "pyensae",
            "mlinsights"
        ],
        additional_local_path=[
            "pyquickhelper", "jyquickhelper", "pandas_streaming", "pyensae",
            "mlinsights"
        ],
        requirements=[
            "pyquickhelper", "jyquickhelper", "pandas_streaming", "mlinsights"
        ],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner="sdpython",
        fLOG=logging_function,
        covtoken=("c0bd10d2-a7ae-4ba3-8c88-d570676f6df3",
                  "'_UT_39_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
示例#28
0
 def run(self):
     from pyquickhelper.pycode import process_standard_options_for_setup
     parameters = self.get_parameters()
     parameters['argv'] = ['history']
     process_standard_options_for_setup(**parameters)
示例#29
0
    def test_full_unit_test(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        if __name__ != "__main__" or not os.path.exists(
                "temp2_full_unit_test_history"):
            temp_ = get_temp_folder(__file__, "temp2_full_unit_test_history")
            temp = os.path.join(temp_, "python3_module_template")
            if not os.path.exists(temp):
                os.mkdir(temp)
            git_clone(temp, "github.com", "sdpython",
                      "python3_module_template")
            wait = 0
            while not os.path.exists(
                    os.path.join(temp,
                                 "python3_module_template")) and wait < 5:
                fLOG("wait", wait)
                time.sleep(1000)
                wait += 1
        else:
            temp = os.path.abspath(
                os.path.join("temp2_full_unit_test",
                             "python3_module_template"))
        root = temp

        with sys_path_append(os.path.join(root)):
            setup = os.path.join(root, "setup.py")
            pyq = os.path.join(os.path.dirname(pyquickhelper.__file__), "..")

            def skip_function(name, code, duration):
                return "test_example" not in name

            pyq_folder = os.path.normpath(
                os.path.abspath(
                    os.path.join(os.path.dirname(pyq_location), '..')))

            stdout = StringIO()
            stderr = StringIO()
            fLOG("setup", setup)
            thispath = os.path.abspath(os.path.dirname(__file__))
            thispath = os.path.normpath(
                os.path.join(thispath, "..", "..", "src"))
            import jyquickhelper

            fLOG("unit tests", root)
            for command in ["build_history"]:
                fLOG("#######################################################")
                fLOG("#######################################################")
                fLOG(command)
                fLOG("#######################################################")
                rem = False
                PYTHONPATH = os.environ.get("PYTHONPATH", "")
                sep = ";" if sys.platform.startswith("win") else ":"
                new_val = PYTHONPATH + sep + thispath
                os.environ["PYTHONPATH"] = new_val.strip(sep)
                log_lines = []

                def logging_custom(*args, **kwargs):
                    log_lines.append(args)

                lcmd = command.split() if ' ' in command else [command]
                stdout2 = StringIO()
                stderr2 = StringIO()

                r = process_standard_options_for_setup(
                    lcmd,
                    setup,
                    "python3_module_template",
                    port=8067,
                    requirements=["pyquickhelper"],
                    blog_list=None,
                    fLOG=logging_custom,
                    additional_ut_path=[pyq, (root, True)],
                    skip_function=skip_function,
                    coverage_options={"disable_coverage": True},
                    stdout=stdout2,
                    stderr=stderr2,
                    use_run_cmd=True)

                vout = stdout2.getvalue()
                stdout.write(vout)
                verr = stderr2.getvalue()
                stderr.write(verr)
                if rem:
                    del sys.path[sys.path.index(thispath)]
                os.environ["PYTHONPATH"] = PYTHONPATH

            fLOG("#######################################################")
            fLOG("#######################################################")
            sout = stdout.getvalue()
            fLOG("--OUT--\n", sout)
            fLOG("--ERR--\n", stderr.getvalue())
            if len(sout) == 0:
                fLOG("Empty output. thispath='{}'".format(thispath))
示例#30
0
if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        layout=["html"],
        unittest_modules=["pyquickhelper", "ensae_teaching_cs"],
        requirements=[
            "pyquickhelper", "pyensae", "jyquickhelper", "pyrsslocal",
            "pymyinstall", "mlstatpy", "ensae_teaching_cs"
        ],
        additional_notebook_path=[
            "pyquickhelper", "jyquickhelper", "pyensae", "pyrsslocal",
            "pymyinstall", "mlstatpy", "ensae_teaching_cs"
        ],
        additional_local_path=[
            "pyquickhelper", "jyquickhelper", "pyensae", "pyrsslocal",
            "pymyinstall", "mlstatpy", "ensae_teaching_cs"
        ],
        fLOG=logging_function,
        github_owner='sdpython',
        covtoken=("c310b252-ef1b-4454-896c-2d2e01670378",
                  "'_UT_37_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
示例#31
0
    with open(readme, "r", encoding='utf-8-sig') as f:
        long_description = f.read()
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        requirements=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper"],
        unittest_modules=["pyquickhelper"],
        fLOG=logging_function, covtoken=("48330d77-e22b-41b7-83f4-8dbc39abd93b", "'_UT_35_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        pyquickhelper = import_pyquickhelper()
        from pyquickhelper.pycode import process_standard_options_for_setup_help
        process_standard_options_for_setup_help(sys.argv)
示例#32
0
if os.path.exists(history):
    with open(history, "r", encoding='utf-8-sig') as f:
        long_description += f.read()

if "--verbose" in sys.argv:
    verbose()

if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper"],
        requirements=["pyquickhelper"], fLOG=logging_function,
        github_owner='sdpython',
        covtoken=("c17fe586-68b7-4157-9af0-a73c92d16fc7", "'_UT_37_std' in outfile"))

    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if ask_help():
    from pyquickhelper.pycode import process_standard_options_for_setup_help
    process_standard_options_for_setup_help(sys.argv)
示例#33
0
 logging_function = pyquickhelper.get_fLOG()
 logging_function(OutputPrint=True)
 if "unittests" in sys.argv and sys.platform.startswith("win"):
     # There is some issues on Windows.
     from PIL import Image as PIL_Image
     assert PIL_Image is not None
 r = process_standard_options_for_setup(
     sys.argv, __file__, project_var_name, layout=["html"],
     unittest_modules=["pyquickhelper", "jyquickhelper"],
     additional_notebook_path=["mlstatpy", "teachpyx", "pyquickhelper",
                               "jyquickhelper", "ensae_teaching_cs",
                               "pyensae", "csharpy", "csharpyml"],
     additional_local_path=["pyquickhelper", "pyensae", "mlstatpy", "teachpyx",
                            "jyquickhelper", "ensae_teaching_cs",
                            "csharpy", "csharpyml"],
     requirements=["pyquickhelper", "jyquickhelper", "mlstatpy", "teachpyx",
                   "ensae_teaching_cs", "pyensae", "csharpy",
                   "csharpyml"],
     add_htmlhelp=sys.platform.startswith("win"),
     coverage_options=dict(omit=["*exclude*.py"]),
     fLOG=logging_function, covtoken=(
         "989a8320-d21b-47f4-910b-f1fd9b2e5415", "'_UT_37_std' in outfile"),
     nbformats=('ipynb', 'html', 'python', 'rst',
                'slides', 'present', 'github'),
     github_owner='sdpython')
 if not r and "update_grammars" in sys.argv:
     # expecting python setup.py update_grammars file
     ind = sys.argv.index("update_grammars")
     if len(sys.argv) <= ind:
         raise Exception(
             "Expecting a grammar file: python setup.py update_grammars MokadiGrammar.g4")
示例#34
0
        long_description = f.read()
else:
    long_description = ""

if "--verbose" in sys.argv:
    verbose()

if is_local():
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper", "pyensae", "pymyinstall"],
        additional_notebook_path=["pyquickhelper", "pyensae", "pymyinstall"],
        requirements=["pyquickhelper", "pyensae", "pymyinstall"],
        additional_local_path=["pyquickhelper", "pyensae", "pymyinstall"],
        fLOG=logging_function, covtoken=("6f97e59c-33f4-4705-a8a6-f529e9604882", "'_UT_35_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if not r:
    if len(sys.argv) in (1, 2) and sys.argv[-1] in ("--help-commands",):
        pyquickhelper = import_pyquickhelper()
        from pyquickhelper.pycode import process_standard_options_for_setup_help
        process_standard_options_for_setup_help(sys.argv)
示例#35
0
if "--verbose" in sys.argv:
    verbose()

if is_local() and not ({"history"} & set(sys.argv)):
    pyquickhelper = import_pyquickhelper()
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        port=8067,
        requirements=requirements,
        blog_list=pyquickhelper.__blog__,
        layout=["rst", "html"],
        additional_notebook_path=["jyquickhelper"],
        fLOG=logging_function,
        covtoken=("69193a28-dc79-4a24-98ed-aedf441a8249",
                  "'_UT_37_std' in outfile"),
        github_owner=github_owner)

    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
    def test_full_unit_test(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        if __name__ != "__main__" or not os.path.exists(
                "temp2_full_unit_test"):
            temp_ = get_temp_folder(__file__, "temp2_full_unit_test")
            temp = os.path.join(temp_, "python3_module_template")
            if not os.path.exists(temp):
                os.mkdir(temp)
            git_clone(temp, "github.com", "sdpython",
                      "python3_module_template")
            wait = 0
            while not os.path.exists(
                    os.path.join(temp,
                                 "python3_module_template")) and wait < 5:
                fLOG("wait", wait)
                time.sleep(1000)
                wait += 1
        else:
            temp = os.path.abspath(
                os.path.join("temp2_full_unit_test",
                             "python3_module_template"))
        root = temp

        with sys_path_append(os.path.join(root, "src")):
            setup = os.path.join(root, "setup.py")
            pyq = os.path.join(os.path.dirname(pyquickhelper.__file__), "..")

            def skip_function(name, code, duration):
                return "test_example" not in name

            pyq_folder = os.path.normpath(
                os.path.abspath(
                    os.path.join(os.path.dirname(pyq_location), '..')))

            blog_list = """
                <?xml version="1.0" encoding="UTF-8"?>
                <opml version="1.0">
                    <head>
                        <title>blog</title>
                    </head>
                    <body>
                        <outline text="python3_module_template"
                            title="python3_module_template"
                            type="rss"
                            xmlUrl="http://www.xavierdupre.fr/app/pyquickhelper/python3_module_template/_downloads/rss.xml"
                            htmlUrl="http://www.xavierdupre.fr/app/pyquickhelper/python3_module_template/blog/main_0000.html" />
                    </body>
                </opml>
                """

            stdout = StringIO()
            stderr = StringIO()
            fLOG("setup", setup)
            thispath = os.path.abspath(os.path.dirname(__file__))
            thispath = os.path.normpath(
                os.path.join(thispath, "..", "..", "src"))
            import jyquickhelper

            fLOG("unit tests", root)
            for command in [
                    "version", "write_version", "clean_pyd", "setup_hook",
                    "build_script", "copy27",
                    "run_pylint .*((myex)|(example_ext)).*[.]py$ "
                    "-iC0103 -iR0201 -iC0123 -iC0111 -iW0611 -iE0401 -iE0611 -iE0401",
                    "unittests -e .*code_style.*",
                    "unittests -g .*((ext)|(code_style)|(run_notebooks)).*",
                    "unittests_LONG", "unittests_SKIP", "build_sphinx"
            ]:
                if command == "build_sphinx" and is_travis_or_appveyor() in (
                        'travis', 'appveyor'):
                    # InkScape not installed for AppVeyor or travis.
                    continue
                if command == "build_sphinx" and is_travis_or_appveyor() in (
                        'azurepip', ):
                    # AttributeError: type object 'Callable' has no attribute '_abc_registry'
                    continue

                fLOG("#######################################################")
                fLOG("#######################################################")
                fLOG(command)
                fLOG("#######################################################")
                rem = False
                PYTHONPATH = os.environ.get("PYTHONPATH", "")
                sep = ";" if sys.platform.startswith("win") else ":"
                new_val = PYTHONPATH + sep + thispath
                new_val_src = new_val + sep + 'src'
                if os.path.exists(new_val_src):
                    new_val = new_val_src
                os.environ["PYTHONPATH"] = new_val.strip(sep)
                if command == "build_sphinx":
                    if thispath not in sys.path:
                        sys.path.append(thispath)
                        fLOG("UT add", thispath)
                        rem = True
                log_lines = []

                def logging_custom(*args, **kwargs):
                    log_lines.append(args)

                lcmd = command.split() if ' ' in command else [command]
                stdout2 = StringIO()
                stderr2 = StringIO()

                pos_remove = None
                if command == "unittests -e .*code_style.*":
                    if pyq_folder not in sys.path:
                        pos_remove = len(sys.path)
                        sys.path.append(pyq_folder)
                        fLOG("ADD='{0}'".format(pyq_folder))

                try:
                    r = process_standard_options_for_setup(
                        lcmd,
                        setup,
                        "python3_module_template",
                        port=8067,
                        requirements=["pyquickhelper"],
                        blog_list=blog_list,
                        fLOG=logging_custom,
                        additional_ut_path=[pyq, (root, True)],
                        skip_function=skip_function,
                        coverage_options={"disable_coverage": True},
                        hook_print=False,
                        stdout=stdout2,
                        stderr=stderr2,
                        use_run_cmd=True)
                    goon = True
                except PEP8Exception as e:
                    lines = str(e).split('\n')[1:]
                    lines = [
                        line for line in lines
                        if "should be placed before" not in line
                    ]
                    content = "\n".join(lines).strip("\n\r\t ")
                    if len(content) > 0:
                        raise AssertionError(
                            "Remaining style issues.\n{}".format(
                                content)) from e
                except TestWrappedException as e:
                    if "test_coverage_combine.py" in str(e):
                        goon = False
                    else:
                        raise e
                except NotImplementedError:
                    # Maybe not implemented on linux or windows.
                    goon = False

                if goon:
                    if command == "unittests -e .*code_style.*" and pos_remove:
                        if sys.path[pos_remove] != pyq_folder:
                            raise Exception(
                                "sys.path has changed at position {0}".format(
                                    pos_remove))
                        del sys.path[pos_remove]
                        fLOG("REMOVE='{0}'".format(pyq_folder))
                elif pos_remove:
                    del sys.path[pos_remove]

                vout = stdout2.getvalue()
                stdout.write(vout)
                verr = stderr2.getvalue()
                stderr.write(verr)

                if "unittests" in command:
                    if not r:
                        raise Exception("{0}-{1}".format(r, command))
                    for line in log_lines:
                        fLOG("  ", line)
                    if len(log_lines) == 0:
                        raise Exception(
                            "command1={0}\n--OUT--\n{1}\n--ERR--\n{2}".format(
                                command, vout, verr))
                    if "-e" in command and "running test   1, ut_module/test_convert_notebooks.py" in vout:
                        raise Exception(vout)
                    if "-e" in command and "_ext" not in vout and "code_style" not in command:
                        raise Exception("command3={0}\n--OUT--\n{1}".format(
                            command, vout))
                    if "LONG" in command and "running test   1, ut_module/test_convert_notebooks.py" in vout:
                        raise Exception(vout)
                if rem:
                    del sys.path[sys.path.index(thispath)]
                os.environ["PYTHONPATH"] = PYTHONPATH

            fLOG("#######################################################")
            fLOG("#######################################################")
            fLOG("OUT:\n", stdout.getvalue())
            fLOG("ERR:\n", stderr.getvalue())

            out = os.path.join(temp, "_unittests", "unittests.out")
            if not os.path.exists(out):
                raise Exception("not found: " + out)
示例#37
0
if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    from pyquickhelper.pycode import process_standard_options_for_setup
    logging_function(OutputPrint=True)
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=[
            "jyquickhelper", "pyquickhelper", "pyensae", "pyrsslocal",
            "pymyinstall", "pymmails", "ensae_projects"
        ],
        requirements=[
            "pyquickhelper",
            "jyquickhelper",
        ],
        blog_list=os.path.abspath(
            os.path.join("src", project_var_name,
                         package_data[project_var_name][0])),
        fLOG=logging_function,
        github_owner=project_owner,
        covtoken=("4326eb4c-78b5-4ff3-9317-9329fdb20f43",
                  "'_UT_37_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
示例#38
0
    if "build_sphinx" in sys.argv and not sys.platform.startswith("win"):
        # There is an issue with matplotlib and notebook gallery on linux
        # _tkinter.TclError: no display name and no $DISPLAY environment variable
        import matplotlib
        matplotlib.use('agg')

    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv,
        __file__,
        project_var_name,
        unittest_modules=["pyquickhelper"],
        additional_notebook_path=["pyquickhelper", "jyquickhelper"],
        additional_local_path=["pyquickhelper", "jyquickhelper"],
        requirements=["pyquickhelper", "jyquickhelper"],
        layout=["html"],
        github_owner='sdpython',
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        fLOG=logging_function,
        covtoken=("14c7930a-a5c0-405d-a22f-3f9c6feaf0bc",
                  "'_UT_37_std' in outfile"))
    if not r and not ({
            "bdist_msi", "sdist", "bdist_wheel", "publish", "publish_doc",
            "register", "upload_docs", "bdist_wininst", "build_ext"
    } & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False
示例#39
0
if "--verbose" in sys.argv:
    verbose()

if is_local():
    import pyquickhelper
    logging_function = pyquickhelper.get_fLOG()
    logging_function(OutputPrint=True)
    from pyquickhelper.pycode import process_standard_options_for_setup
    r = process_standard_options_for_setup(
        sys.argv, __file__, project_var_name,
        unittest_modules=["pyquickhelper", "jyquickhelper", "mlinsights"],
        additional_notebook_path=["pyquickhelper", "pyensae", "cpyquickhelper",
                                  "pymyinstall", "jyquickhelper", "mlinsights"],
        additional_local_path=["pyquickhelper", "pyensae", "cpyquickhelper",
                               "pymyinstall", "jyquickhelper", "mlinsights"],
        requirements=["pyquickhelper", "pymyinstall", "cpyquickhelper",
                      "jyquickhelper", "pyensae", "mlinsights"],
        add_htmlhelp=sys.platform.startswith("win"),
        coverage_options=dict(omit=["*exclude*.py"]),
        github_owner="sdpython",
        fLOG=logging_function, covtoken=("ab2da06c-1ff3-4875-97fa-145e594bd7f9", "'_UT_37_std' in outfile"))
    if not r and not ({"bdist_msi", "sdist",
                       "bdist_wheel", "publish", "publish_doc", "register",
                       "upload_docs", "bdist_wininst", "build_ext"} & set(sys.argv)):
        raise Exception("unable to interpret command line: " + str(sys.argv))
else:
    r = False

if ask_help():
    from pyquickhelper.pycode import process_standard_options_for_setup_help