| |
@@ -31,9 +31,7 @@
|
| |
import subprocess
|
| |
import sys
|
| |
|
| |
- from dnf.rpm import basearch
|
| |
- from hawkey import detect_arch
|
| |
- from packaging import version
|
| |
+ from platform import machine as detect_arch
|
| |
|
| |
from . import ansi
|
| |
from .review_error import ReviewError
|
| |
@@ -43,6 +41,51 @@
|
| |
|
| |
SESSION_LOG = os.path.join(XdgDirs.cachedir, "fedora-review.log")
|
| |
|
| |
+ # Begin bad things
|
| |
+ # This is stolen from dnf.rpm so that we don't have to deal with importing that entire module
|
| |
+ # It also means we don't have to get a working shim for dnf/libdnf/libcomps/hawkey on PyPi
|
| |
+
|
| |
+
|
| |
+ def _invert(dct):
|
| |
+ return {v: k for k in dct for v in dct[k]}
|
| |
+
|
| |
+
|
| |
+ _BASEARCH_MAP = _invert({
|
| |
+ 'aarch64': ('aarch64',),
|
| |
+ 'alpha': ('alpha', 'alphaev4', 'alphaev45', 'alphaev5', 'alphaev56',
|
| |
+ 'alphaev6', 'alphaev67', 'alphaev68', 'alphaev7', 'alphapca56'),
|
| |
+ 'arm': ('armv5tejl', 'armv5tel', 'armv5tl', 'armv6l', 'armv7l', 'armv8l'),
|
| |
+ 'armhfp': ('armv6hl', 'armv7hl', 'armv7hnl', 'armv8hl'),
|
| |
+ 'i386': ('i386', 'athlon', 'geode', 'i386', 'i486', 'i586', 'i686'),
|
| |
+ 'ia64': ('ia64',),
|
| |
+ 'mips': ('mips',),
|
| |
+ 'mipsel': ('mipsel',),
|
| |
+ 'mips64': ('mips64',),
|
| |
+ 'mips64el': ('mips64el',),
|
| |
+ 'loongarch64': ('loongarch64',),
|
| |
+ 'noarch': ('noarch',),
|
| |
+ 'ppc': ('ppc',),
|
| |
+ 'ppc64': ('ppc64', 'ppc64iseries', 'ppc64p7', 'ppc64pseries'),
|
| |
+ 'ppc64le': ('ppc64le',),
|
| |
+ 'riscv32' : ('riscv32',),
|
| |
+ 'riscv64' : ('riscv64',),
|
| |
+ 'riscv128' : ('riscv128',),
|
| |
+ 's390': ('s390',),
|
| |
+ 's390x': ('s390x',),
|
| |
+ 'sh3': ('sh3',),
|
| |
+ 'sh4': ('sh4', 'sh4a'),
|
| |
+ 'sparc': ('sparc', 'sparc64', 'sparc64v', 'sparcv8', 'sparcv9',
|
| |
+ 'sparcv9v'),
|
| |
+ 'x86_64': ('x86_64', 'amd64', 'ia32e'),
|
| |
+ })
|
| |
+
|
| |
+
|
| |
+ def basearch(arch):
|
| |
+ # :api
|
| |
+ return _BASEARCH_MAP[arch]
|
| |
+
|
| |
+
|
| |
+ # End bad things
|
| |
|
| |
def _check_mock_grp():
|
| |
"""Raise ReviewError unless mock installation is OK."""
|
| |
This is ugly, but it's the first step on the road to being able to publish FedoraReview on PyPi. It also means you can work on FedoraReview in a venv without having to forward the system install of Python into it.
dnf
is not published onto PyPi, making it painful to work with. I did look at creating a shim package like https://github.com/packit/rpm-shim, but when I started building my fifth shim package to chase down the dependency tree, I decided that just inlining the 20 lines fromdnf
we actually use was cleaner. This does lock us out from making further use ofdnf
's Python bindings in the future, so we need to decide if that's okay.rpm
remains available if we do this.hawkey.detect_arch
is mostly just runninguname -m
(see https://github.com/rpm-software-management/hawkey/blob/hawkey-0.6.4-1/src/util.c#L118-L153), Python's builtinplatform.machine
can do that for us (see https://github.com/python/cpython/blob/v3.11.5/Lib/platform.py#L951-L958). Koji and COPR do not have any runners on the architectures which have special behaviour, so I personally think this is an acceptable compromise. Hawkey is also not available on PyPi.I'm very open to feedback on this, as it's the first PR in a series trying to modernise the Python toolchain in use, hopefully with the goal of creating something that can go on PyPi.