Browse Source

makepanda: Add pyenv support

Only tested on Linux with Clang

Closes #943
Mitchell Stokes 5 years ago
parent
commit
eef55f19d8
2 changed files with 28 additions and 0 deletions
  1. 4 0
      makepanda/makepanda.py
  2. 24 0
      makepanda/makepandacore.py

+ 4 - 0
makepanda/makepanda.py

@@ -1972,6 +1972,10 @@ def CompileLink(dll, obj, opts):
             if GetOrigExt(x) != ".dat":
                 cmd += ' ' + x
 
+        pyenv_prefix = GetPyenvPrefix()
+        if pyenv_prefix is not None:
+            cmd += ' -L' + os.path.join(pyenv_prefix, 'lib')
+
         if (GetOrigExt(dll) == ".exe" and GetTarget() == 'windows' and "NOICON" not in opts):
             cmd += " " + GetOutputDir() + "/tmp/pandaIcon.res"
 

+ 24 - 0
makepanda/makepandacore.py

@@ -548,6 +548,24 @@ def GetFlex():
 
     return FLEX
 
+def GetPyenvPrefix():
+    pyenv_prefix = None
+    try:
+        pyenv_prefix = subprocess.check_output(['pyenv', 'virtualenv-prefix'])
+    except subprocess.CalledProcessError:
+        pass
+
+    try:
+        if pyenv_prefix is None:
+            pyenv_prefix = subprocess.check_output(['pyenv', 'prefix'])
+    except subprocess.CalledProcessError:
+        pass
+
+    if pyenv_prefix is not None:
+        pyenv_prefix = pyenv_prefix.decode('utf8').strip()
+    return pyenv_prefix
+
+
 ########################################################################
 ##
 ## LocateBinary
@@ -3065,6 +3083,12 @@ def SetupBuildEnvironment(compiler):
             for dir in SYS_INC_DIRS:
                 print("  " + dir)
 
+    # Check to see if pyenv is being used and update SYS dirs accordingly
+    pyenv_prefix = GetPyenvPrefix()
+    if pyenv_prefix is not None:
+        SYS_LIB_DIRS.insert(0, os.path.join(pyenv_prefix, 'lib'))
+        SYS_INC_DIRS.insert(0, os.path.join(pyenv_prefix, 'include'))
+
     # If we're cross-compiling, no point in putting our output dirs on the path.
     if CrossCompiling():
         return