SkyWalker
SkyWalker

Reputation: 14309

How to create a generic bash shell that will run whatever python is in the PATH?

Due to a complex corporate setup and having a venv I use in the CI pipelines and in the target deployment, I need the python inside my venv bin to run whatever python is in the PATH. I do the following but seems to end in an infinite loop:

This is the content of my $DEPLOYMENT_VENV/bin/python

#!bin/bash
python $@

the default actual python to use is setup in the PATH before.

Why would this lead to infinite loop or hanging forever?

Upvotes: 0

Views: 97

Answers (1)

Jay jargot
Jay jargot

Reputation: 2868

There is an infinite loop if the python found by bash is the same than $DEPLOYMENT_VENV/bin/python.

There could be several reasons: the PATH variable does not have the same value in your terminal, than in the environment where the script is executed, etc.

To troubleshoot this, you should modify temporary the $DEPLOYMENT_VENV/bin/python, in order to add 2 lines to generate extra debug log message in a temporary file /tmp/dbg-python.txt:

#!/bin/bash
printf "DBG: " >>/tmp/dbg-python.txt 2>&1
type python >>/tmp/dbg-python.txt 2>&1
printf "\nDBG: PATH=%s\n" "${PATH}" >>/tmp/dbg-python.txt 2>&1
# python $@

Test again.

What is the content of the /tmp/dbg-python.txt file?

Upvotes: 1

Related Questions