From 76e71def2c27d6948167a31b9644a3678277e423 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Mon, 24 Jan 2022 11:23:14 +0100 Subject: [PATCH] Add namespace option to pythodistdeps.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miro HronĨok --- python-rpm-generators.spec | 5 +++- pythondistdeps.py | 23 +++++++++++-------- .../scripts_pythondistdeps/test-data.yaml | 8 +++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/python-rpm-generators.spec b/python-rpm-generators.spec index fd88df1..fbaff88 100644 --- a/python-rpm-generators.spec +++ b/python-rpm-generators.spec @@ -1,7 +1,7 @@ Name: python-rpm-generators Summary: Dependency generators for Python RPMs Version: 12 -Release: 13%{?dist} +Release: 14%{?dist} # Originally all those files were part of RPM, so license is kept here License: GPLv2+ @@ -47,6 +47,9 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py %{_rpmconfigdir}/pythonbundles.py %changelog +* Thu Feb 10 2022 Sandro Mani - 12-14 +- Add namespace option to pythodistdeps.py to allow mingw-python generatros + * Wed Jan 26 2022 Tomas Orsava - 12-13 - From `python3-foo` packages automatically generate `python3.X-foo` Obsoletes tags on CentOS/RHEL diff --git a/pythondistdeps.py b/pythondistdeps.py index 8ae142d..92be3a5 100755 --- a/pythondistdeps.py +++ b/pythondistdeps.py @@ -326,6 +326,7 @@ def main(): parser.add_argument('--require-extras-subpackages', action='store_true', help="If there is a dependency on a package with extras functionality, require the extras subpackage") parser.add_argument('--package-name', action='store', help="Name of the RPM package that's being inspected. Required for extras requires/provides to work.") + parser.add_argument('--namespace', action='store', help="Namespace for the printed Requires, Provides, Recommends and Conflicts") parser.add_argument('files', nargs=argparse.REMAINDER, help="Files from the RPM package that are to be inspected, can also be supplied on stdin") args = parser.parse_args() @@ -374,6 +375,8 @@ def main(): package_name_parts = args.package_name.rpartition('+') extras_subpackage = package_name_parts[2].lower() or None + namespace = (args.namespace + "({})") if args.namespace else "{}" + for f in (args.files or stdin.readlines()): f = f.strip() lower = f.lower() @@ -430,31 +433,31 @@ def main(): extras_suffix = f"[{extras_subpackage}]" if extras_subpackage else "" # If egg/dist metadata says package name is python, we provide python(abi) if dist.normalized_name == 'python': - name = 'python(abi)' + name = namespace.format('python(abi)') if name not in py_deps: py_deps[name] = [] py_deps[name].append(('==', dist.py_version)) if not args.legacy or not args.majorver_only: if normalized_names_provide_legacy: - name = 'python{}dist({}{})'.format(dist.py_version, dist.legacy_normalized_name, extras_suffix) + name = namespace.format('python{}dist({}{})').format(dist.py_version, dist.legacy_normalized_name, extras_suffix) if name not in py_deps: py_deps[name] = [] if normalized_names_provide_pep503: - name_ = 'python{}dist({}{})'.format(dist.py_version, dist.normalized_name, extras_suffix) + name_ = namespace.format('python{}dist({}{})').format(dist.py_version, dist.normalized_name, extras_suffix) if name_ not in py_deps: py_deps[name_] = [] if args.majorver_provides or args.majorver_only or \ (args.majorver_provides_versions and dist.py_version in args.majorver_provides_versions): if normalized_names_provide_legacy: - pymajor_name = 'python{}dist({}{})'.format(pyver_major, dist.legacy_normalized_name, extras_suffix) + pymajor_name = namespace.format('python{}dist({}{})').format(pyver_major, dist.legacy_normalized_name, extras_suffix) if pymajor_name not in py_deps: py_deps[pymajor_name] = [] if normalized_names_provide_pep503: - pymajor_name_ = 'python{}dist({}{})'.format(pyver_major, dist.normalized_name, extras_suffix) + pymajor_name_ = namespace.format('python{}dist({}{})').format(pyver_major, dist.normalized_name, extras_suffix) if pymajor_name_ not in py_deps: py_deps[pymajor_name_] = [] if args.legacy or args.legacy_provides: - legacy_name = 'pythonegg({})({})'.format(pyver_major, dist.legacy_normalized_name) + legacy_name = namespace.format('pythonegg({})({})').format(pyver_major, dist.legacy_normalized_name) if legacy_name not in py_deps: py_deps[legacy_name] = [] if dist.version: @@ -477,7 +480,7 @@ def main(): if spec not in py_deps[legacy_name]: py_deps[legacy_name].append(spec) if args.requires or (args.recommends and dist.extras): - name = 'python(abi)' + name = namespace.format('python(abi)') # If egg/dist metadata says package name is python, we don't add dependency on python(abi) if dist.normalized_name == 'python': py_abi = False @@ -524,12 +527,12 @@ def main(): dep_normalized_name = dep.legacy_normalized_name if args.legacy: - name = 'pythonegg({})({})'.format(pyver_major, dep.legacy_normalized_name) + name = namespace.format('pythonegg({})({})').format(pyver_major, dep.legacy_normalized_name) else: if args.majorver_only: - name = 'python{}dist({}{})'.format(pyver_major, dep_normalized_name, extras_suffix) + name = namespace.format('python{}dist({}{})').format(pyver_major, dep_normalized_name, extras_suffix) else: - name = 'python{}dist({}{})'.format(dist.py_version, dep_normalized_name, extras_suffix) + name = namespace.format('python{}dist({}{})').format(dist.py_version, dep_normalized_name, extras_suffix) if dep.marker and not args.recommends and not extras_subpackage: if not dep.marker.evaluate(get_marker_env(dist, '')): diff --git a/tests/data/scripts_pythondistdeps/test-data.yaml b/tests/data/scripts_pythondistdeps/test-data.yaml index 7050e60..54e5b66 100644 --- a/tests/data/scripts_pythondistdeps/test-data.yaml +++ b/tests/data/scripts_pythondistdeps/test-data.yaml @@ -762,6 +762,14 @@ python3.9dist(simplejson) = 3.16 python3dist(simplejson) = 3.16 requires: python(abi) = 3.9 +--requires --namespace mingw64: + --provides --namespace mingw64: + usr/lib/python3.9/site-packages/taskotron_python_versions-0.1.dev6.dist-info: + provides: mingw64(python3.9dist(taskotron-python-versions)) = 0.1~~dev6 + requires: |- + mingw64(python(abi)) = 3.9 + mingw64(python3.9dist(libarchive-c)) + mingw64(python3.9dist(python-bugzilla)) --requires --console-scripts-nodep-setuptools-since 3.7: --provides --console-scripts-nodep-setuptools-since 3.6: usr/lib/python3.9/site-packages/zope.component-4.3.0-py3.9.egg-info: