| |
@@ -13,10 +13,10 @@
|
| |
|
| |
from __future__ import print_function
|
| |
import argparse
|
| |
- from distutils.sysconfig import get_python_lib
|
| |
from os.path import dirname, sep
|
| |
import re
|
| |
- from sys import argv, stdin, stderr
|
| |
+ from sys import argv, stdin, stderr, version_info
|
| |
+ from sysconfig import get_path
|
| |
from warnings import warn
|
| |
|
| |
from packaging.requirements import Requirement as Requirement_
|
| |
@@ -341,8 +341,9 @@
|
| |
if py_abi and (lower.endswith('.py') or lower.endswith('.pyc') or lower.endswith('.pyo')):
|
| |
if name not in py_deps:
|
| |
py_deps[name] = []
|
| |
- purelib = get_python_lib(standard_lib=0, plat_specific=0).split(version[:3])[0]
|
| |
- platlib = get_python_lib(standard_lib=0, plat_specific=1).split(version[:3])[0]
|
| |
+ running_python_version = '{}.{}'.format(*version_info[:2])
|
| |
+ purelib = get_path('purelib').split(running_python_version)[0]
|
| |
+ platlib = get_path('platlib').split(running_python_version)[0]
|
| |
for lib in (purelib, platlib):
|
| |
if lib in f:
|
| |
spec = ('==', f.split(lib)[1].split(sep)[0])
|
| |
There were three problems:
We were not hit by the missing import in Fedora because we only run the script
on .dist-info/.egg-info/.egg and not on .py files, so this if-branch never runs.
But when the script was fed with a .py path, it errored:
The sys.version[:3] thing kinda works for Python 3.10+ because in this
particular case splitting on '3.1' and taking the prefix yields the same
results as splitting on '3.10', but I consider that mere coincidence.
Finally, since the distutils import happened at module-level,
we got the Deprecation warning in all Fedora's Python packages:
Backported from https://github.com/rpm-software-management/python-rpm-packaging/commit/d12e039037