Handle removed packaging.version.LegacyVersion
This commit is contained in:
parent
af0b914623
commit
cbe01e38de
62
Handle-removed-packaging.version.LegacyVersion.patch
Normal file
62
Handle-removed-packaging.version.LegacyVersion.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From d53cf4b7b29204f34c65a875860e61e04fae98ec Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Dirk=20M=C3=BCller?= <dirk@dmllr.de>
|
||||
Date: Thu, 5 Jan 2023 09:46:40 +0100
|
||||
Subject: [PATCH] handle removed packaging.version.LegacyVersion (Fixes #83)
|
||||
sync from https://github.com/openSUSE/obs-service-set_version/commit/d53cf4b7b29204f34c65a875860e61e04fae98ec
|
||||
|
||||
This also makes it python 3.x specific, which should be fine
|
||||
---
|
||||
set_version | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/set_version b/set_version
|
||||
index d2a6925..58882c9 100755
|
||||
--- a/set_version
|
||||
+++ b/set_version
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/python
|
||||
+#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# A simple script to update version number in spec, dsc or arch linux files
|
||||
@@ -15,6 +15,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
+from contextlib import suppress
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
@@ -26,7 +27,7 @@ import codecs
|
||||
import logging
|
||||
|
||||
try:
|
||||
- from packaging.version import LegacyVersion, Version, parse
|
||||
+ from packaging.version import Version, parse
|
||||
except ImportError:
|
||||
HAS_PACKAGING = False
|
||||
import warnings
|
||||
@@ -35,6 +36,9 @@ except ImportError:
|
||||
else:
|
||||
HAS_PACKAGING = True
|
||||
|
||||
+if HAS_PACKAGING:
|
||||
+ with suppress(ImportError):
|
||||
+ from packaging.version import LegacyVersion
|
||||
|
||||
if os.environ.get('DEBUG_SET_VERSION') == "1":
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
@@ -351,8 +355,11 @@ def _version_python_pip2rpm(version_pip):
|
||||
v_rpm = v_rpm.replace('rc', '~xrc')
|
||||
v_rpm = v_rpm.replace('.dev', '~dev')
|
||||
version_rpm = v_rpm
|
||||
- elif isinstance(v, LegacyVersion):
|
||||
- # TODO(toabctl): handle setuptools style legacy version
|
||||
+ else:
|
||||
+ with suppress(NameError):
|
||||
+ if isinstance(v, LegacyVersion):
|
||||
+ # TODO(toabctl): handle setuptools style legacy version
|
||||
+ pass
|
||||
pass
|
||||
|
||||
return version_rpm
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
Name: obs-service-set_version
|
||||
Version: 0.5.14
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: Set the version in spec
|
||||
License: GPL-2.0-or-later
|
||||
Group: Development/Tools/Building
|
||||
@ -8,6 +8,7 @@ URL: https://github.com/openSUSE/obs-service-set_version
|
||||
Source: https://github.com/openSUSE/obs-service-set_version/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildArch: noarch
|
||||
patch0: Handle-removed-packaging.version.LegacyVersion.patch
|
||||
BuildRequires: python3-ddt python3-flake8 python3-packaging
|
||||
Requires: python3
|
||||
Recommends: python3-packaging
|
||||
@ -17,10 +18,9 @@ It is a service for building.You can quickly install it
|
||||
and update version in spec files.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
%build
|
||||
sed -i -e "1 s,#!/usr/bin/python$,#!%{__python3}," set_version
|
||||
|
||||
%check
|
||||
make test PYTHON=%{__python3}
|
||||
@ -36,6 +36,9 @@ install -m 0644 set_version.service %{buildroot}%{_prefix}/lib/obs/service
|
||||
%{_prefix}/lib/obs/service
|
||||
|
||||
%changelog
|
||||
* Fri May 12 2023 liyanan <thistleslyn@163.com> - 0.5.14-2
|
||||
- Handle removed packaging.version.LegacyVersion
|
||||
|
||||
* Wed Dec 29 2021 wulei <wulei80@huawei.com> - 0.5.14-1
|
||||
- DESC:package update
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user