Last active
September 3, 2020 01:25
-
-
Save brianv0/9061db99ea6785d67a08876a4fa1e9a4 to your computer and use it in GitHub Desktop.
Pin it - Get versions of a package's installed dependencies from conda in a form which is good for the pinned file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pkg=$1 | |
# Get the current versions of a package's installed dependencies | |
# get dist_name for the package so we can find it's json file | |
pkg_dist_name=$(conda list --json | jq -r '.[] | select(.name=="'${pkg}'") | .dist_name') | |
# get dependencies in the form of a regex | |
name_regex=$(jq -r '.depends | map(. | split(" ")[0]) | join("$|")' ${CONDA_PREFIX}/conda-meta/${pkg_dist_name}.json) | |
# print list of dependency=version for installed dependencies | |
conda list --json | jq -r '.[] | select(.name | match("'${name_regex}'")) | "\(.name)=\(.version)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment