diff --git a/.circleci/config.yml b/.circleci/config.yml index d676557..9e597ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.7.0 + - image: circleci/python:3.7.2 working_directory: ~/repo @@ -72,12 +72,14 @@ jobs: name: run tests command: | . venv/bin/activate + export PYTHONPATH=src python setup.py unittests - run: name: wheel command: | . venv/bin/activate + export PYTHONPATH=src python setup.py bdist_wheel mkdir -p test-reports/dist cp dist/*.whl test-reports/dist @@ -86,6 +88,7 @@ jobs: name: documentation command: | . venv/bin/activate + export PYTHONPATH=src python setup.py build_sphinx - run: @@ -96,4 +99,4 @@ jobs: - store_artifacts: path: test-reports - destination: test-reports \ No newline at end of file + destination: test-reports diff --git a/.local.jenkins.lin.yml b/.local.jenkins.lin.yml index 4f3dd5e..fc3293c 100644 --- a/.local.jenkins.lin.yml +++ b/.local.jenkins.lin.yml @@ -2,7 +2,7 @@ language: python python: - - { PATH: "{{Python37}}", VERSION: 3.7, DIST: std, PYINT: python3.7 } + - { PATH: "{{Python37}}", VERSION: 3.7, DIST: std, PYINT: python3.7, PYTHONPATH: src } virtualenv: - path: {{ospathjoin(root_path, pickname("$NAME_JENKINS", project_name + "_$VERSION_$DIST_$NAME"), "_venv")}} diff --git a/.local.jenkins.win.yml b/.local.jenkins.win.yml index 5f7fc48..c0ef1d3 100644 --- a/.local.jenkins.win.yml +++ b/.local.jenkins.win.yml @@ -1,6 +1,6 @@ language: python python: - - { PATH: "{{replace(Python37, '\\', '\\\\')}}", VERSION: 3.7, DIST: std } + - { PATH: "{{replace(Python37, '\\', '\\\\')}}", VERSION: 3.7, DIST: std, PYTHONPATH: src } virtualenv: - path: {{ospathjoin(root_path, pickname("%NAME_JENKINS%", project_name + "_%VERSION%_%DIST%_%NAME%"), "_venv")}} install: diff --git a/.travis.yml b/.travis.yml index 9d56430..b066a61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,6 @@ install: - pip install -r requirements.txt - pip install -U git+https://github.com/quantopian/qgrid --no-deps # - pip install hg+http://bitbucket.org/pygame/pygame + - export PYTHONPATH=src script: - python setup.py unittests diff --git a/_doc/sphinxdoc/source/conf.py b/_doc/sphinxdoc/source/conf.py index 1bde517..032f18d 100644 --- a/_doc/sphinxdoc/source/conf.py +++ b/_doc/sphinxdoc/source/conf.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import sys import os -import sphinx_modern_theme_modified +import sphinx_readable_theme from pyquickhelper.helpgen.default_conf import set_sphinx_variables, get_default_stylesheet sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0]))) @@ -9,7 +9,7 @@ os.path.dirname(__file__)), "phdoc_templates") set_sphinx_variables(__file__, "mathenjeu", "Xavier Dupré", 2019, - "sphinx_modern_theme_modified", sphinx_modern_theme_modified.get_html_theme_path(), + "readable", sphinx_readable_theme.get_html_theme_path(), locals(), extlinks=dict( issue=('https://github.com/sdpython/mathenjeu/issues/%s', 'issue')), title="Exercices via une application web", book=True, nblayout='table') diff --git a/_unittests/run_unittests.py b/_unittests/run_unittests.py deleted file mode 100644 index aee4423..0000000 --- a/_unittests/run_unittests.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -@file -@brief run all unit tests -""" - - -def main(): - """ - Runs the unit tests. - """ - from pyquickhelper.loghelper import fLOG - from pyquickhelper.pycode import main_wrapper_tests - fLOG(OutputPrint=True) - main_wrapper_tests(__file__) - - -if __name__ == "__main__": - main() diff --git a/_unittests/ut_activities/test_repr.py b/_unittests/ut_activities/test_repr.py index 1a26c58..3be6ed9 100644 --- a/_unittests/ut_activities/test_repr.py +++ b/_unittests/ut_activities/test_repr.py @@ -1,29 +1,10 @@ """ @brief test log(time=1s) """ - -import sys -import os import unittest from pyquickhelper.pycode import ExtTestCase - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - - -from src.mathenjeu.activities import Display -from src.mathenjeu.tests import simple_french_qcm +from mathenjeu.activities import Display +from mathenjeu.tests import simple_french_qcm class TestRepr(ExtTestCase): diff --git a/_unittests/ut_apps/test_qcm_app.py b/_unittests/ut_apps/test_qcm_app.py index d75ff87..50b0fb8 100644 --- a/_unittests/ut_apps/test_qcm_app.py +++ b/_unittests/ut_apps/test_qcm_app.py @@ -2,29 +2,11 @@ """ @brief test log(time=33s) """ - -import sys -import os import unittest from starlette.testclient import TestClient from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware from pyquickhelper.pycode import get_temp_folder, ExtTestCase - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.cli import create_qcm_local_app +from mathenjeu.cli import create_qcm_local_app class TestQcmApp(ExtTestCase): diff --git a/_unittests/ut_apps/test_static_app.py b/_unittests/ut_apps/test_static_app.py index 069eb65..9e8e28e 100644 --- a/_unittests/ut_apps/test_static_app.py +++ b/_unittests/ut_apps/test_static_app.py @@ -2,29 +2,12 @@ """ @brief test log(time=33s) """ - -import sys import os import unittest from starlette.testclient import TestClient from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware from pyquickhelper.pycode import get_temp_folder, ExtTestCase - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.cli import create_static_local_app +from mathenjeu.cli import create_static_local_app class TestStaticApp(ExtTestCase): diff --git a/_unittests/ut_cli/test_cert.py b/_unittests/ut_cli/test_cert.py index 3dfcef5..cc38d82 100644 --- a/_unittests/ut_cli/test_cert.py +++ b/_unittests/ut_cli/test_cert.py @@ -1,36 +1,15 @@ """ @brief test tree node (time=2s) """ - - -import sys import os import unittest from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.loghelper import BufferedPrint - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.__main__ import main +from mathenjeu.__main__ import main class TestCertCli(ExtTestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_cert(self): st = BufferedPrint() main(args=['create_self_signed_cert', '--help'], fLOG=st.fprint) diff --git a/_unittests/ut_cli/test_cli_helper.py b/_unittests/ut_cli/test_cli_helper.py index f3401c6..e071903 100644 --- a/_unittests/ut_cli/test_cli_helper.py +++ b/_unittests/ut_cli/test_cli_helper.py @@ -1,36 +1,14 @@ """ @brief test tree node (time=1s) """ - - -import sys -import os import unittest from pyquickhelper.pycode import ExtTestCase - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.activities import ActivityGroup -from src.mathenjeu.cli.cli_helper import build_games +from mathenjeu.activities import ActivityGroup +from mathenjeu.cli.cli_helper import build_games class TestCliHelper(ExtTestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_local_app(self): script = "src.mathenjeu.tests.qcms.py:simple_french_qcm,Maths et QCM,0" games, fct = build_games(script, None) diff --git a/_unittests/ut_cli/test_qcm_https_app.py b/_unittests/ut_cli/test_qcm_https_app.py index c6995e9..ddeeed1 100644 --- a/_unittests/ut_cli/test_qcm_https_app.py +++ b/_unittests/ut_cli/test_qcm_https_app.py @@ -1,34 +1,15 @@ """ @brief test tree node (time=2s) """ -import sys import os import unittest from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.loghelper import BufferedPrint - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.__main__ import main +from mathenjeu.__main__ import main class TestQcmHttpsAppCli(ExtTestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_https_webapp(self): st = BufferedPrint() main(args=['qcm_https', '--help'], fLOG=st.fprint) diff --git a/_unittests/ut_cli/test_qcm_local_app.py b/_unittests/ut_cli/test_qcm_local_app.py index db3edf2..d1995fb 100644 --- a/_unittests/ut_cli/test_qcm_local_app.py +++ b/_unittests/ut_cli/test_qcm_local_app.py @@ -1,35 +1,13 @@ """ @brief test tree node (time=2s) """ - - -import sys -import os import unittest from pyquickhelper.loghelper import BufferedPrint - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.__main__ import main +from mathenjeu.__main__ import main class TestQcmLocalAppCli(unittest.TestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_local_app(self): st = BufferedPrint() main(args=[], fLOG=st.fprint) diff --git a/_unittests/ut_cli/test_static_https_app.py b/_unittests/ut_cli/test_static_https_app.py index eb7ce54..b65a9be 100644 --- a/_unittests/ut_cli/test_static_https_app.py +++ b/_unittests/ut_cli/test_static_https_app.py @@ -1,34 +1,15 @@ """ @brief test tree node (time=2s) """ -import sys import os import unittest from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.loghelper import BufferedPrint - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.__main__ import main +from mathenjeu.__main__ import main class TestQcmHttpsAppCli(ExtTestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_https_webapp(self): st = BufferedPrint() main(args=['qcm_https', '--help'], fLOG=st.fprint) diff --git a/_unittests/ut_cli/test_static_local_app.py b/_unittests/ut_cli/test_static_local_app.py index 9c3d1d5..74a4235 100644 --- a/_unittests/ut_cli/test_static_local_app.py +++ b/_unittests/ut_cli/test_static_local_app.py @@ -1,35 +1,13 @@ """ @brief test tree node (time=2s) """ - - -import sys -import os import unittest from pyquickhelper.loghelper import BufferedPrint - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.__main__ import main +from mathenjeu.__main__ import main class TestStaticLocalAppCli(unittest.TestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_local_app(self): st = BufferedPrint() main(args=[], fLOG=st.fprint) diff --git a/_unittests/ut_datalog/test_datalog.py b/_unittests/ut_datalog/test_datalog.py index 88a91c2..e85154b 100644 --- a/_unittests/ut_datalog/test_datalog.py +++ b/_unittests/ut_datalog/test_datalog.py @@ -1,37 +1,16 @@ """ @brief test tree node (time=2s) """ - - -import sys import os import unittest import datetime import pandas from pyquickhelper.pycode import ExtTestCase - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu.datalog import enumerate_qcmlog, enumerate_qcmlogdf +from mathenjeu.datalog import enumerate_qcmlog, enumerate_qcmlogdf class TestLocalAppCli(ExtTestCase): - def test_src_import(self): - """for pylint""" - self.assertTrue(src is not None) - def test_datalog(self): this = os.path.abspath(os.path.dirname(__file__)) logs = [os.path.join(this, "data", "QCMApp.log")] diff --git a/_unittests/ut_documentation/test_run_notebooks.py b/_unittests/ut_documentation/test_run_notebooks.py index 62c86d9..6a87730 100644 --- a/_unittests/ut_documentation/test_run_notebooks.py +++ b/_unittests/ut_documentation/test_run_notebooks.py @@ -2,29 +2,12 @@ """ @brief test log(time=21s) """ - -import sys import os import unittest from pyquickhelper.loghelper import fLOG from pyquickhelper.ipythonhelper import test_notebook_execution_coverage import jyquickhelper - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -import src.mathenjeu +import mathenjeu class TestRunNotebooksPython(unittest.TestCase): @@ -39,7 +22,7 @@ def test_notebook_donnees_anonymisees(self): self._testMethodName, OutputPrint=__name__ == "__main__") - self.assertTrue(src.mathenjeu is not None) + self.assertTrue(mathenjeu is not None) folder = os.path.join(os.path.dirname(__file__), "..", "..", "_doc", "notebooks") test_notebook_execution_coverage(__file__, "donnees_anonymisees", folder, 'mathenjeu', @@ -51,7 +34,7 @@ def test_notebook_example_logs(self): self._testMethodName, OutputPrint=__name__ == "__main__") - self.assertTrue(src.mathenjeu is not None) + self.assertTrue(mathenjeu is not None) self.assertTrue(jyquickhelper is not None) folder = os.path.join(os.path.dirname(__file__), "..", "..", "_doc", "notebooks") diff --git a/_unittests/ut_module/test___init__.py b/_unittests/ut_module/test___init__.py index 6d0971d..f469596 100644 --- a/_unittests/ut_module/test___init__.py +++ b/_unittests/ut_module/test___init__.py @@ -1,28 +1,9 @@ """ @brief test log(time=0s) """ - -import sys -import os import unittest from pyquickhelper.loghelper import fLOG - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - - -from src.mathenjeu import check, _setup_hook +from mathenjeu import check, _setup_hook class TestInit(unittest.TestCase): diff --git a/_unittests/ut_module/test_code_style.py b/_unittests/ut_module/test_code_style.py index 33bc47f..87dfd87 100644 --- a/_unittests/ut_module/test_code_style.py +++ b/_unittests/ut_module/test_code_style.py @@ -10,20 +10,6 @@ from pyquickhelper.pycode import check_pep8 -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - - class TestCodeStyle(unittest.TestCase): def test_code_style_src(self): diff --git a/_unittests/ut_module/test_convert_notebooks.py b/_unittests/ut_module/test_convert_notebooks.py index 68fd4ce..09fe244 100644 --- a/_unittests/ut_module/test_convert_notebooks.py +++ b/_unittests/ut_module/test_convert_notebooks.py @@ -1,8 +1,6 @@ """ @brief test log(time=0s) """ - -import sys import os import unittest from pyquickhelper.loghelper import fLOG @@ -10,20 +8,6 @@ from pyquickhelper.ipythonhelper import upgrade_notebook, remove_execution_number -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - - class TestConvertNotebooks(unittest.TestCase): def test_convert_notebooks(self): diff --git a/_unittests/ut_module/test_readme.py b/_unittests/ut_module/test_readme.py index 5bb9404..c9d365b 100644 --- a/_unittests/ut_module/test_readme.py +++ b/_unittests/ut_module/test_readme.py @@ -1,26 +1,11 @@ """ @brief test tree node (time=50s) """ - -import sys import os import unittest from pyquickhelper.loghelper import fLOG from pyquickhelper.pycode import get_temp_folder -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - class TestReadme(unittest.TestCase): diff --git a/_unittests/ut_module/test_version.py b/_unittests/ut_module/test_version.py deleted file mode 100644 index 4dd01ec..0000000 --- a/_unittests/ut_module/test_version.py +++ /dev/null @@ -1,46 +0,0 @@ -""" -@brief test log(time=0s) -""" - -import sys -import os -import unittest -import re - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - -from src.mathenjeu import __version__ - - -class TestVersion (unittest.TestCase): - - def test_version(self): - setup = os.path.join( - os.path.split(__file__)[0], - "..", - "..", - "setup.py") - with open(setup, "r") as f: - c = f.read() - reg = re.compile("sversion *= \\\"(.*)\\\"") - - f = reg.findall(c) - if len(f) != 1: - raise Exception("not only one version") - assert f[0] == __version__ - - -if __name__ == "__main__": - unittest.main() diff --git a/_unittests/ut_tests/test_activity_group.py b/_unittests/ut_tests/test_activity_group.py index 2b390d8..b150b0f 100644 --- a/_unittests/ut_tests/test_activity_group.py +++ b/_unittests/ut_tests/test_activity_group.py @@ -1,28 +1,9 @@ """ @brief test log(time=1s) """ - -import sys -import os import unittest from pyquickhelper.pycode import ExtTestCase - - -try: - import src -except ImportError: - path = os.path.normpath( - os.path.abspath( - os.path.join( - os.path.split(__file__)[0], - "..", - ".."))) - if path not in sys.path: - sys.path.append(path) - import src - - -from src.mathenjeu.tests import simple_french_qcm, ml_french_qcm +from mathenjeu.tests import simple_french_qcm, ml_french_qcm class TestaTestsctivityGroup(ExtTestCase): diff --git a/appveyor.yml b/appveyor.yml index 347cc4e..1a9a704 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,7 @@ install: - "%PYTHON%\\Scripts\\pip install git+https://github.com/sdpython/nbconvert.git@fixes" - "%PYTHON%\\Scripts\\pymy_install3 --task=tool --source=zip graphviz" - "set PATH=%PATH%;C:\\projects\\mathenjeu\\build\\update_modules\\Graphviz\\bin" + - set PYTHONPATH=src build: off test_script: diff --git a/build_script.bat b/build_script.bat index 1ee9acb..7688939 100644 --- a/build_script.bat +++ b/build_script.bat @@ -5,12 +5,12 @@ set pythonexe="%1" goto custom_python: :default_value_python: -set pythonexe="c:\Python370_x64\python.exe" +set pythonexe="c:\Python372_x64\python.exe" +if not exist %pythonexe% set pythonexe="c:\Python370_x64\python.exe" if not exist %pythonexe% set pythonexe="c:\Python366_x64\python.exe" if not exist %pythonexe% set pythonexe="c:\Python365_x64\python.exe" if not exist %pythonexe% set pythonexe="c:\Python364_x64\python.exe" if not exist %pythonexe% set pythonexe="c:\Python363_x64\python.exe" -if not exist %pythonexe% set pythonexe="c:\Python36_x64\python.exe" :custom_python: @echo [python] %pythonexe% %pythonexe% -u setup.py build_script diff --git a/requirements.txt b/requirements.txt index 47b4820..9413f0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,8 @@ missingno pyopenssl pyquickhelper>=1.8.2924 python-multipart -sphinx_modern_theme_modified +sphinx +sphinx_readable_theme sphinxcontrib.blockdiag starlette>=0.11.0 ujson diff --git a/setup.py b/setup.py index 7d06bec..5460926 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ ######### project_var_name = "mathenjeu" -sversion = "0.1" versionPython = "%s.%s" % (sys.version_info.major, sys.version_info.minor) path = "Lib/site-packages/" + project_var_name readme = 'README.rst' @@ -153,6 +152,7 @@ def write_version(): from pyquickhelper.pycode import process_standard_options_for_setup_help process_standard_options_for_setup_help(sys.argv) from pyquickhelper.pycode import clean_readme + from mathenjeu import __version__ as sversion long_description = clean_readme(long_description) setup( diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/mathenjeu/__init__.py b/src/mathenjeu/__init__.py index 81dc79e..74df4d1 100644 --- a/src/mathenjeu/__init__.py +++ b/src/mathenjeu/__init__.py @@ -5,7 +5,7 @@ Building an web application with QCM. """ -__version__ = "0.1" +__version__ = "0.2" __author__ = "Xavier Dupré" __github__ = "https://github.com/sdpython/mathenjeu" __url__ = "http://www.xavierdupre.fr/app/mathenjeu/helpsphinx/index.html"