Skip to content

Commit

Permalink
Fix python's lib folder search on virtualenv
Browse files Browse the repository at this point in the history
the current way to find it looks for a file that was changed after a
refactor `virtualenv` had
  • Loading branch information
DjLegolas committed Oct 25, 2024
1 parent b99ae87 commit 0fd04f9
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions gvsbuild/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,37 @@ def python_find_libs_dir(org_dir):
# easy :)
return cur

org_found = False
# look for the virtualenv marker
chk = os.path.join(org_dir, "lib")
if not os.path.isdir(chk):
pyvenv_file = os.path.join(org_dir, "pyvenv.cfg")
if not os.path.isfile(pyvenv_file):
# one level up
chk = os.path.join(org_dir, "..", "lib")

if not chk:
# oops
return None
pyvenv_file = os.path.join(org_dir, "..", "pyvenv.cfg")

if os.path.isfile(pyvenv_file):
# Read file to get home path
for line in read_file(pyvenv_file):
key, value = line.split("=")
if "home" == key.strip():
org_dir = value.strip()
org_found = True
break

orig_file = os.path.join(chk, "orig-prefix.txt")
if os.path.isfile(orig_file):
# Read and see what's happening
org_dir = pathlib.Path(orig_file).read_text()
if not org_found:
# look for the virtualenv marker (legacy)
chk = os.path.join(org_dir, "lib")
if not os.path.isdir(chk):
# one level up
chk = os.path.join(org_dir, "..", "lib")

if not chk:
# oops
return None

orig_file = os.path.join(chk, "orig-prefix.txt")
if os.path.isfile(orig_file):
# Read and see what's happening
org_dir = pathlib.Path(orig_file).read_text()
# Let's see if now is ok ..
cur = os.path.join(org_dir, "libs")
return cur if os.path.isdir(cur) else None

0 comments on commit 0fd04f9

Please sign in to comment.