From 8b749c35969e840e7b7cbd14918daa6867650cf7 Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Thu, 28 Mar 2024 22:37:16 +0100 Subject: [PATCH] try to fix get site-paclages folder for ubutnu --- tests/test_metadata.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 515350c0..1e97c864 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -10,11 +10,20 @@ def get_site_package_folder(self): for f in site.getsitepackages(): if 'site-packages' in f: return f - - def get_installed_lib_version(self, lib_name:str): + + def find_lib_folder(self, lib_name:str): dirs = [f for f in os.listdir(self.get_site_package_folder()) if f.startswith(lib_name.replace('-', '_')+'-')] if len(dirs) == 1: - metadata_file = os.path.join(sys.exec_prefix, 'Lib', 'site-packages', dirs[0], 'METADATA') + for f in os.listdir(self.get_site_package_folder()): + print(f"file in dir: {f}") + return dirs[0] + return None + + def get_installed_lib_version(self, lib_name:str): + + dir_name = self.find_lib_folder(lib_name) + if dir_name: + metadata_file = os.path.join(sys.exec_prefix, 'Lib', 'site-packages', dir_name, 'METADATA') with open(metadata_file, 'r') as f: for l in f.readlines(): if l.startswith('Version: '):