Skip to content

Commit

Permalink
fix: Respect PYTHONPATH environment
Browse files Browse the repository at this point in the history
If PYTHONPATH is set to non-empty value, include it when running the
egg. The Egg path is always the first to ensure the correct egg will be
run, but the rest of the paths is now included.

This is useful during development. For example, `rhsm` may only be
available on non-standard path (= not as installed package), and without
this patch it is not possible to use it.
  • Loading branch information
m-horky committed Mar 6, 2024
1 parent 7bcc085 commit 3c886f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/insights_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ def run_phase(phase, client, validated_eggs):
continue
client_debug("phase '%s'; egg '%s'" % (phase['name'], egg))

# set up the env
# prepare the environment
pythonpath = str(egg)
env_pythonpath = os.environ.get("PYTHONPATH", "") # type: str
if env_pythonpath:
pythonpath += ":" + env_pythonpath
insights_env = {
"INSIGHTS_PHASE": str(phase['name']),
"PYTHONPATH": str(egg)
"PYTHONPATH": pythonpath,
}
env = os.environ
env.update(insights_env)
Expand Down

0 comments on commit 3c886f4

Please sign in to comment.