Changeset View
Changeset View
Standalone View
Standalone View
pythonpath.sh
# usage: . pythonpath | # usage: . pythonpath | ||||
# | # | ||||
# source this file as above (do not execute it) to set the PYTHONPATH | # source this file as above (do not execute it) to set the PYTHONPATH | ||||
# environment variable to the list of directories corresponding to the | # environment variable to the list of directories corresponding to the | ||||
# repositories known to mr | # repositories known to mr | ||||
local base_path | |||||
# special case for bash to get the sourced script file path | |||||
if [ -n "${BASH_VERSION}" ] ; then | |||||
base_path=$( dirname "${BASH_SOURCE[0]}" ) | |||||
else | |||||
base_path=$( dirname "$0" ) | base_path=$( dirname "$0" ) | ||||
fi | |||||
local tmp_path | |||||
tmp_path=$( | tmp_path=$( | ||||
for dir in $( builtin cd $base_path && bin/ls-all-repos --absolute ) ; do | for dir in $( builtin cd $base_path && bin/ls-all-repos --absolute ) ; do | ||||
if echo "$dir" | grep -q -- '-template$' ; then | if echo "$dir" | grep -q -- '-template$' ; then | ||||
continue | continue | ||||
fi | fi | ||||
if test -d "${dir}/swh/" ; then | if test -d "${dir}/swh/" ; then | ||||
echo "$dir" | echo "$dir" | ||||
fi | fi | ||||
done \ | done \ | ||||
| paste -d':' -s) | | paste -d':' -s) | ||||
export PYTHONPATH="$tmp_path" | export PYTHONPATH="$tmp_path" | ||||
if [ "$1" = "-p" -o "$1" = "--print" ] ; then | if [ "$1" = "-p" -o "$1" = "--print" ] ; then | ||||
echo $PYTHONPATH | echo $PYTHONPATH | ||||
fi | fi | ||||
unset base_path | |||||
unset tmp_path |