MycroftAI / mycroft-core

Mycroft Core, the Mycroft Artificial Intelligence platform.
https://mycroft.ai
Apache License 2.0
6.51k stars 1.27k forks source link

Virtual environment dev_setup with python argument #3041

Closed HFabi closed 2 years ago

HFabi commented 2 years ago

Is your feature request related to a problem? Please describe. It is possible to provide a python version as an argument to the dev_setup.sh script. I suggest that the provided version should also be used to install the correct pip. This would make it easier to install mycroft on systems such as respeaker core 2.

Describe the solution you'd like A clear and concise description of what you want to happen. I would suggest the following change:

# dev_setup.sh
function install_venv() {
    $opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip
    curl https://bootstrap.pypa.io/get-pip.py | "${VIRTUALENV_ROOT}/bin/python" - 'pip==20.0.2'
    [[ -x ${VIRTUALENV_ROOT}/bin/pip ]]
}

# dev_setup.sh changes:
function install_venv() {
    $opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip
    # replace "python" with "$opt_python"
    curl https://bootstrap.pypa.io/get-pip.py | "${VIRTUALENV_ROOT}/bin/${opt_python}" - 'pip==20.0.2'.  # <-----
    [[ -x ${VIRTUALENV_ROOT}/bin/pip ]]
}

Describe alternatives you've considered

Additional context

I am going to create a Pull Request with these change, if others consider it reasonable But first want to discuss about it here.

forslund commented 2 years ago

I think that sounds like a great update. Seems like the current state could cause weird errors.

Tony763 commented 2 years ago

Hi @krisgesling , this change breaks my workflow in skill-homeassistant as I used `${opt_python}' to supply python from custom location to it:

- name: Github Actions - Get path to python
        run: echo "PATH_TO_PYTHON=$(which python)" >> $GITHUB_ENV
        # /opt/hostedtoolcache/Python/3.7.12/x64/bin/python

- name: Mycroft - install Mycroft
        run: |
          sudo apt update
          git clone https://github.com/MycroftAI/mycroft-core.git /opt/mycroft-core
          ls /opt
          chmod +x /opt/mycroft-core/dev_setup.sh
          /opt/mycroft-core/dev_setup.sh --allow-root -ci -sm -p ${{ env.PATH_TO_PYTHON }}
...

Any though how to supply it now?

Also "${VIRTUALENV_ROOT}/bin/python" is symlink and point to supplied $opt_python which created virtual environment. So I do not see a meaning of this change (correct me if I am wrong :slightly_smiling_face: )

image As .venv/bin/ is in Path, python point to python3 which is symlink to actually used binary.

Nevermind, found a way to supply it. :smile: