Skip to content

Commit

Permalink
create-env: Allow passing PREFIX via --prefix=...
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Jun 2, 2024
1 parent 884e219 commit a7866a2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions images/create-env/create-env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ for arg do
case "${arg}" in
--help )
cat <<'end-of-help'
Usage: create-env [OPTIONS]... [--] PREFIX [CONDA_CREATE_ARGS]...
Usage: create-env [OPTIONS]... [--] [PREFIX] [CONDA_CREATE_ARGS]...
Use conda (or mamba via --conda=mamba) to create a Conda environment at PREFIX
according to specifications given by CONDA_CREATE_ARGS.
Expand All @@ -19,6 +19,8 @@ according to specifications given by CONDA_CREATE_ARGS.
script. (default: PREFIX/env-activate.sh)
--env-execute-script=FILE Destination path of environment execution script.
(default: PREFIX/env-execute)
--prefix=PREFIX Destination path of environment.
If omitted, first positional argument is PREFIX.
--remove-paths=GLOB Glob of paths to remove from PREFIX after its
creation. Can be passed on multiple times. Will
be passed on to `find -path PREFIX/GLOB`.
Expand Down Expand Up @@ -57,6 +59,9 @@ end-of-help
"${arg#--remove-paths=}"
)"
shift ;;
--prefix=* )
prefix="${arg#--prefix=}"
shift ;;
--strip-files=* )
strip_files_globs="$(
printf '%s\n' \
Expand All @@ -78,13 +83,15 @@ end-of-help
esac
done

if [ $# -eq 0 ] ; then
printf 'missing argument: environment path\n'
exit 1
if [ -z "${prefix+x}" ] ; then
if [ $# -eq 0 ] ; then
printf 'missing argument: environment path\n' 1>&2
exit 1
fi
prefix="${1}"
shift
fi

prefix="${1%%/}"
shift
prefix="${prefix%%/}"

conda_impl="${conda_impl:-conda}"
create_command="${create_command-create}"
Expand Down

0 comments on commit a7866a2

Please sign in to comment.