Skip to content

Commit

Permalink
Enable shell extra for installing ptpython and rich (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: Teemu R. <tpr@iki.fi>
  • Loading branch information
sdb9696 and rytilahti committed Feb 20, 2024
1 parent 5ba3676 commit 4beff22
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ jobs:
- uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies (no speedups)"
- name: "Install dependencies (no extras)"
if: matrix.extras == false
run: |
python -m pip install --upgrade pip poetry
poetry install
- name: "Install dependencies (with speedups)"
- name: "Install dependencies (with extras)"
if: matrix.extras == true
run: |
python -m pip install --upgrade pip poetry
poetry install --extras speedups
poetry install --all-extras
- name: "Run tests"
run: |
poetry run pytest --cov kasa --cov-report xml
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ You can install the most recent release using pip:
pip install python-kasa
```

For enhanced cli tool support (coloring, embedded shell) install with `[shell]`:
```
pip install python-kasa[shell]
```

If you are using cpython, it is recommended to install with `[speedups]` to enable orjson (faster json support):
```
pip install python-kasa[speedups]
```

or for both:
```
pip install python-kasa[speedups, shell]
```
With `[speedups]`, the protocol overhead is roughly an order of magnitude lower (benchmarks available in devtools).

Alternatively, you can clone this repository and use poetry to install the development version:
Expand Down
2 changes: 1 addition & 1 deletion kasa/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ async def test_errors(mocker):
assert res.exit_code == 1
assert (
"Raised error: Managed to invoke callback without a context object of type 'Device' existing."
in res.output
in res.output.replace("\n", "") # Remove newlines from rich formatting
)
assert isinstance(res.exception, SystemExit)

Expand Down
115 changes: 113 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ sphinxcontrib-programoutput = { version = "^0", optional = true }
myst-parser = { version = "*", optional = true }
docutils = { version = ">=0.17", optional = true }

# shell support
# ptpython = { version = "*", optional = true }
# enhanced cli support
ptpython = { version = "*", optional = true }
rich = { version = "*", optional = true }

[tool.poetry.group.dev.dependencies]
pytest = "*"
Expand All @@ -60,7 +61,7 @@ coverage = {version = "*", extras = ["toml"]}
[tool.poetry.extras]
docs = ["sphinx", "sphinx_rtd_theme", "sphinxcontrib-programoutput", "myst-parser", "docutils"]
speedups = ["orjson", "kasa-crypt"]
# shell = ["ptpython"]
shell = ["ptpython", "rich"]

[tool.coverage.run]
source = ["kasa"]
Expand Down

0 comments on commit 4beff22

Please sign in to comment.