Bug 2162667

Summary: scapy version doesn't comply with pep-0440: Invalid version: 'git-archive.dev95ba5b8504'
Product: Red Hat Enterprise Linux 9 Reporter: Flavio Leitner <fleitner>
Component: scapyAssignee: Andrea Claudi <aclaudi>
Status: VERIFIED --- QA Contact: Li Shuang <shuali>
Severity: high Docs Contact:
Priority: high    
Version: CentOS StreamCC: bstinson, i.maximets, jwboyer, rjarry, shuali
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: scapy-2.5.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Flavio Leitner 2023-01-20 12:42:06 UTC
The current scapy version uses dash '-' in its version which doesn't comply with https://peps.python.org/pep-0440/ and that breaks any python project using setuptools.

See the example below:
01:13:09 + git clone https://github.com/chaudron/XenaPythonLib.git /ovsci/xena
01:13:09 Cloning into '/ovsci/xena'...
01:13:09 + cd /ovsci/xena
01:13:09 + python3 setup.py install
01:13:09 Traceback (most recent call last):
01:13:09   File "/ovsci/xena/setup.py", line 3, in <module>
01:13:09     setup(name='xenalib-python',
01:13:09   File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 86, in setup
01:13:09     _install_setup_requires(attrs)
01:13:09   File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 80, in _install_setup_requires
01:13:09     dist.fetch_build_eggs(dist.setup_requires)
01:13:09   File "/usr/local/lib/python3.9/site-packages/setuptools/dist.py", line 874, in fetch_build_eggs
01:13:09     resolved_dists = pkg_resources.working_set.resolve(
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 815, in resolve
01:13:09     dist = self._resolve_dist(
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 844, in _resolve_dist
01:13:09     env = Environment(self.entries)
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1044, in __init__
01:13:09     self.scan(search_path)
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1077, in scan
01:13:09     self.add(dist)
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1096, in add
01:13:09     dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2631, in hashcmp
01:13:09     self.parsed_version,
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2678, in parsed_version
01:13:09     self._parsed_version = parse_version(self.version)
01:13:09   File "/usr/local/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/version.py", line 266, in __init__
01:13:09     raise InvalidVersion(f"Invalid version: '{version}'")
01:13:09 pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'git-archive.dev95ba5b8504'


[root@wsfd-advnetlab71 ~]# rpm -ql python3-scapy-2.4.4-5.el9.noarch  | grep git
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/PKG-INFO
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/SOURCES.txt
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/dependency_links.txt
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/entry_points.txt
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/not-zip-safe
/usr/lib/python3.9/site-packages/scapy-git_archive.dev95ba5b8504-py3.9.egg-info/top_level.txt
[root@wsfd-advnetlab71 ~]# rpm -q --provides python3-scapy-2.4.4-5.el9.noarch | grep git-
python3.9dist(scapy) = git-archive.dev95ba5b8504
python3dist(scapy) = git-archive.dev95ba5b8504

Comment 1 Robin Jarry 2023-01-20 12:44:13 UTC
I am working on an upstream patch to allow forcing a version when doing downstream packaging from a non-tagged git archive. I'll update this BZ when ready.

Comment 2 Andrea Claudi 2023-01-20 13:14:23 UTC
Thanks Robin. Let me know when you're done, so I can backport your fix to the RHEL package.

Comment 3 Robin Jarry 2023-01-20 16:16:06 UTC
Here's the pull request: https://github.com/secdev/scapy/pull/3862

Comment 4 Robin Jarry 2023-02-14 21:10:27 UTC
Hi Andrea. The fix was applied upstream. Let me know if I can help with the RHEL package.