/elasticluster/share/playbooks/roles/jupyter/tasks/matlab.yml

https://github.com/elasticluster/elasticluster · YAML · 47 lines · 27 code · 10 blank · 10 comment · 0 complexity · df352b8fb28fdbf8ccce50441569d133 MD5 · raw file

  1. ---
  2. # The following code is an attempt at getting MathWorks' official "MATLAB Engine
  3. # API for Python" to work, instead of the `pymatbridge` Python package (which is
  4. # still labeled as status "3 - Alpha" on PyPI).
  5. #
  6. # Unfortunately, as of MATLAB 2016a, the MATLAB Engine API only supports Python
  7. # 2.7, 3.3, and 3.4. Since the provided Python module is a *binary* one
  8. # (`libmatlabforpython3_4.so`), we cannot play any diff/patch/symlink tricks.
  9. #
  10. # So here you go, code that only works for Python 2 and little chances of
  11. # ever working with the *current* Python 3.
  12. - name: Is the MATLAB Engine API for Python already installed?
  13. command: |
  14. {{PYTHON2_EXE}} -c "import matlab"
  15. ignore_errors: yes
  16. register: matlab_for_python_available
  17. - name: Find MATLAB root directory
  18. shell: |
  19. {{MATLAB_EXE}} -nojvm -nodesktop -nodisplay -nosplash -r "dir = matlabroot; fprintf('MATLABROOT=%s\n', dir); exit" | grep "^MATLABROOT=" | cut -d= -f2
  20. register: matlabroot
  21. when: (matlab_for_python_available is failed)
  22. - name: Install MATLAB engine for Python
  23. command: |
  24. {{PYTHON2_EXE}} setup.py install
  25. args:
  26. chdir: '{{matlabroot.stdout}}/extern/engines/python/'
  27. when: (matlab_for_python_available is failed)
  28. - name: Install Jupyter/IPython kernel for MATLAB (module)
  29. pip:
  30. name: '{{item}}'
  31. state: '{{ pkg_install_state }}'
  32. executable: '{{PYTHON2_EXE|dirname}}/pip'
  33. loop:
  34. - matlab_kernel
  35. - name: Install Jupyter/IPython kernel for MATLAB (kernel spec)
  36. command:
  37. 'env PATH={{PYTHON2_EXE|dirname}}:$PATH {{PYTHON2_EXE}} -m matlab_kernel install'