PBR

version_string() and semantic_version() etc is slow

Bug #1866991 reported by Racz Benedek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
New
Undecided
Unassigned

Bug Description

Problem
^^^^^^^

If a particular package is *not* installed (with pip) just cloned, the version_string() (and similar methods) are really slow.

Reproduce:
^^^^^^^^^^

Choose an arbitrary python package, which uses pbr. I tested with scrapd and wexpect.

Type following commands into Windows' cmd:

```console
mkdir slow_pbr
cd slow_pbr
python -m virtualenv slow_pbr_virtualenv
slow_pbr_virtualenv\Scripts\activate
git clone https://github.com/scrapd/scrapd.git
cd scrapd
python -m pip install -r requirements.txt

python
# The following commands are python commands:
import scrapd
from pbr.version import VersionInfo
a = VersionInfo('scrapd')
a.version_string() # <--- This command is really slow. It takes several secs.
```

Here is my full transcript:

```console
Microsoft Windows [Version 10.0.18363.657]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\usr>mkdir slow_pbr

C:\Users\usr>cd slow_pbr

C:\Users\usr\slow_pbr>python -m virtualenv slow_pbr_virtualenv
Using base prefix 'C:\\Program Files\\Python37'
New python executable in C:\Users\usr\slow_pbr\slow_pbr_virtualenv\Scripts\python.exe
Installing setuptools, pip, wheel...
done.

C:\Users\usr\slow_pbr>slow_pbr_virtualenv\Scripts\activate

(slow_pbr_virtualenv) C:\Users\usr\slow_pbr>git clone https://github.com/scrapd/scrapd.git
Cloning into 'scrapd'...
remote: Enumerating objects: 190, done.
remote: Counting objects: 100% (190/190), done.
remote: Compressing objects: 100% (89/89), done.
remote: Total 1927 (delta 119), reused 139 (delta 95), pack-reused 1737
Receiving objects: 100% (1927/1927), 905.79 KiB | 2.58 MiB/s, done.
Resolving deltas: 100% (1278/1278), done.

(slow_pbr_virtualenv) C:\Users\usr\slow_pbr>python -m pip install -r scrapd\requirements.txt
Collecting aiohttp==3.6.1
  Downloading aiohttp-3.6.1-cp37-cp37m-win_amd64.whl (617 kB)
     |████████████████████████████████| 617 kB 1.7 MB/s
Collecting beautifulsoup4==4.8.1
  Downloading beautifulsoup4-4.8.1-py3-none-any.whl (101 kB)
     |████████████████████████████████| 101 kB 5.7 MB/s
Collecting click==7.0
  Using cached Click-7.0-py2.py3-none-any.whl (81 kB)
Collecting dateparser==0.7.2
  Downloading dateparser-0.7.2-py2.py3-none-any.whl (352 kB)
     |████████████████████████████████| 352 kB ...
Collecting loguru==0.3.2
  Downloading loguru-0.3.2-py3-none-any.whl (44 kB)
     |████████████████████████████████| 44 kB 770 kB/s
Collecting pbr>=5.2.0
  Using cached pbr-5.4.4-py2.py3-none-any.whl (110 kB)
Collecting pydantic==0.32.2
  Downloading pydantic-0.32.2-py36.py37.py38-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 4.5 MB/s
Collecting tenacity==5.1.1
  Downloading tenacity-5.1.1-py2.py3-none-any.whl (34 kB)
Collecting async-timeout<4.0,>=3.0
  Downloading async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.4.2-cp37-cp37m-win_amd64.whl (125 kB)
     |████████████████████████████████| 125 kB ...
Collecting attrs>=17.3.0
  Downloading attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting chardet<4.0,>=2.0
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting multidict<5.0,>=4.5
  Downloading multidict-4.7.5-cp37-cp37m-win_amd64.whl (48 kB)
     |████████████████████████████████| 48 kB ...
Collecting soupsieve>=1.2
  Downloading soupsieve-2.0-py2.py3-none-any.whl (32 kB)
Collecting regex
  Downloading regex-2020.2.20-cp37-cp37m-win_amd64.whl (271 kB)
     |████████████████████████████████| 271 kB 6.4 MB/s
Collecting tzlocal
  Downloading tzlocal-2.0.0-py2.py3-none-any.whl (15 kB)
Collecting python-dateutil
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB ...
Collecting pytz
  Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB)
Collecting colorama>=0.3.4; sys_platform == "win32"
  Using cached colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting win32-setctime>=1.0.0; sys_platform == "win32"
  Downloading win32_setctime-1.0.1-py3-none-any.whl (3.4 kB)
Collecting six>=1.9.0
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting idna>=2.0
  Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.7 MB/s
Installing collected packages: async-timeout, idna, multidict, yarl, attrs, chardet, aiohttp, soupsieve, beautifulsoup4, click, regex, pytz, tzlocal, six, python-dateutil, dateparser, colorama, win32-setctime, loguru, pbr, pydantic, tenacity
Successfully installed aiohttp-3.6.1 async-timeout-3.0.1 attrs-19.3.0 beautifulsoup4-4.8.1 chardet-3.0.4 click-7.0 colorama-0.4.3 dateparser-0.7.2 idna-2.9 loguru-0.3.2 multidict-4.7.5 pbr-5.4.4 pydantic-0.32.2 python-dateutil-2.8.1 pytz-2019.3 regex-2020.2.20 six-1.14.0 soupsieve-2.0 tenacity-5.1.1 tzlocal-2.0.0 win32-setctime-1.0.1 yarl-1.4.2

(slow_pbr_virtualenv) C:\Users\usr\slow_pbr>cd scrapd

(slow_pbr_virtualenv) C:\Users\usr\slow_pbr\scrapd>python
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scarpd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scarpd'
>>> import scrapd
>>> from pbr.version import VersionInfo
>>> a =VersionInfo('scrapd')
>>> a.version_string()
'3.0.5'
```

I use:
^^^^^^
 - Win 10.0.18363 Build 18363
 - Python 3.7.5
 - pbr 5.4.4

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.