Skip to content

Commit fa25b38

Browse files
committed
Add --min-version
1 parent a65f5e8 commit fa25b38

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Global options
298298
python environment to work on. Defaults to the
299299
'py' or 'python' executable found in PATH.
300300
-r, --project-root DIRECTORY The project root directory. [default: .]
301+
--min-version VERSION Minimum version of pip-deepfreeze required.
301302
--version Show the version and exit.
302303
-v, --verbose
303304
--install-completion Install completion for the current shell.

news/95.feature

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Declare minimum pip-deepfreeze version in ``pyproject.toml``.
2+
pip-deepfreeze verifies its version according to `tool.pip-deepfreeze.min_version`,
3+
so a project can ensure all contributors have the minmum required version.

src/pip_deepfreeze/__main__.py

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import typer
77
from packaging.utils import canonicalize_name
8+
from packaging.version import Version
89

910
from .pip import Installer
1011
from .pyproject_toml import load_pyproject_toml
@@ -173,6 +174,12 @@ def callback(
173174
resolve_path=True,
174175
help="The project root directory.",
175176
),
177+
min_version: Optional[str] = typer.Option(
178+
None,
179+
"--min-version",
180+
metavar="VERSION",
181+
help="Minimum version of pip-deepfreeze required.",
182+
),
176183
version: bool = typer.Option(
177184
None,
178185
"--version",
@@ -183,6 +190,14 @@ def callback(
183190
verbose: bool = typer.Option(False, "--verbose", "-v", show_default=False),
184191
) -> None:
185192
"""A simple pip freeze workflow for Python application developers."""
193+
if min_version:
194+
current_version = importlib.metadata.version("pip-deepfreeze")
195+
if Version(current_version) < Version(min_version):
196+
log_error(
197+
f"pip-deepfreeze {min_version} or later is required. "
198+
f"Current version is {current_version}."
199+
)
200+
raise typer.Exit(1)
186201
# handle verbosity/quietness
187202
if verbose:
188203
increase_verbosity()

0 commit comments

Comments
 (0)