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

Support --min-version, tool.pip-deepfreeze.min_version #141

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ Global options
python environment to work on. Defaults to the
'py' or 'python' executable found in PATH.
-r, --project-root DIRECTORY The project root directory. [default: .]
--min-version VERSION Minimum version of pip-deepfreeze required.
--version Show the version and exit.
-v, --verbose
--install-completion Install completion for the current shell.
Expand Down
3 changes: 3 additions & 0 deletions news/95.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Declare minimum pip-deepfreeze version in ``pyproject.toml``.
pip-deepfreeze verifies its version according to `tool.pip-deepfreeze.min_version`,
so a project can ensure all contributors have the minmum required version.
15 changes: 15 additions & 0 deletions src/pip_deepfreeze/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import typer
from packaging.utils import canonicalize_name
from packaging.version import Version

from .pip import Installer
from .pyproject_toml import load_pyproject_toml
Expand Down Expand Up @@ -173,6 +174,12 @@ def callback(
resolve_path=True,
help="The project root directory.",
),
min_version: Optional[str] = typer.Option(
None,
"--min-version",
metavar="VERSION",
help="Minimum version of pip-deepfreeze required.",
),
version: bool = typer.Option(
None,
"--version",
Expand All @@ -183,6 +190,14 @@ def callback(
verbose: bool = typer.Option(False, "--verbose", "-v", show_default=False),
) -> None:
"""A simple pip freeze workflow for Python application developers."""
if min_version:
current_version = importlib.metadata.version("pip-deepfreeze")
if Version(current_version) < Version(min_version):
log_error(
f"pip-deepfreeze {min_version} or later is required. "
f"Current version is {current_version}."
)
raise typer.Exit(1)
# handle verbosity/quietness
if verbose:
increase_verbosity()
Expand Down
Loading