From 0d78d47f7986d9e23a44cd490432b195d517e414 Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Thu, 28 Mar 2024 22:26:42 +0100 Subject: [PATCH] try to fix get site-paclages folder for ubutnu --- tests/test_metadata.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 16dcb15e..515350c0 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -2,11 +2,17 @@ import sys import unittest import json +import site class MetadataTest(unittest.TestCase): + 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): - dirs = [f for f in os.listdir(os.path.join(sys.exec_prefix, 'Lib', 'site-packages')) if f.startswith(lib_name.replace('-', '_')+'-')] + 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') with open(metadata_file, 'r') as f: