fix: migrates pkg_resources.working_set; removes commented test
This commit is contained in:
parent
aee6a61102
commit
2cabe6569c
2 changed files with 17 additions and 32 deletions
|
|
@ -15,8 +15,7 @@
|
|||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
|
@ -25,7 +24,6 @@ import collections
|
|||
import psutil
|
||||
from functools import wraps
|
||||
|
||||
import pkg_resources
|
||||
import logging
|
||||
import resource
|
||||
|
||||
|
|
@ -162,7 +160,22 @@ def python_info():
|
|||
|
||||
@register_sysinfo
|
||||
def py_modules():
|
||||
mods = dict([(p.project_name, {"version": p.version, "location": p.location}) for p in pkg_resources.working_set])
|
||||
mods = {
|
||||
d.metadata.get("Name"): {
|
||||
"version": d.version,
|
||||
"location": str(
|
||||
next(
|
||||
(
|
||||
p.locate().parent.parent
|
||||
for p in (d.files or [])
|
||||
if p.parent.name.endswith((".dist-info", ".egg-info"))
|
||||
),
|
||||
next(iter(d.files)).locate().parent if d.files else None,
|
||||
)
|
||||
),
|
||||
}
|
||||
for d in importlib.metadata.distributions()
|
||||
}
|
||||
|
||||
value = sorted(mods.items(), key=lambda k: k[0].lower())
|
||||
return SysInfoRes(value=value)
|
||||
|
|
|
|||
|
|
@ -41,31 +41,3 @@ class TestPkgResourcesLibMigrations:
|
|||
migrated_res = importlib.resources.files(module).joinpath(path).read_bytes()
|
||||
|
||||
assert res == migrated_res
|
||||
|
||||
# def test_pkg_resources_working_set_lib_migration(self):
|
||||
# mods = dict(
|
||||
# [(p.project_name, {"version": p.version, "location": p.location}) for p in pkg_resources.working_set]
|
||||
# )
|
||||
#
|
||||
# migration_mods = {
|
||||
# d.metadata.get("Name"): {
|
||||
# "version": d.version,
|
||||
# "location": str(
|
||||
# next(
|
||||
# (
|
||||
# p.locate().parent.parent
|
||||
# for p in (d.files or [])
|
||||
# if p.parent.name.endswith((".dist-info", ".egg-info"))
|
||||
# ),
|
||||
# next(iter(d.files)).locate().parent if d.files else None,
|
||||
# )
|
||||
# ),
|
||||
# }
|
||||
# for d in importlib.metadata.distributions()
|
||||
# }
|
||||
#
|
||||
# mods_keys = sorted(list(mods.keys()))
|
||||
# migration_mods_keys = sorted(list(migration_mods.keys()))
|
||||
#
|
||||
# assert len(mods_keys) == len(migration_mods_keys)
|
||||
# assert mods_keys == migration_mods_keys
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue