Skip to content

Commit

Permalink
Make progress_bar an extra feature
Browse files Browse the repository at this point in the history
This allows the 'rich' dependency, which has additional dependencies and
is not available in RHEL, to be optional.

Fixes: #360

Signed-off-by: Yaakov Selkowitz <[email protected]>
  • Loading branch information
yselkowitz committed Jan 3, 2024
1 parent 3b62766 commit ea85c5f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
14 changes: 13 additions & 1 deletion podman/domain/images_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import urllib.parse
from typing import Any, Dict, Generator, Iterator, List, Mapping, Optional, Union
import requests
from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn

from podman import api
from podman.api import Literal
Expand All @@ -17,6 +16,17 @@
from podman.domain.registry_data import RegistryData
from podman.errors import APIError, ImageNotFound

try:
from rich.progress import (
Progress,
TextColumn,
BarColumn,
TaskProgressColumn,
TimeRemainingColumn,
)
except (ImportError, ModuleNotFoundError):
Progress = None

logger = logging.getLogger("podman.images")


Expand Down Expand Up @@ -314,6 +324,8 @@ def pull(
# progress bar
progress_bar = kwargs.get("progress_bar", False)
if progress_bar:
if Progress is None:
raise ModuleNotFoundError('progress_bar requires \'rich.progress\' module')
params["compatMode"] = True
stream = True

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ sphinx
tomli>=1.2.3; python_version<'3.11'
urllib3
wheel
rich >= 12.5.1
6 changes: 6 additions & 0 deletions rpm/python-podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ export PBR_VERSION="0.0.0"
%pyproject_save_files %{pypi_name}
%endif

%if !%{defined rhel8_py}
%check
%pyproject_check_import -e podman.api.typing_extensions
%endif

%if %{defined rhel8_py}
%files -n python%{python3_pkgversion}-%{pypi_name}
%dir %{python3_sitelib}/%{pypi_name}-*-py%{python3_version}.egg-info
%{python3_sitelib}/%{pypi_name}-*-py%{python3_version}.egg-info/*
%dir %{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}/*
%else
%pyproject_extras_subpkg -n python%{python3_pkgversion}-%{pypi_name} progress_bar
%files -n python%{python3_pkgversion}-%{pypi_name} -f %{pyproject_files}
%endif
%license LICENSE
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ install_requires =
requests >=2.24
tomli>=1.2.3; python_version<'3.11'
urllib3

[options.extras_require]
progress_bar =
rich >= 12.5.1

# typing_extensions are included for RHEL 8.5
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ pylint
pytest
requests-mock >= 1.11.0
tox
rich >= 12.5.1

0 comments on commit ea85c5f

Please sign in to comment.