diff --git a/.gitignore b/.gitignore index 5428fe68df32a7e1e0eb314e76fa929dfc6acccb..f0193121d077fce776b6d6c844773e41123b4575 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ git-roots .mypy_cache /.idea +/.env diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29e740fd03f4eb77f2008cec76d249799bf59cce..eb9f20524cce9a4df4adabe7597ae4012a7ef94a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,15 @@ Python 3.6: variables: CODECOV_TOKEN: "895e3bf2-cfd0-45f8-9a14-4b7bd148f76d" +Python 3.6: + script: + - "PY_EXE=python3.6 bash ./test-command-line-tool.sh" + tags: + - python3.6 + - linux + except: + - tags + Documentation: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-docs.sh diff --git a/.travis.yml b/.travis.yml index 4704d87660e97f21e15cc072c99bd8470888a00e..0046093f0a176f7fe8fefdfcee1b940f95c929b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,12 +16,14 @@ install: true matrix: include: - python: "2.7" - env: PY=true PY_EXE=python2.7 + env: RL_TRAVIS_TEST=test PY_EXE=python2.7 - python: "3.5" - env: PY=true PY_EXE=python3.5 + env: RL_TRAVIS_TEST=test PY_EXE=python3.5 + - python: "3.6" + env: RL_TRAVIS_TEST=cmdline PY_EXE=python3.5 - python: "3.5" - env: Flake8=true PY_EXE=python3.5 + env: RL_TRAVIS_TEST=flake8 PY_EXE=python3.5 - python: "3.6" - env: Mypy=true PY_EXE=python3.6 + env: RL_TRAVIS_TEST=mypy PY_EXE=python3.6 script: - bash ./run-travis-ci.sh diff --git a/bin/relate b/bin/relate index 7d78b445af1113133574302426885e943329db1f..51e3757d994bd326bb98c4d6581f6b4d1eb0fe91 100644 --- a/bin/relate +++ b/bin/relate @@ -214,6 +214,9 @@ def main(): pass import os import argparse + + os.environ["RELATE_COMMAND_LINE"] = "1" + parser = argparse.ArgumentParser( description='RELATE course content command line tool') subp = parser.add_subparsers() diff --git a/course/utils.py b/course/utils.py index 1e4b5b6ab8cbb6a6f5cb8e51f87e1e6d378ce580..b364556f38537d38a04439e5ec3e184d15d89cf3 100644 --- a/course/utils.py +++ b/course/utils.py @@ -37,8 +37,6 @@ from django.utils import translation from django.utils.translation import ( ugettext as _, pgettext_lazy) -from codemirror import CodeMirrorTextarea, CodeMirrorJavascript - from relate.utils import string_concat from course.content import ( get_course_repo, get_flow_desc, @@ -70,6 +68,8 @@ if False: FlowPageData, ) from course.content import Repo_ish # noqa + from codemirror import CodeMirrorTextarea # noqa + # }}} @@ -938,6 +938,9 @@ def get_codemirror_widget( read_only=False, # type: bool ): # type: (...) -> CodeMirrorTextarea + + from codemirror import CodeMirrorTextarea, CodeMirrorJavascript + theme = "default" if read_only: theme += " relate-readonly" @@ -1304,8 +1307,10 @@ class IpynbJinjaMacro(RelateJinjaMacroBase): from django.conf import settings # Place the template in course template dir + import course template_path = os.path.join( - settings.BASE_DIR, "course", "templates", "course", "jinja2") + os.path.dirname(course.__file__), + "templates", "course", "jinja2") c.TemplateExporter.template_path.append(template_path) from nbconvert import HTMLExporter diff --git a/relate/__init__.py b/relate/__init__.py index d13e951393e4daf65324993963f8f2e73706eaed..5983599dd06e157bd27ff9d8c6e6f6bda87088ee 100644 --- a/relate/__init__.py +++ b/relate/__init__.py @@ -1,5 +1,7 @@ from __future__ import absolute_import +import os -# This will make sure the app is always imported when -# Django starts so that shared_task will use this app. -from .celery import app as celery_app # noqa +if "RELATE_COMMAND_LINE" not in os.environ: + # This will make sure the app is always imported when + # Django starts so that shared_task will use this app. + from .celery import app as celery_app # noqa diff --git a/run-travis-ci.sh b/run-travis-ci.sh index 9ae669a0321782448eeb6ebce6d58c6c0c181bf6..a4977e0ed21db282dacbf745728d1d9179ed4815 100644 --- a/run-travis-ci.sh +++ b/run-travis-ci.sh @@ -1,19 +1,21 @@ #! /bin/bash # before_script -if [[ $Flake8 == true ]]; then +if [[ $RL_TRAVIS_TEST == test ]]; then curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh fi -if [[ $Mypy == true ]]; then +if [[ $RL_TRAVIS_TEST == mypy ]]; then curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-mypy.sh fi # run ci according to env variables -if [[ $PY == true ]]; then +if [[ $RL_TRAVIS_TEST == test ]]; then . ./run-tests-for-ci.sh -elif [[ $Mypy == true ]]; then +if [[ $RL_TRAVIS_TEST == cmdline ]]; then + . ./test-command-line-tool.sh +elif [[ $RL_TRAVIS_TEST == mypy ]]; then . ./prepare-and-run-mypy.sh python3.6 mypy==0.560 -elif [[ $Flake8 == true ]]; then +elif [[ $RL_TRAVIS_TEST == flake8 ]]; then . ./prepare-and-run-flake8.sh relate course accounts tests bin fi diff --git a/setup.py b/setup.py index baf85018accbdf6cfc1cf30053b2713419f44c5a..ba311032c702707a24900772525de6a69c796b82 100644 --- a/setup.py +++ b/setup.py @@ -21,5 +21,12 @@ setup(name="relate-courseware", license="MIT", packages=find_packages(exclude=['tests']), install_requires=[ + "django>=1.10,<1.12", + "django-crispy-forms>=1.5.1", "colorama", + "markdown", + "dulwich", + "pyyaml", + "lxml", + "nbconvert>=5.2.1", ]) diff --git a/test-command-line-tool.sh b/test-command-line-tool.sh new file mode 100644 index 0000000000000000000000000000000000000000..93ff339a7f1cd01fb0be7fd157e87f43a0690745 --- /dev/null +++ b/test-command-line-tool.sh @@ -0,0 +1,51 @@ +#! /bin/bash + +set -e +set -x + +PY_EXE="$1" + +if test "$PY_EXE" = ""; then + PY_EXE="python3.6" +fi +shift + +echo "-----------------------------------------------" +echo "Current directory: $(pwd)" +echo "Python executable: ${PY_EXE}" +echo "-----------------------------------------------" + +# {{{ clean up + +rm -Rf .env +rm -Rf build +find . -name '*.pyc' -delete + +rm -Rf env +git clean -fdx -e siteconf.py -e boost-numeric-bindings -e local_settings.py + +if test `find "siteconf.py" -mmin +1`; then + echo "siteconf.py older than a minute, assumed stale, deleted" + rm -f siteconf.py +fi + +# }}} + +# {{{ virtualenv + +${PY_EXE} -m venv .env +. .env/bin/activate + +${PY_EXE} -m ensurepip + +# }}} + +$PY_EXE -m pip install . + +git clone https://github.com/inducer/relate-sample +cd relate-sample + +relate validate . +relate test-code questions/autograded-python-example.yml +relate expand-yaml flows/quiz-test.yml > /dev/null +