Skip to content

Commit

Permalink
Make pandoc an optional installation
Browse files Browse the repository at this point in the history
Resolves #160
  • Loading branch information
alexiswl committed May 25, 2023
1 parent ea8ea98 commit ab35a67
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
35 changes: 31 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ You should have the following applications installed before continuing:
* yq (version 4.18 or later)
MacOS users, please install greadlink through 'brew install coreutils'
Options:
--install-pandoc: Required for running the command icav2 projectpipelines create-cwl-from-zip
"

ICAV2_CLI_PLUGINS_HOME="$HOME/.icav2-cli-plugins"
Expand Down Expand Up @@ -138,6 +141,24 @@ get_this_path() {
echo "${this_dir}"
}

################
# ARGUMENTS
################
# Get args from command line
install_pandoc="false"
while [ $# -gt 0 ]; do
case "$1" in
--install-pandoc)
install_pandoc="true"
;;
-h | --help)
print_help
exit 0
;;
esac
shift 1
done

################
# GET VERSIONS
################
Expand Down Expand Up @@ -282,10 +303,16 @@ sed -i "s/__PLUGIN_VERSION__/${PLUGIN_VERSION}/" "${ICAV2_CLI_PLUGINS_HOME}/shel
# LINK PANDOC BINARY
######################
# Link pandoc binary from site-packages/pypandoc/files/pandoc to ${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin
( \
cd "${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin/";
ln -sf "${SITE_PACKAGES_DIR}/pypandoc/files/pandoc" "${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin/pandoc}"
)
if [[ "${install_pandoc}" == "true" ]]; then
echo_stderr "Installing pandoc requirements"
"${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin/python3" -m pip install --requirement "${ICAV2_CLI_PLUGINS_HOME}/requirements-pandoc.txt" --quiet
if [[ -f "${SITE_PACKAGES_DIR}/pypandoc/files/pandoc" ]]; then
( \
cd "${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin/";
ln -sf "${SITE_PACKAGES_DIR}/pypandoc/files/pandoc" "${ICAV2_CLI_PLUGINS_HOME}/pyenv/bin/pandoc}"
)
fi
fi

######################
# COPY AUTOCOMPLETIONS
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/requirements-pandoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
pypandoc==1.10
pypandoc_binary==1.10
2 changes: 0 additions & 2 deletions src/plugins/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ websocket_client==1.4.2
# Manual additions
cwltool==3.1.20221201130942
pandoc==2.3
pypandoc==1.10
pypandoc_binary==1.10
humanfriendly==10.0
matplotlib==3.7.1
invoke==2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def print_to_stdout(self):
)

def check_args(self):
# Check pypandoc binary
try:
import pandoc
except ImportError:
logger.error("Could not find pandoc module, please re-run the installation script with --install-pandoc parameter")
raise ImportError
# Check zipped workflow path exists
self.zipped_workflow_path = Path(self.args.get("<zipped_workflow_path>"))
if not self.zipped_workflow_path.is_file():
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/utils/gh_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

from utils.logger import get_logger

import pandoc

logger = get_logger()


Expand Down

0 comments on commit ab35a67

Please sign in to comment.