diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 65971d323bb11cd7449be54f22898bedfa6e4b0d..a0bc61a4732248b754675c4ffa8c87a9ac6e15e9 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -70,6 +70,12 @@ Ready to contribute? Here's how to set up `flatland` for local development. $ cd flatland/ $ python setup.py develop + You can also use the virtual environment created by the getting_started scripts: + + getting_started/run_notebooks.bat + getting_started/run_notebooks.sh + + 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature diff --git a/README.rst b/README.rst index a626dcb8c865002eac2205a0f9525795af0f6b8d..4d0cb2abae20fa0cce46656ace5bb5cb9cbcf250 100644 --- a/README.rst +++ b/README.rst @@ -47,6 +47,15 @@ Online Docs The documentation for the latest code on the master branch is found at `http://flatland-rl-docs.s3-website.eu-central-1.amazonaws.com/ <http://flatland-rl-docs.s3-website.eu-central-1.amazonaws.com/>`_ +Run Notebooks with Examples with one Click +------------------------------------------ +Under getting_started, there are two scripts + + getting_started/run_notebooks.bat + getting_started/run_notebooks.sh + +They require git and Python>=3.6 installed with venv (python3-venv has to be installed under Linux). +They create a virtual environment, install Flatland and all dependencies into into and start they Jupyter notebooks in your browser. Generate Docs diff --git a/getting_started/run_notebooks.bat b/getting_started/run_notebooks.bat new file mode 100644 index 0000000000000000000000000000000000000000..afe41e08040c981deddcb1718e3876c2bb097708 --- /dev/null +++ b/getting_started/run_notebooks.bat @@ -0,0 +1,53 @@ +@echo on + +set PWD_BEFORE=%cd% + +@echo off +echo "************ TESTING PREREQUISITES PYTHON3 + GIT *************************" +@echo on + +git --version || goto :error +python3 --version || goto :error + + +@echo off +echo "************ SETUP VIRTUAL ENVIRONMENT FLATLAND *************************" +@echo on + +set FLATLAND_BASEDIR=%~dp0\.. +set WORKON_HOME=%FLATLAND_BASEDIR%\getting_started\envs_win +if not exist "%WORKON_HOME%" md "%WORKON_HOME%" || goto :error +cd "%WORKON_HOME%" +rem use venv instead of virtualenv/virtualenv-wrapper because of https://github.com/pypa/virtualenv/issues/355 +python3 -m venv flatland || goto :error +rem ignore activation error: https://stackoverflow.com/questions/51358202/python-3-7-activate-venv-error-parameter-format-not-correct-65001-windows +call "%WORKON_HOME%\flatland\Scripts\activate.bat" || true + + +@echo off +echo "************ INSTALL FLATLAND IN THE VIRTUALENV *************************" +@echo on +python -m pip install --upgrade pip || goto :error +cd %FLATLAND_BASEDIR% || goto :error +python setup.py install || goto :error +REM ensure jupyter is installed in the virtualenv +pip install -r "%FLATLAND_BASEDIR%/requirements_dev.txt" -r "%FLATLAND_BASEDIR%\requirements_continuous_integration.txt" || goto :error + +@echo off +echo "************ INSTALL JUPYTER EXTENSION *************************" +@echo on +jupyter nbextension install --py --sys-prefix widgetsnbextension || goto :error +jupyter nbextension enable --py --sys-prefix widgetsnbextension || goto :error +jupyter nbextension install --py --sys-prefix jpy_canvas || goto :error +jupyter nbextension enable --py --sys-prefix jpy_canvas || goto :error +jupyter notebook || goto :error + + +goto :EOF + + +:error +echo Failed with error #%errorlevel%. +cd "%PWD_BEFORE%" || true +deactivate || true +pause diff --git a/getting_started/run_notebooks.sh b/getting_started/run_notebooks.sh new file mode 100644 index 0000000000000000000000000000000000000000..70654ae50fa2e51c7b19df1e71e07408d3c4e7ce --- /dev/null +++ b/getting_started/run_notebooks.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e # stop on error +set -x # echo commands + + +# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself +FLATLAND_BASEDIR=$(dirname "$0")/.. +FLATLAND_BASEDIR=$(realpath "$FLATLAND_BASEDIR") +echo "BASEDIR=${FLATLAND_BASEDIR}" + +set +x +echo "************ TESTING PREREQUISITES PYTHON3 + GIT *************************" +set -x + + +set +x +echo "************ SETUP VIRTUAL ENVIRONMENT FLATLAND *************************" +set -x + +export WORKON_HOME=${FLATLAND_BASEDIR}/getting_started/envs +echo WORKON_HOME=$WORKON_HOME +echo PWD=$PWD +mkdir -p ${WORKON_HOME} +# cannot work with virtualenvwrapper in script +cd ${WORKON_HOME} +python3 -m venv flatland +source flatland/bin/activate + +set +x +echo "************ INSTALL FLATLAND IN THE VIRTUALENV *************************" +set -x +cd ${FLATLAND_BASEDIR} +python setup.py install +# ensure jupyter is installed in the virtualenv +pip install -r ${FLATLAND_BASEDIR}/requirements_dev.txt -r requirements_continuous_integration.txt + +set +x +echo "************ INSTALL JUPYTER EXTENSION *************************" +set -x +jupyter nbextension install --py --sys-prefix widgetsnbextension +jupyter nbextension enable --py --sys-prefix widgetsnbextension +jupyter nbextension install --py --sys-prefix jpy_canvas +jupyter nbextension enable --py --sys-prefix jpy_canvas +jupyter notebook diff --git a/setup.py b/setup.py index eaabda402f9d802a496042f237abefc08a14fbab..7e9a8b04f00424ebe4c8fcb9671b8d2328e51bb1 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ import sys from setuptools import setup, find_packages +assert sys.version_info >= (3, 6) with open('README.rst') as readme_file: readme = readme_file.read()