Last active
July 15, 2024 20:36
-
-
Save mfansler/b7b75f73495b940948efa3c1f58827bf to your computer and use it in GitHub Desktop.
Conda Forge `staged-recipes` utility scripts
This file contains 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
#!/usr/bin/env bash -l | |
#' Usage: `bash -l new-cran-pkg.sh {r-package}` | |
#' Purpose: Generates a Conda Forge recipe using `conda_r_skeleton_helper` and | |
#' pushes this to a personal fork of `staged-recipes`. | |
#' Notes: Should be located in and run from a `staged-recipes` clone prefix. | |
#' `git remote -v` should show `origin` set to a personal fork | |
#' and `upstream` set to 'git@github.com:conda-forge/staged-recipes.git'. | |
#' CRAN package name should be prefixed with 'r-' and given in all lowercase. | |
set -xe -o pipefail | |
## validate arguments | |
if [[ $# -ne 1 ]]; then | |
echo "Requires a CRAN package name (e.g., 'r-foo')." >&2 | |
exit 2 | |
fi | |
## parameters | |
tmp=$(mktemp -d) | |
PKG_CF=$1 | |
FILE_META="recipes/${PKG_CF}/meta.yaml" | |
GIT_CRSH="git@github.com:bgruening/conda_r_skeleton_helper.git" | |
DIR_CRSH="${tmp}/conda_r_skeleton_helper" | |
## update main | |
./sync-upstream.sh | |
## checkout new branch | |
git checkout -b $1 | |
## clone conda_r_skeleton_helper | |
git clone --depth=1 ${GIT_CRSH} ${DIR_CRSH} | |
## generate recipe | |
DIR_SR=$(pwd) | |
pushd ${DIR_CRSH} | |
echo "$1" > packages.txt | |
conda run -n base --live-stream python run.py | |
## copy recipe | |
cp -R "$1" "${DIR_SR}/recipes/." | |
popd | |
## add files | |
git add recipes/$1/* | |
## commit | |
git commit -m "adds $1" | |
## setup remote | |
git push -u origin $1 | |
## cleanup | |
rm -rf ${tmp} | |
## lint recipe | |
{ printf "\nLinting recipe:\n\n"; } 2> /dev/null | |
conda run -n base --live-stream \ | |
conda-smithy recipe-lint recipes/${PKG_CF} | |
## suggest stub | |
PKG_CRAN=$(grep "# Package:" ${FILE_META} | awk '{print $3}') | |
{ | |
printf "\nSuggested PR stub:\n\n" | |
printf "\tAdds [CRAN package \`%s\`](https://cran.r-project.org/package=%s) as \`%s\`. Recipe generated with \`conda_r_skeleton_helper\`.\n\n" $PKG_CRAN $PKG_CRAN $PKG_CF | |
} 2> /dev/null |
This file contains 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
#!/usr/bin/env bash -l | |
#' Usage: `bash -l new-pypi-pkg.sh {pypi-package}` | |
#' Purpose: Generates a Conda Forge recipe using `grayskull` and | |
#' pushes this to a personal fork of `staged-recipes`. | |
#' Notes: Should be located in and run from a `staged-recipes` clone prefix. | |
#' `git remote -v` should show `origin` set to a personal fork | |
#' and `upstream` set to 'git@github.com:conda-forge/staged-recipes.git'. | |
#' PyPI package name should be given in all lowercase. | |
set -xe -o pipefail | |
if [[ $# -ne 1 ]]; then | |
echo "Requires a PyPI package name (all lowercase)." >&2 | |
exit 2 | |
fi | |
## update main | |
./sync-upstream.sh | |
## run grayskull | |
conda run -n grayskull \ | |
--live-stream \ | |
grayskull pypi -o recipes/ $1 | |
## checkout new branch | |
git checkout -b $1 | |
## add files | |
git add recipes/$1/* | |
## commit | |
git commit -m "adds $1" | |
## setup remote | |
git push -u origin $1 |
This file contains 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
#!/usr/bin/env bash -l | |
#' Usage: `bash -l sync-upstream.sh` | |
#' Purpose: Refreshes 'main' branch of current git repository from upstream | |
#' and pushes this to 'origin'. | |
#' Notes: Should be located in and run from a `staged-recipes` clone prefix. | |
#' `git remote -v` should show `origin` set to a personal fork | |
#' and `upstream` set to 'git@github.com:conda-forge/staged-recipes.git'. | |
set -xe -o pipefail | |
## switch back to main | |
git checkout main | |
## git fetch from upstream | |
git fetch upstream main | |
## merge upstream | |
git merge upstream/main | |
## update remote | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision 3 Changes
conda-smithy
linting (helps to catch aberrant SPDX license issues)