Skip to content

Commit

Permalink
try to fix get site-paclages folder for ubutnu
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Mar 28, 2024
1 parent 0d78d47 commit 8b749c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: '):
Expand Down

0 comments on commit 8b749c3

Please sign in to comment.