From 822e31391ec6b86c21311cd234c9d0887b9ffd76 Mon Sep 17 00:00:00 2001 From: u214892 <u214892@sbb.ch> Date: Mon, 8 Jul 2019 11:47:50 +0200 Subject: [PATCH] 78 getting_started.bat with conda; removed pycairo from setup.py --- .gitattributes | 12 +++++ getting_started/getting_started.bat | 52 ++++++++++++++++++ .../{run_notebooks.sh => gettings_started.sh} | 0 getting_started/run_notebooks.bat | 53 ------------------- requirements_continuous_integration.txt | 3 +- requirements_dev.txt | 1 - setup.py | 46 ---------------- 7 files changed, 66 insertions(+), 101 deletions(-) create mode 100644 .gitattributes create mode 100644 getting_started/getting_started.bat rename getting_started/{run_notebooks.sh => gettings_started.sh} (100%) mode change 100755 => 100644 delete mode 100644 getting_started/run_notebooks.bat diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..333aa39 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# auto detect text files and perform LF normalization +* text=auto + +# shell scripts will always have LF only (even in Windows environment) +*.sh text eol=lf + +# perl scripts will always have LF only (even in Windows environment) +*.pl text eol=lf + +# denote all files that are truly binary and should not be modified +*.png binary +*.jpg binary diff --git a/getting_started/getting_started.bat b/getting_started/getting_started.bat new file mode 100644 index 0000000..03dfcc4 --- /dev/null +++ b/getting_started/getting_started.bat @@ -0,0 +1,52 @@ +@echo on + +set FLATLAND_BASEDIR=%~dp0\.. + +@echo off +echo "************ TESTING PREREQUISITES PYTHON3 + GIT + GIT *************************" +@echo on + +git --version || goto :error +python --version || goto :error +rem deactivae in case we're in virtualenv +call deactivate +conda --version || goto :error + + +@echo off +echo "************ SETUP VIRTUAL ENVIRONMENT FLATLAND *************************" +@echo on +(conda info --envs | findstr flatland-rl) || conda create python=3.6 -y --name flatland-rl || goto :error +call activate flatland-rl || goto :error + + +@echo off +echo "************ INSTALL FLATLAND AND DEPENDENCIES IN THE VIRTUALENV *************************" +@echo on +rem TODO we should get rid of having to install these packages outside of setup.py with conda! +call conda install -y -c conda-forge cairosvg pycairo || goto :error +call conda install -y -c anaconda tk || goto :error +call python -m pip install --upgrade pip || goto :error +python setup.py install || goto :error + +# ensure jupyter is installed in the virtualenv + +python -m pip install --upgrade -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%. +pause diff --git a/getting_started/run_notebooks.sh b/getting_started/gettings_started.sh old mode 100755 new mode 100644 similarity index 100% rename from getting_started/run_notebooks.sh rename to getting_started/gettings_started.sh diff --git a/getting_started/run_notebooks.bat b/getting_started/run_notebooks.bat deleted file mode 100644 index afe41e0..0000000 --- a/getting_started/run_notebooks.bat +++ /dev/null @@ -1,53 +0,0 @@ -@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/requirements_continuous_integration.txt b/requirements_continuous_integration.txt index fa2b57b..9475e28 100644 --- a/requirements_continuous_integration.txt +++ b/requirements_continuous_integration.txt @@ -11,6 +11,7 @@ flake8-eradicate==0.2.0 twine==1.12.1 pydeps==1.7.2 jupyter==1.0.0 +jupyter-core>=4.5.0 +notebook>=5.7.8 pytest-xvfb==1.2.0 git+https://github.com/who8mylunch/Jupyter_Canvas_Widget.git@bd151ae1509c50b5809944dd3294f58b7b069c86 - diff --git a/requirements_dev.txt b/requirements_dev.txt index 002be2a..7858de7 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,7 +8,6 @@ recordtype==1.3 xarray==0.11.3 matplotlib==3.0.2 Pillow==5.4.1 -# pycairo==1.18.1 is installed via setup.py since it needs special treatment under Windows CairoSVG==2.3.1 msgpack==0.6.1 svgutils==0.3.1 diff --git a/setup.py b/setup.py index 3cc28b3..ba9f0c5 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ """The setup script.""" import os -import platform import sys from setuptools import setup, find_packages @@ -12,51 +11,6 @@ assert sys.version_info >= (3, 6) with open('README.rst') as readme_file: readme = readme_file.read() -# install pycairo on Windows -if os.name == 'nt': - p = platform.architecture() - is64bit = p[0] == '64bit' - if sys.version[0:3] == '3.5': - if is64bit: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp35-cp35m-win_amd64.whl' - else: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp35-cp35m-win32.whl' - - if sys.version[0:3] == '3.6': - if is64bit: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp36-cp36m-win_amd64.whl' - else: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp36-cp36m-win32.whl' - - if sys.version[0:3] == '3.7': - if is64bit: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp37-cp37m-win_amd64.whl' - else: - url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp37-cp37m-win32.whl' - - try: - import pycairo - except: - call_cmd = "pip install " + url - os.system(call_cmd) - - import site - import ctypes.util - - default_os_path = os.environ['PATH'] - os.environ['PATH'] = '' - for s in site.getsitepackages(): - os.environ['PATH'] = os.environ['PATH'] + ';' + s + '\\cairo' - os.environ['PATH'] = os.environ['PATH'] + ';' + default_os_path - print(os.environ['PATH']) - if ctypes.util.find_library('cairo') is not None: - print("cairo installed: OK") -else: - try: - import pycairo - except: - os.system("pip install pycairo==1.18.1") - def get_all_svg_files(directory='./svg/'): ret = [] -- GitLab