You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

  1. {% from 'common.jinja2' import app_dir, app_username, bin_dir, python_version, venv_dir %}
  2. deadsnakes:
  3. pkgrepo.managed:
  4. - ppa: deadsnakes/ppa
  5. pkg.installed:
  6. - name: python{{ python_version }}
  7. - refresh: True
  8. /opt/venvs:
  9. file.directory:
  10. - user: {{ app_username }}
  11. - group: {{ app_username }}
  12. - dir_mode: 755
  13. delete-obsolete-venv:
  14. file.absent:
  15. - name: {{ venv_dir }}
  16. - unless: {{ bin_dir }}/python --version | grep {{ python_version }}
  17. # Salt seems to use the deprecated pyvenv script, manual for now
  18. venv-setup:
  19. pkg.installed:
  20. - name: python{{ python_version }}-venv
  21. cmd.run:
  22. - name: python{{ python_version }} -m venv {{ venv_dir }}
  23. - creates: {{ venv_dir }}
  24. - runas: {{ app_username }}
  25. - require:
  26. - pkg: python{{ python_version }}-venv
  27. # Packages needed to be able to compile psycopg2 (while installing requirements.txt)
  28. psycopg2-deps:
  29. pkg.installed:
  30. - pkgs:
  31. - gcc
  32. - libpq-dev
  33. - python{{ python_version }}-dev
  34. pip-installs:
  35. pip.installed:
  36. {% if grains['id'] == 'dev' %}
  37. - requirements: {{ app_dir }}/requirements-dev.txt
  38. {% else %}
  39. - requirements: {{ app_dir }}/requirements.txt
  40. {% endif %}
  41. - user: {{ app_username }}
  42. - bin_env: {{ venv_dir }}
  43. require:
  44. - cmd: venv-setup
  45. - pkg: psycopg2-deps
  46. self-install:
  47. pip.installed:
  48. - bin_env: {{ venv_dir }}
  49. - editable:
  50. - {{ app_dir }}
  51. - require:
  52. - cmd: venv-setup
  53. - unless: ls {{ venv_dir }}/lib/python{{ python_version }}/site-packages/tildes.egg-link