Skip to content

Commit

Permalink
feat: add script to allow the CLI to work without pip install
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Jun 26, 2024
1 parent aca24ca commit 310a9b0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CCBR template for creating Nextflow pipelines <!-- TODO: replace this line with
.github/ISSUE_TEMPLATE/bug_report.yml
.github/ISSUE_TEMPLATE/config.yml
.github/workflows/build.yml
bin/tool_name
CHANGELOG.md
CITATION.cff
README.md
Expand Down
7 changes: 7 additions & 0 deletions bin/tool_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# script that allows the CLI to work out-of-the-box
# without the need to install it via pip first

TOOLDIR=$(realpath $(dirname $(dirname ${BASH_SOURCE})))

${TOOLDIR}/main.py "$@"
17 changes: 17 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
# this script gets called by bin/tool_name
import os
import re
import sys

# add script directory to the path to allow the CLI to work out-of-the-box
# without the need to install it via pip first
SCRIPT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "src")
sys.path.append(SCRIPT_DIR)
from src.__main__ import main

if (
__name__ == "__main__"
): # this block is adapted from the executable file created by `pip install`
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())

0 comments on commit 310a9b0

Please sign in to comment.