Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create scripts to make champagne cli work OOTB #180

Merged
merged 10 commits into from
Jun 26, 2024
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ jobs:
cache: "pip"
- name: Install nextflow
uses: nf-core/setup-nextflow@v1
- name: Install dependencies
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
mkdir -p tests/bin/
pip install click pyyaml cffconvert
- name: check out-of-the-box CLI script
run: |
bash bin/champagne --help
cd tests/cli && ../../bin/champagne --help
- name: Install champagne python package
run: |
pip install .[dev,test]
python -c 'from champagne.src.util import chmod_bins_exec; chmod_bins_exec()'
- name: Check CLI basics
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## CHAMPAGNE development version

- Create a script (`bin/champagne`) to provide an interface to the champagne CLI that works out-of-the-box without the need to install the python package with `pip`. (#180, @kelly-sovacool)
- However, any dependencies not in the Python Standard Library must be installed for this to work. See the dependencies list in `pyproject.toml`.
- Fix configuration files for compatibility with using the GitHub repo as the source. (#173, @kelly-sovacool)
- These equivalent commands now work:
```sh
Expand Down
5 changes: 5 additions & 0 deletions bin/champagne
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

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

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

# add script directory to the path to allow champagne 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())
Loading