---
- name: Set virtualenv path
  ansible.builtin.set_fact:
    virtualenv_path: "{{ build_dir }}/venv-{{ py_ver }}"

- name: Create virtualenv directory
  ansible.builtin.file:
    path: "{{ virtualenv_path }}"
    state: directory
    owner: buildslave
    group: buildslave
    mode: 0755

- name: Create Python {{ py_ver }} virtualenv
  become: true
  become_user: "buildslave"
  become_method: su
  ansible.builtin.pip:
    virtualenv: "{{ virtualenv_path }}"
    virtualenv_command: "/opt/python/{{ py_ver }}/bin/python3 -mvenv"
    extra_args: "--extra-index-url {{ pip_extra_index_url }} -c '{{ wheels_dir }}/upper-constraints.txt'"
    name:
      - pip
      - pkgconfig
      - Cython
      - wheel
