diff --git a/0001-fixup-moving-average-window.patch b/0001-fixup-moving-average-window.patch index 844a6eb..96ea569 100644 --- a/0001-fixup-moving-average-window.patch +++ b/0001-fixup-moving-average-window.patch @@ -11,7 +11,7 @@ Since the upstream default window size is only of size 10 items (by default), it calculates the average speed only for the last ~0.005s. We could enlarge the size of window (sma_window param), but the algorithm is so naive that it would decrease the -performance. +performance (O(N): sum(queue)/len(queue)). This has been discussed very extensively with upstream (PR 24 and friends) but I neither was not able to explain the problem, nor I @@ -22,36 +22,14 @@ compatibility - changes the algorithm so the average speed is calculation is fast enough, and much more stable (by default it calculates speed for window of 2 seconds). -We also don't seem to have the monotonic() mess, since we don't seem -to suffer from the same issues. - Fork with this patch backported is maintained in https://github.com/python-progress/python-progress -diff --git a/MANIFEST.in b/MANIFEST.in -index ef7c4cb..0c73842 100644 ---- a/MANIFEST.in -+++ b/MANIFEST.in -@@ -1,2 +1 @@ - include README.rst LICENSE --include test_*.py diff --git a/progress/__init__.py b/progress/__init__.py -index b434b30..71b2039 100644 +index b434b30..f26056d 100644 --- a/progress/__init__.py +++ b/progress/__init__.py -@@ -18,10 +18,7 @@ from collections import deque - from datetime import timedelta - from math import ceil - from sys import stderr --try: -- from time import monotonic --except ImportError: -- from time import time as monotonic -+from time import time - - - __version__ = '1.6' -@@ -30,19 +27,55 @@ HIDE_CURSOR = '\x1b[?25l' +@@ -30,19 +30,55 @@ HIDE_CURSOR = '\x1b[?25l' SHOW_CURSOR = '\x1b[?25h' @@ -63,7 +41,7 @@ index b434b30..71b2039 100644 + self.max_seconds = max_seconds + self.max_items = max_items + -+ stamp = time() ++ stamp = monotonic() + self.last = stamp - 0.001 + self.counter = 0 + self.deque = deque() @@ -103,30 +81,26 @@ index b434b30..71b2039 100644 def __init__(self, message='', **kwargs): self.index = 0 -- self.start_ts = monotonic() + self.start_ts = monotonic() - self.avg = 0 - self._avg_update_ts = self.start_ts - self._ts = self.start_ts - self._xput = deque(maxlen=self.sma_window) -+ self.start_ts = time() + self.window = _Window(self.sma_window_seconds, self.sma_window) for key, val in kwargs.items(): setattr(self, key, val) -@@ -67,23 +100,19 @@ class Infinite(object): - - @property +@@ -69,21 +105,17 @@ class Infinite(object): def elapsed(self): -- return int(monotonic() - self.start_ts) -+ return int(time() - self.start_ts) -+ + return int(monotonic() - self.start_ts) + + @property + def avg(self): + speed = self.window.avg + if speed: + return 1/speed -+ return 3600 # better constant? - ++ return float("inf") ++ @property def elapsed_td(self): return timedelta(seconds=self.elapsed) @@ -145,15 +119,20 @@ index b434b30..71b2039 100644 def update(self): pass -@@ -116,10 +145,7 @@ class Infinite(object): - raise AttributeError(msg) +@@ -112,14 +144,10 @@ class Infinite(object): + try: + return self.file.isatty() if self.check_tty else True + except AttributeError: +- msg = "%s has no attribute 'isatty'. Try setting check_tty=False." % self +- raise AttributeError(msg) ++ raise AttributeError('\'{}\' object has no attribute \'isatty\'. Try setting parameter check_tty=False.'.format(self)) def next(self, n=1): - now = monotonic() - dt = now - self._ts - self.update_avg(n, dt) - self._ts = now -+ self.window.next(n, time()) ++ self.window.next(n, monotonic()) self.index = self.index + n self.update() diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d9b529 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +See also automatic push/pr [Copr builds](https://copr.fedorainfracloud.org/coprs/praiskup/enterprise-ci-python-progress/). diff --git a/build-and-update-all-branches b/build-and-update-all-branches new file mode 100755 index 0000000..e52a0d7 --- /dev/null +++ b/build-and-update-all-branches @@ -0,0 +1,39 @@ +#! /bin/sh + +# Prepare main branch, review the list of branches below and then execute this +# script. + +branches='main epel8 epel9 epel10 f39 f40 f41' + +exit_handler () +{ + git checkout main +} + +trap exit_handler EXIT + +set -e +set -x + +koji hello + +tasks= +for branch in $branches; do + if test $branch != main; then + git checkout "$branch" + git merge main + fi + git push + skip_nvr_check= + if test $branch = epel7; then + skip_nvr_check=--skip-nvr-check + fi + tasks="${tasks}`fedpkg build $skip_nvr_check --nowait | grep 'Created task' | cut -d: -f2`" +done + +if test -n "$tasks"; then + koji watch-task $tasks +fi + +git checkout main +fedpkg update diff --git a/python-progress.spec b/python-progress.spec index 5b5e3ac..d8c3ee7 100644 --- a/python-progress.spec +++ b/python-progress.spec @@ -1,103 +1,125 @@ -%if 0%{?fedora} - %bcond_without python3 - %if 0%{?fedora} > 29 - %bcond_with python2 - %else - %bcond_without python2 - %endif -%else - %if 0%{?rhel} > 7 - %bcond_with python2 - %bcond_without python3 - %else - %bcond_without python2 - %bcond_with python3 - %endif -%endif - -# Created by pyp2rpm-0.5.2 %global pypi_name progress Name: python-%{pypi_name} Version: 1.6 -Release: 4%{?dist} +Release: 19%{?dist} Summary: Easy to use progress bars License: ISC URL: http://github.com/verigak/progress/ -Source0: %pypi_source +Source0: %{pypi_source %{pypi_name}} BuildArch: noarch -%if %{with python2} -BuildRequires: python2-devel -BuildRequires: python2-setuptools -%endif - -%if %{with python3} BuildRequires: python3-devel +%if %{defined el8} BuildRequires: python3-setuptools %endif Patch1: 0001-fixup-moving-average-window.patch -%global _description\ -Collection of easy to use progress bars and spinners.\ +%global _description %{expand: +Collection of easy to use progress bars and spinners.} %description %_description -%if 0%{with python2} -%package -n python2-%{pypi_name} -Summary: %summary -%{?python_provide:%python_provide python2-%{pypi_name}} - -%description -n python2-%{pypi_name} %_description -%endif # python2 - - -%if 0%{with python3} %package -n python3-%{pypi_name} Summary: Easy to use progress bars -%description -n python3-%{pypi_name} -Collection of easy to use progress bars and spinners. -%endif # python3 +%description -n python3-%{pypi_name} %_description %prep %autosetup -p1 -n %{pypi_name}-%{version} -# Remove bundled egg-info -rm -rf %{pypi_name}.egg-info + +%if %{undefined el8} +%generate_buildrequires +%pyproject_buildrequires +%endif %build -%{?with_python2: %py2_build} -%{?with_python3: %py3_build} +%if %{defined el8} +%py3_build +%else +%pyproject_wheel +%endif %install -%{?with_python2: %py2_install} -%{?with_python3: %py3_install} - - -%if 0%{with python2} -%files -n python2-%{pypi_name} -%doc README.rst LICENSE -%{python2_sitelib}/%{pypi_name} -%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info +%if %{defined el8} +%py3_install +%else +%pyproject_install +%pyproject_save_files -l %{pypi_name} %endif -%if 0%{with python3} -%files -n python3-%{pypi_name} -%doc README.rst LICENSE + +%check +%if %{defined el8} +%py3_check_import %{pypi_name} +%else +%pyproject_check_import +%endif + + +%files -n python3-%{pypi_name} %{!?el8:-f %{pyproject_files}} +%doc README.rst +%if %{defined el8} +%license LICENSE %{python3_sitelib}/%{pypi_name} %{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info %endif %changelog +* Fri Sep 19 2025 Python Maint - 1.6-19 +- Rebuilt for Python 3.14.0rc3 bytecode + +* Fri Aug 15 2025 Python Maint - 1.6-18 +- Rebuilt for Python 3.14.0rc2 bytecode + +* Fri Jul 25 2025 Fedora Release Engineering - 1.6-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Mon Jun 02 2025 Python Maint - 1.6-16 +- Rebuilt for Python 3.14 + +* Sat Jan 18 2025 Fedora Release Engineering - 1.6-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Tue Sep 24 2024 Carl George - 1.6-14 +- Convert to pyproject macros + +* Fri Jul 19 2024 Fedora Release Engineering - 1.6-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Fri Jun 07 2024 Python Maint - 1.6-12 +- Rebuilt for Python 3.13 + +* Fri Jan 26 2024 Fedora Release Engineering - 1.6-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Mon Jan 22 2024 Fedora Release Engineering - 1.6-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Jul 21 2023 Fedora Release Engineering - 1.6-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Tue Jun 13 2023 Python Maint - 1.6-8 +- Rebuilt for Python 3.12 + +* Fri Jan 20 2023 Fedora Release Engineering - 1.6-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Fri Jul 22 2022 Pavel Raiskup - 1.6-6 +- use time.monotonic(), bar.avg is infinity for zero speed + +* Fri Jul 22 2022 Fedora Release Engineering - 1.6-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Sat Jul 02 2022 Pavel Raiskup - 1.6-4 - fix for very frequent next() call, rhbz#2103093