From 7850a7ca7e089c824181f6f8498df245b331ebff Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Jan 28 2020 03:36:19 +0000 Subject: Update to 4.8.2 Obtain bash completion file from github - tartansandal/conda-bash-completion --- diff --git a/0002-Adjust-ruamel.yaml-imports.patch b/0002-Adjust-ruamel.yaml-imports.patch index e37ba17..b9366bb 100644 --- a/0002-Adjust-ruamel.yaml-imports.patch +++ b/0002-Adjust-ruamel.yaml-imports.patch @@ -1,17 +1,9 @@ -commit 40a3c3c80c78a1086c376b71e1e4c352f9a1d244 -Author: rpm-build -Date: Sat Mar 30 20:56:58 2019 -0600 - - [PATCH] Adjust ruamel.yaml imports - - This is how it's called in Fedora. - diff --git a/conda/common/configuration.py b/conda/common/configuration.py -index 87c36ef..cda042f 100644 +index 53d9225..1fdf48a 100644 --- a/conda/common/configuration.py +++ b/conda/common/configuration.py -@@ -47,9 +47,9 @@ from .._vendor.boltons.setutils import IndexedSet - from .._vendor.toolz import concat, concatv, excepts, merge, unique +@@ -45,9 +45,9 @@ from .._vendor.boltons.setutils import IndexedSet + from .._vendor.toolz import concat, concatv, excepts, merge, merge_with, unique try: # pragma: no cover - from ruamel_yaml.comments import CommentedSeq, CommentedMap diff --git a/conda b/conda new file mode 100644 index 0000000..0309bad --- /dev/null +++ b/conda @@ -0,0 +1,201 @@ +# bash_completion for conda. +# +# This was initially based on completion support for `fish`, but later extended +# complete options for subcommands and files/dirs/paths as appropriate. +# +# Dynamic option lookup uses a cache that persists for the duration of the shell. +# Updates to the conda command options are relatively rare, but there is a small chance +# that this cache will hold incorrect/incomplete values. A restart of your shell will +# fix this. + +# If this completion file is 'installed' under +# +# /etc/bash_completion.d/, +# /usr/share/bash-completion/completions/, or +# ~/.local/share/bash-completion/completions/, +# +# rather than being managed via the `conda shell.bash hook`, then this file may +# be sourced before conda is setup. To support this we allow for a potential +# late initialization of the CONDA_ROOT and CONDA_SOURCE environment +# variables. + +# The extglob option is set by the bash_completion library anyway, +# Setting it here to work around some rare edge cases. +shopt -s extglob + +function __comp_conda_ensure_root() { + if [[ -z "${CONDA_SOURCE-}" && -n "${CONDA_EXE-}" ]] ; then + if [[ -n "${_CE_CONDA-}" && -n "${WINDIR-}" ]]; then + CONDA_ROOT=$(\dirname "${CONDA_EXE}") + else + CONDA_ROOT=$(\dirname "${CONDA_EXE}") + CONDA_ROOT=$(\dirname "${CONDA_ROOT}") + fi + \local script=" + : from __future__ import print_function + : import os + : import conda + : print(os.path.dirname(conda.__file__)) + " + # don't assume an active base environment + CONDA_SOURCE=$(conda activate base; python -c "${script// : /}") + fi +} + +function __comp_conda_commands () { + # default core commands + echo clean config create help info init install list package + echo remove uninstall run search update upgrade + + # implied by conda shell function + echo activate deactivate + + # check commands from full anaconda install + for f in $CONDA_SOURCE/cli/main_*.py + do + # skip pip -- not a sub-command + [[ $f == */main_pip.py ]] && continue + \expr match "$f" '.*_\([a-z]\+\)\.py$' + done + + # check extra pluggins + for f in $CONDA_ROOT/bin/conda-* + do + if [[ -x "$f" && ! -d "$f" ]] + then + \expr match "$f" '^.*/conda-\(.*\)' + fi + done +} + +function __comp_conda_env_commands() { + for f in $CONDA_SOURCE/../conda_env/cli/main_*.py + do + \expr match "$f" '.*_\([a-z]\+\)\.py$' + done +} + +function __comp_conda_envs() { + \local script=" + : from __future__ import print_function; + : import json, os, sys; + : from os.path import isdir, join; + : print('\n'.join( + : d for ed in json.load(sys.stdin)['envs_dirs'] if isdir(ed) + : for d in os.listdir(ed) if isdir(join(ed, d)))); + " + conda config --json --show envs_dirs | python -c "${script// : /}" +} + +function __comp_conda_packages() { + conda list | awk 'NR > 3 {print $1}' +} + +function __comp_conda_cmds_str() { + # get a list of commands, skipping options + \local cmd + \local -a cmds + for cmd in $*; do + case "$cmd" in + -*) continue ;; + *) cmds+=($cmd) ;; + esac + done + echo "${cmds[*]}" +} + +# helper for debugging issues with the cache +function __comp_conda_cache_dump() { + for k in "${!__comp_conda_cache[@]}"; do + printf "%s:\n" "$k" + for w in ${__comp_conda_cache[$k]}; do + printf "\t%s\n" "$w" + done + done +} + +function __comp_conda_option_lookup() { + \local word_list cmd_str cmd_key + cmd_str=$1 + + # make a key to look up the cached result of the command help + # (We should be able to just use $cmd_str, since spaces in an array key are fine, + # but this produces an error with an empty cache. I'm not sure why though) + cmd_key=${cmd_str// /_} + + if [[ -z "${__comp_conda_cache[$cmd_key]}" ]]; then + # parse the output of command help to get completions + word_list=$($cmd_str --help 2>&1 | _parse_help -) + if [[ ${PIPESTATUS[0]} -eq 0 && -n $word_list ]]; then + __comp_conda_cache[$cmd_key]=$word_list + else + # something went wrong, so abort completion attempt + return 1 + fi + else + word_list=${__comp_conda_cache[$cmd_key]} + fi + echo $word_list +} + +# cache conda subcommand help lookups for the duration of the shell +unset __comp_conda_cache +declare -A __comp_conda_cache + +# If conda has not been fully setup/activated yet, some of the above functions may fail +# and print error messages. This is not helpful during normal usage, so we discard all +# error output by default. +__comp_conda_ensure_root 2>/dev/null || : + +_comp_conda() +{ + \local cur prev words cword + _init_completion || return + + __comp_conda_ensure_root 2>/dev/null + + \local word_list cmd_str + if [[ $cur == -* ]]; then + # get the current list of commands as a string sans options + cmd_str="$(__comp_conda_cmds_str ${words[@]})" + word_list=$(__comp_conda_option_lookup "$cmd_str") + else + case "$prev" in + conda) + word_list=$(__comp_conda_commands 2>/dev/null) + ;; + env) + word_list=$(__comp_conda_env_commands 2>/dev/null) + ;; + activate) + _filedir -d # environment directories + word_list=$(__comp_conda_envs 2>/dev/null) + ;; + remove|uninstall|upgrade|update) + word_list=$(__comp_conda_packages 2>/dev/null) + ;; + --name|--clone) + word_list=$(__comp_conda_envs 2>/dev/null) + ;; + --*-file|--file|--which|convert) + _filedir # filenames + ;; + --*-dir|--*-folder|--subdir|--prefix|--cwd|index) + _filedir -d # directories + ;; + verify|debug) + _filedir 'tar.bz2' # package paths and directories + ;; + build) + _filedir 'tar.bz2' # package paths and directories + word_list='purge purge-all' # special keywords + ;; + esac + fi + if [[ -n $word_list ]]; then + COMPREPLY+=( $(compgen -W "$word_list" -- "$cur") ) + fi +} && +complete -F _comp_conda conda + +# vim: ft=sh diff --git a/conda-conda_etc.patch b/conda-conda_etc.patch deleted file mode 100644 index b763a40..0000000 --- a/conda-conda_etc.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -up conda-4.8.0/conda/shell/etc/conda_bash.sh.conda_etc conda-4.8.0/conda/shell/etc/conda_bash.sh ---- conda-4.8.0/conda/shell/etc/conda_bash.sh.conda_etc 2019-11-04 10:30:49.000000000 -0700 -+++ conda-4.8.0/conda/shell/etc/conda_bash.sh 2019-12-14 16:17:04.692391506 -0700 -@@ -1,11 +1,4 @@ --# In dev-mode CONDA_EXE is python.exe and on Windows --# it is in a different relative location to condabin. --if [ -n "${_CE_CONDA}" -a -n "${WINDIR-}" ]; then -- CONDA_ETC=$(\dirname "${CONDA_EXE}")/etc --else -- CONDA_ETC=$(\dirname "${CONDA_EXE}") -- CONDA_ETC=$(\dirname "${CONDA_ETC}")/etc --fi -+CONDA_ETC=/etc - - # Load the POSIX setup - . $CONDA_ETC/profile.d/conda.sh diff --git a/conda.spec b/conda.spec index 26eacb7..c756e0b 100644 --- a/conda.spec +++ b/conda.spec @@ -1,8 +1,8 @@ %{!?_with_bootstrap: %global bootstrap 0} Name: conda -Version: 4.8.0 -Release: 2%{?dist} +Version: 4.8.2 +Release: 1%{?dist} Summary: Cross-platform, Python-agnostic binary package manager License: BSD and ASL 2.0 and LGPLv2+ and MIT @@ -13,14 +13,13 @@ License: BSD and ASL 2.0 and LGPLv2+ and MIT URL: http://conda.pydata.org/docs/ Source0: https://github.com/conda/conda/archive/%{version}/%{name}-%{version}.tar.gz -# Source0: https://pypi.io/packages/source/c/%%{name}/%%{name}-%%{version}.tar.gz +# bash completion script moved to a separate project +Source1: https://raw.githubusercontent.com/tartansandal/conda-bash-completion/1.5/conda Patch0: conda_sys_prefix.patch Patch1: conda_gateways_disk_create.patch Patch2: setup.patch # Use system cpuinfo Patch3: conda-cpuinfo.patch -# Fix CONDA_ETC in conda_bash.sh -Patch4: conda-conda_etc.patch Patch10001: 0001-Fix-toolz-imports.patch Patch10002: 0002-Adjust-ruamel.yaml-imports.patch @@ -31,13 +30,16 @@ Patch10006: 0006-shell-assume-shell-plugins-are-in-etc.patch BuildArch: noarch +BuildRequires: pkgconfig(bash-completion) +%global bash_completionsdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || echo '/etc/bash_completion.d') +BuildRequires: sed + Requires: python%{python3_pkgversion}-conda = %{version}-%{release} # Removed upstream in favour of calling "conda activate" in version 4.4.0 Obsoletes: conda-activate < 4.4 %?python_enable_dependency_generator -BuildRequires: sed %global _description %{expand: Conda is a cross-platform, Python-agnostic binary package manager. It @@ -153,12 +155,10 @@ install -m 0644 -Dt %{buildroot}/etc/profile.d/ conda/shell/etc/profile.d/conda. sed -r -i '1i CONDA_EXE=%{_bindir}/conda' %{buildroot}/etc/profile.d/conda.sh sed -r -i -e '1i set _CONDA_EXE=%{_bindir}/conda\nset _CONDA_ROOT=' \ -e 's/CONDA_PFX=.*/CONDA_PFX=/' %{buildroot}/etc/profile.d/conda.csh -mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d -install -m 0644 -Dt %{buildroot}/etc/bash_completion.d/ conda/shell/etc/bash_completion.d/conda -# make conda shell.bash hook work -mkdir -p %{buildroot}%{python3_sitelib}/conda/shell/etc -cp -p conda/shell/etc/conda_bash.sh %{buildroot}%{python3_sitelib}/conda/shell/etc/ +# Install bash completion script +mkdir -p %{buildroot}%{bash_completionsdir} +install -m 0644 -Dt %{buildroot}%{bash_completionsdir}/ %SOURCE1 %check @@ -181,7 +181,7 @@ py.test-%{python3_version} -vv -m "not integration" \ %files %{_bindir}/conda %{_bindir}/conda-env -/etc/bash_completion.d/conda +%{bash_completionsdir}/conda /etc/profile.d/conda.sh /etc/profile.d/conda.csh @@ -197,6 +197,10 @@ py.test-%{python3_version} -vv -m "not integration" \ %changelog +* Tue Jan 28 2020 Orion Poplawski - 4.8.2-1 +- Update to 4.8.2 +- Obtain bash completion file from github - tartansandal/conda-bash-completion + * Mon Jan 20 2020 Orion Poplawski - 4.8.0-2 - Install bash completion file (bz#1791068) diff --git a/sources b/sources index 4887b43..44778e2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (conda-4.8.0.tar.gz) = c85ea7b051171479ee387fb6d54204ab59489521ac822797c4dc7b5be120c4b8a6844eb7c36ec85d3238dbb5a1525e8c5371df0d2b478d26e25d2bac5e26a07e +SHA512 (conda-4.8.2.tar.gz) = f9537fa675d7311bf9a04cf8e925ff2afbed6f5df51281633327a8d2e4f4eeedf7cf22ef44e000e6960b96bc1c32bed85f51e20675a4186d5300c74e4ba6ac34