From 5ded997f54ad47ee3789a9d322fb3abb76e12ba7 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 27 May 2019 22:00:11 -0500 Subject: [PATCH 1/4] First attempt at enabling CI --- .gitlab-ci.yml | 14 +++++++++ build-py-project.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 12 ++++++++ 3 files changed, 98 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 build-py-project.sh create mode 100644 requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6371035 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +Python 3 POCL: + script: + - export PY_EXE=python3 + - export PYOPENCL_TEST=portable + - export EXTRA_INSTALL="pybind11 numpy mako" + - ". ./build-and-test-py-project.sh" + tags: + - python3 + - pocl + except: + - tags + artifacts: + reports: + junit: pytest.xml diff --git a/build-py-project.sh b/build-py-project.sh new file mode 100644 index 0000000..69b5b8e --- /dev/null +++ b/build-py-project.sh @@ -0,0 +1,72 @@ +echo "-----------------------------------------------" +echo "Current directory: $(pwd)" +echo "Python executable: ${PY_EXE}" +echo "PYOPENCL_TEST: ${PYOPENCL_TEST}" +echo "PYTEST_ADDOPTS: ${PYTEST_ADDOPTS}" +echo "PROJECT_INSTALL_FLAGS: ${PROJECT_INSTALL_FLAGS}" +echo "git revision: $(git rev-parse --short HEAD)" +echo "git status:" +git status -s +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 '.pylintrc.yml' \ + -e 'prepare-and-run-*.sh' \ + -e 'run-*.py' \ + $GIT_CLEAN_EXCLUDE + +# }}} + +if [[ "$NO_SUBMODULES" = "" ]]; then + git submodule update --init --recursive +fi + +# {{{ virtualenv + +VIRTUALENV="${PY_EXE} -m venv" + +if [ -d ".env" ]; then + echo "**> virtualenv exists" +else + echo "**> creating virtualenv" + ${VIRTUALENV} .env +fi + +. .env/bin/activate + +# }}} + +$PY_EXE -m ensurepip + +PIP="${PY_EXE} $(which pip)" + +# https://github.com/pypa/pip/issues/5345#issuecomment-386443351 +export XDG_CACHE_HOME=$HOME/.cache/$CI_RUNNER_ID + +$PIP install --upgrade pip +$PIP install setuptools + +# Pinned to 3.0.4 because of https://github.com/pytest-dev/pytest/issues/2434 +# Install before a newer version gets pulled in as a dependency +$PIP install pytest==3.0.4 pytest-warnings==0.2.0 + +if test "$REQUIREMENTS_TXT" == ""; then + REQUIREMENTS_TXT="requirements.txt" +fi + +if test -f $REQUIREMENTS_TXT; then + $PIP install -r $REQUIREMENTS_TXT +fi + +${PY_EXE} -m pytest -rw --durations=10 --tb=native --junitxml=pytest.xml -rxsw test.py + +# vim: foldmethod=marker diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cd9b67c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +git+https://github.com/inducer/pytools.git +git+https://github.com/inducer/islpy.git +git+https://github.com/inducer/cgen.git +git+https://github.com/inducer/pyopencl.git +git+https://github.com/inducer/pymbolic.git +git+https://github.com/inducer/genpy.git +git+https://github.com/inducer/codepy.git + +git+https://github.com/inducer/f2py + +# Optional, needed for using the C preprocessor on Fortran +ply>=3.6 -- GitLab From caa229d27c05f7f3293ec0cd08a944abdb2e661b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 28 May 2019 05:02:00 +0200 Subject: [PATCH 2/4] Rename build script --- build-py-project.sh => build-and-test-py-project.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build-py-project.sh => build-and-test-py-project.sh (100%) diff --git a/build-py-project.sh b/build-and-test-py-project.sh similarity index 100% rename from build-py-project.sh rename to build-and-test-py-project.sh -- GitLab From cc2317de601e8727e9f5e20dc2c5054ec7ef8e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 28 May 2019 05:04:15 +0200 Subject: [PATCH 3/4] Handle $EXTRA_INSTALL in CI script --- build-and-test-py-project.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/build-and-test-py-project.sh b/build-and-test-py-project.sh index 69b5b8e..0810a38 100644 --- a/build-and-test-py-project.sh +++ b/build-and-test-py-project.sh @@ -59,6 +59,26 @@ $PIP install setuptools # Install before a newer version gets pulled in as a dependency $PIP install pytest==3.0.4 pytest-warnings==0.2.0 +if test "$EXTRA_INSTALL" != ""; then + for i in $EXTRA_INSTALL ; do + if [ "$i" = "numpy" ] && [[ "${PY_EXE}" == pypy* ]]; then + $PIP install git+https://bitbucket.org/pypy/numpy.git + elif [[ "$i" = *pybind11* ]] && [[ "${PY_EXE}" == pypy* ]]; then + # Work around https://github.com/pypa/virtualenv/issues/1198 + # Running virtualenv --always-copy or -m venv --copies should also do the trick. + L=$(readlink .env/include) + rm .env/include + cp -R $L .env/include + + $PIP install $i + elif [ "$i" = "numpy" ] && [[ "${PY_EXE}" == python2.6* ]]; then + $PIP install 'numpy==1.10.4' + else + $PIP install $i + fi + done +fi + if test "$REQUIREMENTS_TXT" == ""; then REQUIREMENTS_TXT="requirements.txt" fi -- GitLab From 43b4ed914d9df631ec497bbf5183ab917d646784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 28 May 2019 05:05:39 +0200 Subject: [PATCH 4/4] Add loopy to requirements.txt for CI --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index cd9b67c..36d95d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ git+https://github.com/inducer/pyopencl.git git+https://github.com/inducer/pymbolic.git git+https://github.com/inducer/genpy.git git+https://github.com/inducer/codepy.git +git+https://gitlab.tiker.net/inducer/loopy.git@kernel_callables_v3 git+https://github.com/inducer/f2py -- GitLab