This is an automated email from the ASF dual-hosted git repository. mykolabodnar pushed a commit to branch DATALAB-2398 in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit b64143d162b8a5776934fa4d43173b316d490f71 Author: bodnarmykola <[email protected]> AuthorDate: Thu May 20 11:51:38 2021 +0300 [DATALAB-2398] - Python installation in virtualenv added --- .../src/general/lib/os/fab.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py index 3185b65..a9daee1 100644 --- a/infrastructure-provisioning/src/general/lib/os/fab.py +++ b/infrastructure-provisioning/src/general/lib/os/fab.py @@ -38,6 +38,31 @@ from fabric import * from patchwork.files import exists from patchwork import files +def ensure_python_venv(python_version): + try: + if not exist(conn, '/opt/python/python{}'.format(python_version)): + conn.sudo('wget https://www.python.org/ftp/python/{0}/Python-{0}.tgz -O /tmp/Python-{0}.tgz'.format(python_version)) + conn.sudo('tar zxvf /tmp/Python-{}.tgz -C /tmp/'.format(python_version)) + conn.sudo('cd /tmp/Python-{0} && ./configure --prefix=/opt/python/python{0} --with-zlib-dir=/usr/local/lib/ --with-ensurepip=install'.format( + python_version) + conn.sudo('cd /tmp/Python-{0} make altinstall'.format(python_version)) + conn.sudo('cd /tmp && rm -rf Python-{}'.format(python_version)) + conn.sudo('virtualenv /opt/python/python{}'.format(python_version)) + venv_command = 'source /opt/python/python{}/bin/activate'.format(python_version) + pip_command = '/opt/python/python{0}/bin/pip{1}'.format(python_version, python_version[:3]) + conn.sudo('{0} && install -U pip=={}'.format(venv_command, pip_command, os.environ['pip_version'])) + subprocess.run({0} && {1} install pyzmq==17.0.0'.format(venv_command, pip_command)) + subprocess.run( + '{0} && sudo -i {1} install ipython ipykernel --no-cache-dir'.format(venv_command, pip_command), + shell=True, check=True) + subprocess.run( + '{0} && sudo -i {1} install boto boto3 NumPy=={2} SciPy Matplotlib pandas Sympy Pillow sklearn --no-cache-dir' + .format(venv_command, pip_command, numpy_version), shell=True, check=True) + + except Exception as err: + print('Error:', str(err)) + sys.exit(1) + def ensure_pip(requisites): try: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
