Bug 2235255

Summary: centpkg: unused pytz import
Product: [Fedora] Fedora Reporter: Vít Ondruch <vondruch>
Component: centpkgAssignee: Carl George 🤠 <carl>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: admiller, brian, carl, james.antill, mboddu, merlin.mathesius, sgallagh, tdawson
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: centpkg-0.8.1-2.fc39 centpkg-0.8.1-2.fc38 centpkg-0.8.1-2.fc37 centpkg-0.8.1-2.el8 centpkg-0.8.1-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-15 18:54:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vít Ondruch 2023-08-28 07:54:05 UTC
It seems I am missing some dependencies to have centpkg working:

~~~
$ centpkg
Traceback (most recent call last):
  File "/usr/bin/centpkg", line 16, in <module>
    from centpkg.__main__ import main
  File "/usr/lib/python3.12/site-packages/centpkg/__init__.py", line 27, in <module>
    from . import cli  # noqa
    ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/centpkg/cli.py", line 21, in <module>
    from centpkg.utils import config_get_safely, do_add_remote, do_fork
  File "/usr/lib/python3.12/site-packages/centpkg/utils.py", line 17, in <module>
    import pytz
ModuleNotFoundError: No module named 'pytz'
~~~



Reproducible: Always

Steps to Reproduce:
1. Execute `centpkg`
2.
3.
Actual Results:  
`centpkg` command fails

Expected Results:  
`centpkg` command succeeds

~~~
$ rpm -q centpkg
centpkg-0.7.4-4.fc40.noarch
~~~

Installing `python3-pytz` changed the error:

~~~
$ centpkg
Traceback (most recent call last):
  File "/usr/bin/centpkg", line 19, in <module>
    main()
  File "/usr/lib/python3.12/site-packages/centpkg/__main__.py", line 57, in main
    config = ConfigParser.SafeConfigParser()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
~~~

Comment 1 Carl George 🤠 2023-08-29 03:14:05 UTC
Thanks for reporting this.  It looks like the import was added here:

https://git.centos.org/centos/centpkg/c/1e7ef8239acb86e77b95756f423b6b9b04d82d55

Comment 2 Carl George 🤠 2023-08-29 03:30:29 UTC
So that import and code usage was added in version 0.7.0.  The code usage was removed in version 0.8.0, but the import was left behind.

https://git.centos.org/centos/centpkg/c/6b939c428fa8df73fe1d08157d922b9560baeb9f

I've opened a PR to correct this.

https://git.centos.org/centos/centpkg/pull-request/87

Comment 3 Troy Dawson 2023-08-29 15:24:45 UTC
Thank you for that Carl.
I thought python packages automatically got their python dependencies pulled in.  I guess that changed.
I'm going through the code some more to see if there are other un-needed imports.

Comment 4 Vít Ondruch 2023-08-29 15:29:55 UTC
(In reply to Troy Dawson from comment #3)
> I thought python packages automatically got their python dependencies pulled
> in.

I was under the same impression. Maybe it would make sense to check with somebody from Python community?

Comment 5 Carl George 🤠 2023-08-30 22:32:14 UTC
Python dependencies that are specified in the Python metadata are automatically added as RPM dependencies (except on RHEL 7).  An import statement for pytz was added to the centpkg code, but it wasn't specified as a dependency in setup.py (or more specifically requirements.txt, which setup.py parses in this case [0][1]).  The dependencies that are specified [2] have corresponding automatically generated RPM dependencies [3].

pycurl -> python3.12dist(pycurl)
cryptography -> python3.12dist(cryptography)
rpkg -> python3.12dist(rpkg)
six -> python3.12dist(six)
GitPython -> python3.12dist(gitpython)


[0] https://git.centos.org/centos/centpkg/blob/fbdb66146ca3c23542fe0e0704b963ab78b67010/f/setup.py#_42
[1] https://git.centos.org/centos/centpkg/blob/fbdb66146ca3c23542fe0e0704b963ab78b67010/f/setup.py#_3-31
[2] https://git.centos.org/centos/centpkg/blob/fbdb66146ca3c23542fe0e0704b963ab78b67010/f/requirements.txt
[3] https://koji.fedoraproject.org/koji/rpminfo?rpmID=35658947

Comment 6 Carl George 🤠 2023-09-02 04:44:32 UTC
Speaking of dependencies...

https://git.centos.org/centos/centpkg/pull-request/90

Comment 7 Fedora Update System 2023-09-07 20:42:43 UTC
FEDORA-2023-499dd2dbc8 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-499dd2dbc8

Comment 8 Fedora Update System 2023-09-07 20:42:43 UTC
FEDORA-2023-72fb583706 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-72fb583706

Comment 9 Fedora Update System 2023-09-07 20:42:44 UTC
FEDORA-EPEL-2023-258f609b2b has been submitted as an update to Fedora EPEL 8. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-258f609b2b

Comment 10 Fedora Update System 2023-09-07 20:42:44 UTC
FEDORA-2023-0c5ab13424 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-0c5ab13424

Comment 11 Fedora Update System 2023-09-07 20:42:45 UTC
FEDORA-EPEL-2023-258c46c652 has been submitted as an update to Fedora EPEL 9. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-258c46c652

Comment 12 Fedora Update System 2023-09-08 01:28:53 UTC
FEDORA-2023-499dd2dbc8 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-499dd2dbc8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-499dd2dbc8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 13 Fedora Update System 2023-09-08 01:33:37 UTC
FEDORA-2023-0c5ab13424 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-0c5ab13424`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-0c5ab13424

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2023-09-08 01:37:25 UTC
FEDORA-2023-72fb583706 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-72fb583706`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-72fb583706

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Fedora Update System 2023-09-08 02:48:09 UTC
FEDORA-EPEL-2023-258f609b2b has been pushed to the Fedora EPEL 8 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-258f609b2b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2023-09-08 02:55:23 UTC
FEDORA-EPEL-2023-258c46c652 has been pushed to the Fedora EPEL 9 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-258c46c652

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 17 Fedora Update System 2023-09-15 18:54:04 UTC
FEDORA-2023-72fb583706 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 18 Fedora Update System 2023-09-16 01:28:32 UTC
FEDORA-2023-499dd2dbc8 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Fedora Update System 2023-09-16 01:40:52 UTC
FEDORA-2023-0c5ab13424 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 20 Fedora Update System 2023-09-16 01:52:00 UTC
FEDORA-EPEL-2023-258f609b2b has been pushed to the Fedora EPEL 8 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 21 Fedora Update System 2023-09-16 02:10:53 UTC
FEDORA-EPEL-2023-258c46c652 has been pushed to the Fedora EPEL 9 stable repository.
If problem still persists, please make note of it in this bug report.