<commit_before>#!/bin/bash
# ----------------------------------------------------------------------
#
# Installation of tools for better Python programming experience.
#
# ----------------------------------------------------------------------

echo_prefix_temp="$echo_prefix"
echo_prefix="[python tools setup] "

########################
####### Jupyter notebook
#######################
# Instructions from:
# http://bikulov.org/blog/2015/11/07/install-jupyter-notebook-and-scientific-environment-in-ubuntu-14-dot-04-with-python-3/

### Install prerequisites

# install curl virtualenvwrapper
apt_get_install_pkg curl
apt_get_install_pkg virtualenvwrapper

# install as workaround for https://github.com/matplotlib/matplotlib/issues/3029/
apt_get_install_pkg pkg-config

# install python development packages and g++
apt_get_install_pkg python-dev
apt_get_install_pkg python-pip
apt_get_install_pkg python3-dev
apt_get_install_pkg python3-pip
apt_get_install_pkg g++

# install dependencies for scipy
apt_get_install_pkg libblas-dev
apt_get_install_pkg liblapack-dev
apt_get_install_pkg gfortran

# install some dependencies for matplotlib
apt_get_install_pkg libfreetype6-dev
apt_get_install_pkg libpng-dev
apt_get_install_pkg libjpeg8-dev


### Now create and activate virtualenv, install all the packages via pip

# create and activate virtual environment using mkvirtualenv wrapper (env name is jupnb)
# if [ ! -d "${home}/.python_venv/jupnb" ]; then
#     runcmd "sudo -u ${normal_user} /usr/local/bin/virtualenv --no-setuptools --python /usr/bin/python3.4 ${home}/.python_venv/jupnb"
# fi
# runcmd ". ${home}/.python_venv/jupnb/bin/activate"

# install fresh pip
# runcmd "sudo -H python -m pip install --upgrade --force pip"
# runcmd "sudo -H pip install setuptools==33.1.1"
# runcmd "eval curl https://bootstrap.pypa.io/get-pip.py | python"

# install fresh setuptools
runcmd "sudo -u ${normal_user} pip install setuptools distribute"

# install numpy as it is dependecy for many others
runcmd "sudo -u ${normal_user} pip install numpy"

# install scientific packages (seaborn instead of matplotlib for pretty plots)
runcmd "sudo -u ${normal_user} pip install sympy scipy seaborn pandas jupyter"

# install scikit-learn separately, it depends on numpy and scipy
runcmd "sudo -u ${normal_user} pip install scikit-learn"

######## Setup virtualenvs
runcmd "sudo -u ${normal_user} mkdir -p ${home}/.python_venv"
runcmd "sudo -u ${normal_user} python -m pip install virtualenv --user"

# configure python2 kernel
runcmd "sudo -u ${normal_user} python -m virtualenv -p python2 ${home}/.python_venv/py2_kernel"
runcmd ". ${home}/.python_venv/py2_kernel/bin/activate"
runcmd "sudo -H python -m pip install ipykernel"
runcmd "ipython kernel install --name py2 --user"
runcmd "deactivate"<commit_msg>Jupyter installation changes<commit_after>#!/bin/bash
# ----------------------------------------------------------------------
#
# Installation of tools for better Python programming experience.
#
# ----------------------------------------------------------------------

echo_prefix_temp="$echo_prefix"
echo_prefix="[python tools setup] "

########################
####### Jupyter notebook
#######################
# Instructions from:
# http://bikulov.org/blog/2015/11/07/install-jupyter-notebook-and-scientific-environment-in-ubuntu-14-dot-04-with-python-3/

### Install prerequisites

# install curl virtualenvwrapper
apt_get_install_pkg curl
apt_get_install_pkg virtualenvwrapper

# install as workaround for https://github.com/matplotlib/matplotlib/issues/3029/
apt_get_install_pkg pkg-config

# install fresh pip
runcmd "sudo -H python -m pip install --upgrade --force pip"
runcmd "sudo -H pip install setuptools==33.1.1"
# runcmd "eval curl https://bootstrap.pypa.io/get-pip.py | python"

# install python development packages and g++
apt_get_install_pkg python-dev
apt_get_install_pkg python-pip
apt_get_install_pkg python3-dev
apt_get_install_pkg python3-pip
apt_get_install_pkg g++

# install dependencies for scipy
apt_get_install_pkg libblas-dev
apt_get_install_pkg liblapack-dev
apt_get_install_pkg gfortran

# install some dependencies for matplotlib
apt_get_install_pkg libfreetype6-dev
apt_get_install_pkg libpng-dev
apt_get_install_pkg libjpeg8-dev


### Now create and activate virtualenv, install all the packages via pip

# create and activate virtual environment using mkvirtualenv wrapper (env name is jupnb)
# if [ ! -d "${home}/.python_venv/jupnb" ]; then
#     runcmd "sudo -u ${normal_user} /usr/local/bin/virtualenv --no-setuptools --python /usr/bin/python3.4 ${home}/.python_venv/jupnb"
# fi
# runcmd ". ${home}/.python_venv/jupnb/bin/activate"

# install fresh setuptools
runcmd "sudo -H pip install setuptools distribute"

# install numpy as it is dependecy for many others
runcmd "sudo -H pip install numpy"

# install scientific packages (seaborn instead of matplotlib for pretty plots)
runcmd "sudo -H pip install sympy scipy seaborn pandas jupyter"

# install scikit-learn separately, it depends on numpy and scipy
runcmd "sudo -H pip install scikit-learn"

######## Setup virtualenvs
runcmd "sudo -u ${normal_user} mkdir -p ${home}/.python_venv"
runcmd "sudo -u ${normal_user} python -m pip install virtualenv --user"

# configure python2 kernel
runcmd "sudo -u ${normal_user} python -m virtualenv -p python2 ${home}/.python_venv/py2_kernel"
runcmd ". ${home}/.python_venv/py2_kernel/bin/activate"
runcmd "sudo -H python -m pip install ipykernel"
runcmd "ipython kernel install --name py2 --user"
runcmd "deactivate"
{'fraction_non_alphanumeric': 0.16435393764642278, 'fraction_numerical': 0.01153360965939809, 'mean_word_length': 3.8898678414096914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925063', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1725, 'n_words': 495}