mirror of
https://github.com/YunoHost-Apps/pepettes_ynh.git
synced 2024-09-03 19:56:35 +02:00
Update ynh_install_python
This commit is contained in:
parent
269739dbe1
commit
1f0009d2a7
1 changed files with 18 additions and 17 deletions
|
@ -37,18 +37,18 @@ SOURCE_SUM=27ae3de027a6f6dccdca4085225512e559c6b94b31625bd2b357a18890a1e618" > "
|
|||
(cd $pyenv_install_dir
|
||||
./src/configure && make -C src)
|
||||
|
||||
# Create shims directory if needed
|
||||
if [ ! -d $pyenv_install_dir/shims ] ; then
|
||||
mkdir $pyenv_install_dir/shims
|
||||
fi
|
||||
# Create shims directory if needed
|
||||
if [ ! -d $pyenv_install_dir/shims ] ; then
|
||||
mkdir $pyenv_install_dir/shims
|
||||
fi
|
||||
}
|
||||
|
||||
# Load the version of python for an app, and set variables.
|
||||
# Load the version of Python for an app, and set variables.
|
||||
#
|
||||
# ynh_use_python has to be used in any app scripts before using python for the first time.
|
||||
# ynh_use_python has to be used in any app scripts before using Python for the first time.
|
||||
# This helper will provide alias and variables to use in your scripts.
|
||||
#
|
||||
# To use pip or python, use the alias `ynh_pip` and `ynh_python`
|
||||
# To use pip or Python, use the alias `ynh_pip` and `ynh_python`
|
||||
# Those alias will use the correct version installed for the app
|
||||
# For example: use `ynh_pip install` instead of `pip install`
|
||||
#
|
||||
|
@ -56,46 +56,47 @@ fi
|
|||
# And propagate $PATH to sudo with $ynh_python_load_path
|
||||
# Exemple: `ynh_exec_as $app $ynh_python_load_path $ynh_pip install`
|
||||
#
|
||||
# $PATH contains the path of the requested version of python.
|
||||
# $PATH contains the path of the requested version of Python.
|
||||
# However, $PATH is duplicated into $python_path to outlast any manipulation of $PATH
|
||||
# You can use the variable `$ynh_python_load_path` to quickly load your python version
|
||||
# You can use the variable `$ynh_python_load_path` to quickly load your Python version
|
||||
# in $PATH for an usage into a separate script.
|
||||
# Exemple: $ynh_python_load_path $final_path/script_that_use_pip.sh`
|
||||
#
|
||||
#
|
||||
# Finally, to start a python service with the correct version, 2 solutions
|
||||
# Either the app is dependent of python or pip, but does not called it directly.
|
||||
# Finally, to start a Python service with the correct version, 2 solutions
|
||||
# Either the app is dependent of Python or pip, but does not called it directly.
|
||||
# In such situation, you need to load PATH
|
||||
# `Environment="__YNH_PYTHON_LOAD_ENV_PATH__"`
|
||||
# `ExecStart=__FINALPATH__/my_app`
|
||||
# You will replace __YNH_PYTHON_LOAD_ENV_PATH__ with $ynh_python_load_path
|
||||
#
|
||||
# Or python start the app directly, then you don't need to load the PATH variable
|
||||
# Or Python start the app directly, then you don't need to load the PATH variable
|
||||
# `ExecStart=__YNH_PYTHON__ my_app run`
|
||||
# You will replace __YNH_PYTHON__ with $ynh_python
|
||||
#
|
||||
#
|
||||
# one other variable is also available
|
||||
# - $python_path: The absolute path to python binaries for the chosen version.
|
||||
# - $python_path: The absolute path to Python binaries for the chosen version.
|
||||
#
|
||||
# usage: ynh_use_python
|
||||
#
|
||||
# Requires YunoHost version 2.7.12 or higher.
|
||||
ynh_use_python () {
|
||||
# Get the absolute path of this version of python
|
||||
python_version=$(ynh_app_setting_get --app=$app --key=python_version)
|
||||
# Get the absolute path of this version of Python
|
||||
python_path="$python_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
|
||||
# Allow alias to be used into bash script
|
||||
shopt -s expand_aliases
|
||||
|
||||
# Create an alias for the specific version of python and a variable as fallback
|
||||
# Create an alias for the specific version of Python and a variable as fallback
|
||||
ynh_python="$python_path/python"
|
||||
alias ynh_python="$ynh_python"
|
||||
# And pip
|
||||
ynh_pip="$python_path/pip"
|
||||
alias ynh_pip="$ynh_pip"
|
||||
|
||||
# Load the path of this version of python in $PATH
|
||||
# Load the path of this version of Python in $PATH
|
||||
if [[ :$PATH: != *":$python_path"* ]]; then
|
||||
PATH="$python_path:$PATH"
|
||||
fi
|
||||
|
@ -176,7 +177,7 @@ ynh_install_python () {
|
|||
pyenv install --skip-existing $python_version &>/dev/null
|
||||
|
||||
# Remove app virtualenv
|
||||
if `pyenv virtualenvs | grep "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
if `pyenv virtualenvs | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
then
|
||||
pyenv virtualenv-delete --force $YNH_APP_INSTANCE_NAME
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue