Skip to content

fix: make click a truly optional dependency of the s7 command - #954

Closed
rshanor wants to merge 2 commits into
gijzelaerr:masterfrom
rshanor:cli-optional-click
Closed

rshanor wants to merge 2 commits into
gijzelaerr:masterfrom
rshanor:cli-optional-click

Conversation

@rshanor

@rshanor rshanor commented Oct 19, 2026

Copy link
Copy Markdown

click is listed as the optional cli extra, but the s7 console script is always installed. On a plain pip install python-snap7, running s7 fails with an ImportError traceback from snap7.cli. Downstream packagers, such as the conda-forge recipe being added, then have to make click a hard dependency to keep the installed script working.

This points the s7 entry point at a small wrapper, snap7._console:main. The wrapper checks for click before importing snap7.cli:

  • Without click, s7 prints Install them with: pip install python-snap7[cli] to stderr and exits with status 1.
  • With click, behaviour is unchanged.

snap7.cli itself is unchanged, so from snap7.cli import main and python -m snap7.cli work as before.

Testing

  • New tests/test_console.py covers both paths: click missing, and click present.
  • Manual check in a fresh venv with pip install . (no click): s7 --help prints the hint and exits 1. With [cli] installed it shows the normal help.
  • uv run pre-commit run --all-files passes, including mypy and ruff.
  • pytest -m "server or util or client or mainloop": all pass except test_get_pg_block_info. That test also fails on unmodified master when run in a US timezone (b'2019/06/26' != b'2019/06/27') and passes with TZ=UTC, so it is unrelated to this change.

@rshanor rshanor closed this Oct 19, 2026
@rshanor
rshanor deleted the cli-optional-click branch October 19, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant