-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add script to allow the CLI to work without pip install
parallels CCBR/CHAMPAGNE#180
- Loading branch information
1 parent
aca24ca
commit 310a9b0
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
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
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
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 "$@" |
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
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()) |