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 c41bb4e commit 0d78d47
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0d78d47

Please sign in to comment.