#compdef python

autoload +X _python

_auto_argcomplete_python () {
  local -a options
  local output ret=1

  if [[ $CURRENT -eq 2 ]]; then
    _python
  elif [ "${words[2]}" = "setup.py" ]; then
    _python
  else
    output=$(auto_argcomplete ${words[2]} 2>/dev/null)
    eval "options=($output)"  # for completion with description
    if [ ${#options} -eq 0 ]; then
      _python
    else
      _describe 'values' options && ret=0
    fi
  fi
}
_auto_argcomplete_python
