Skip to content

Commit 7410bc4

Browse files
authored
make cli requirements optional (#16)
* make cli requirements optional * fix CI * fix ci again
1 parent 2845b8b commit 7410bc4

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"-e",
99
"GIT_EDITOR=code --wait"
1010
],
11-
"postCreateCommand": "pip3 install -e .[dev]",
11+
"postCreateCommand": "pip3 install -e .[cli,dev]",
1212
"customizations": {
1313
"vscode": {
1414
"extensions": [

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
tests:
1111
name: ${{ matrix.session }} ${{ matrix.python-version }}
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
strategy:
1414
fail-fast: false
1515
matrix:
@@ -31,7 +31,7 @@ jobs:
3131
run: pip install pip
3232

3333
- name: Setup
34-
run: pip install -e .[dev]
34+
run: pip install -e .[cli,dev]
3535

3636
- name: Run Pytest
3737
run: pytest tests

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ it's a vacuum.
2727

2828
If you have a recent version of Python 3, you should be able to
2929
do `pip install py-sucks` to get the most recently released version of
30-
this.
30+
this. In order to use the command line (cli) tool, you need to install
31+
the additional cli requirements by `pip install py-sucks[cli]`
3132

3233
## Usage
3334

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@
4848
# https://packaging.python.org/en/latest/requirements.html
4949
install_requires=[
5050
"sleekxmppfs>=1.4.1",
51-
"click>=6",
5251
"requests>=2.18",
5352
"pycryptodome>=3.4",
54-
"pycountry-convert>=0.5",
5553
],
5654
# List additional groups of dependencies here (e.g. development
5755
# dependencies). You can install these using the following syntax,
5856
# for example:
5957
# $ pip install -e .[dev,test]
6058
extras_require={
59+
"cli": ["click>=6", "pycountry-convert>=0.5"],
6160
"dev": ["pytest", "requests-mock>=1.3"],
6261
},
6362
# If there are data files included in your packages that need to be

sucks/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
import itertools
33
import os
44
import platform
5+
import sys
56
import random
67
import re
78

8-
import click
9-
from pycountry_convert import country_alpha2_to_continent_code
9+
try:
10+
import click
11+
from pycountry_convert import country_alpha2_to_continent_code
12+
except ImportError:
13+
print(
14+
"The extra dependencies are missing, "
15+
"please use 'pip install py-sucks[cli]' to install them."
16+
)
17+
sys.exit(1)
1018

1119
from sucks import *
1220

0 commit comments

Comments
 (0)