<commit_before>#==================================
# Python Select Compensation
#==================================
#PYTHON Variables


function port_python_alias () {
    
    
    GETPYTHONREGEX="s/^.*py[A-Za-z]+([0-9])([0-9]+)-?[A-Za-z]*.*$/\1.\2/"
    COMMAND="port select --show python"
    
    PYVERSION=`$COMMAND  | sed -E $GETPYTHONREGEX `
    PORT_BIN="$MPPREFIX/bin"
    PORT_PY_BIN="$MPPREFIX/Library/Frameworks/Python.framework/Versions/2.7/bin"
    
    files=`find $PORT_BIN/*-$PYVERSION`
    
    
    
    for file in $files
    do
        dirname=${file%/*}
        rootname=${file##*/}
        program=${rootname%-*}
        if [ ! -e "$dirname/$program" ]; then
            echo "Linking $file to $program"
            sudo ln -s "$file" "$dirname/$program"
        fi
    done
    
    files=`find $PORT_PY_BIN/*-$PYVERSION`
    
    for file in $files
    do
        dirname=${file%/*}
        rootname=${file##*/}
        program=${rootname%-*}
        if [ ! -e "$dirname/$program" ]; then
            sudo ln -s "$file" "$dirname/$program"
        fi
    done
    
    
    PYVERSIONSHORT=`echo $PYVERSION | sed -E 's/\.//g'`
    
    PYDIR=py-$PYVERSIONSHORT
    
    LOCALPY="~/.python"
    if [ -d $LOCALPY ]; then
        if [ -z $PYTHONPATH ]; then
            export PYTHONPATH="$LOCALPY"
        else
            export PYTHONPATH="${PYTHONPATH}:$LOCALPY"
        fi
        export PYTHONPATH="${PYTHONPATH}:~/.python/lib/python/site-packages:~/.python/lib/python$PYVERSION/site-packages"
        export PYTHONPATH="${PYTHONPATH}:~/.python/lib/python:~/.python/lib/python$PYVERSION"
    fi
    
    # if [ -z $PYTHONPATH ]; then
    #     export PYTHONPATH="${PYTHONPATH}:$MPPREFIX/Library/Python/$PYVERSION/site-packages"
    # else
    #     export PYTHONPATH="$MPPREFIX/Library/Python/$PYVERSION/site-packages"
    # fi
    # export PYTHONPATH="${PYTHONPATH}:/Library/Python/$PYVERSION/site-packages" #Add back system Library packages
    export PATH="$HOME/Library/Python/$PYVERSION/bin/:$MPPREFIX/Library/Frameworks/Python.framework/Versions/$PYVERSION/bin/:$PATH"
    STSCI="/usr/local/stsci/$PYDIR/lib/python"
    if [ -d $STSCI ]; then
        export PYTHONPATH="${PYTHONPATH}:$STSCI" # PUT STSCI at the end
        export PATH="$PATH:/usr/local/stsci/$PYDIR/bin"
    fi
    
    if [ -f $MPPREFIX/bin/python3.3 ]; then
        alias python3=python3.3
    fi
}

if [ -f $MPPREFIX/bin/port ]; then
    port_python_alias
fi<commit_msg>Better handling of python_select for python3<commit_after>#==================================
# Python Select Compensation
#==================================
#PYTHON Variables

function port_python_version () {
  if [[ -z $PYVERSION ]]; then
    local GETPYTHONREGEX="s/^.*py[A-Za-z]+([0-9])([0-9]+)-?[A-Za-z]*.*$/\1.\2/"
    local COMMAND="port select --show python"
    PYVERSION=`$COMMAND  | sed -E $GETPYTHONREGEX`
    PYVERSIONSHORT=`echo $PYVERSION | sed -E 's/\.//g'`
  fi
  echo "$PYVERSION"
}

function link_port_python () {
  files=`find $1/*-$(port_python_version)`
  for file in $files
  do
      dirname=${file%/*}
      rootname=${file##*/}
      program=${rootname%-*}
      if [ ! -e "$dirname/$program" ]; then
          echo "Linking $file to $program"
          sudo ln -s "$file" "$dirname/$program"
      fi
  done
}

function port_python_alias () {
    
    PYV=$(port_python_version)
    
    PORT_BIN="$MPPREFIX/bin"
    PORT_PY_BIN="$MPPREFIX/Library/Frameworks/Python.framework/Versions/2.7/bin"
    
    link_port_python $PORT_BIN
    link_port_python $PORT_PY_BIN
    
    PYDIR="py-$PYVERSIONSHORT"
    
    LOCALPY="~/.python"
    if [ -d $LOCALPY ]; then
        if [ -z $PYTHONPATH ]; then
            export PYTHONPATH="$LOCALPY"
        else
            export PYTHONPATH="${PYTHONPATH}:$LOCALPY"
        fi
        export PYTHONPATH="${PYTHONPATH}:~/.python/lib/python/site-packages:~/.python/lib/python$PYVERSION/site-packages"
        export PYTHONPATH="${PYTHONPATH}:~/.python/lib/python:~/.python/lib/python$PYVERSION"
    fi
    
    export PATH="$HOME/Library/Python/$PYVERSION/bin/:$MPPREFIX/Library/Frameworks/Python.framework/Versions/$PYVERSION/bin/:$PATH"
    STSCI="/usr/local/stsci/$PYDIR/lib/python"
    if [ -d $STSCI ]; then
        export PYTHONPATH="${PYTHONPATH}:$STSCI" # PUT STSCI at the end
        export PATH="$PATH:/usr/local/stsci/$PYDIR/bin"
    fi
    
    py3exe=`find $MPPREFIX/bin -name python3.[0-9]`
    if [ -f $py3exe ]; then
    if [ ! -e "$MPPREFIX/bin/python3" ]; then
      echo "Linking $py3exe to python3"
        sudo ln -s "$py3exe" "$MPPREFIX/bin/python3"
      fi
    fi
}

if [ -f $MPPREFIX/bin/port ]; then
    port_python_alias
fi
{'fraction_non_alphanumeric': 0.18689993599317262, 'fraction_numerical': 0.007040751013441433, 'mean_word_length': 2.6539360872954014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '330804', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1610, 'n_words': 279}