potiuk edited a comment on pull request #21520:
URL: https://github.com/apache/airflow/pull/21520#issuecomment-1037334254


   Hey @ephraimbuddy  - I found a way of adding the mssql-cli without impacting 
our dependencies (I am using pipx to install it).
   
   @uranusjr - re pipx - is it often the case that package scripts need some 
adjustments when installed by `pipx` to make it works (like in this case?) I 
guess because they are using own bash scripts rather than relying on 
entrypoint? 
   
   I had to do this to make it works:
   
   ```
       # Unfortunately mssql-cli installed by `pipx` does not work out of the 
box because it uses
       # its own execution bash script which is not compliant with the 
auto-activation of
       # pipx venvs - we need to manually patch Python executable in the script 
to fix it: ¯\_(ツ)_/¯
       sed "s/python /\/root\/\.local\/pipx\/venvs\/mssql-cli\/bin\/python /" 
-i /root/.local/bin/mssql-cli
   ```
   
   The original script was this (which had no chance to run when it was 
installed by pipx):
   
   ```
   #!/usr/bin/env bash
   
   SOURCE="${BASH_SOURCE[0]}"
   while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a 
symlink
     DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
     SOURCE="$(readlink "$SOURCE")"
     [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative 
symlink, we need to resolve it relative to the path where the symlink file was 
located
   done
   DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
   
   # Set the /root/.local/pipx/venvs/mssql-cli/bin/python io encoding to UTF-8 
by default if not set.
   if [ -z ${PYTHONIOENCODING+x} ]; then export PYTHONIOENCODING=UTF-8; fi
   
   export PYTHONPATH="${DIR}:${PYTHONPATH}"
   
   python -m mssqlcli.main "$@"
   ```
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to