Browse Source

makepanda: add --no-copy-python flag for Windows build

This will avoid copying over the python installation to the built/python directory.
rdb 7 years ago
parent
commit
94d1722c8c
1 changed files with 13 additions and 8 deletions
  1. 13 8
      makepanda/makepanda.py

+ 13 - 8
makepanda/makepanda.py

@@ -70,6 +70,7 @@ WINDOWS_SDK = None
 MSVC_VERSION = None
 MSVC_VERSION = None
 BOOUSEINTELCOMPILER = False
 BOOUSEINTELCOMPILER = False
 OPENCV_VER_23 = False
 OPENCV_VER_23 = False
+COPY_PYTHON = True
 
 
 if "MACOSX_DEPLOYMENT_TARGET" in os.environ:
 if "MACOSX_DEPLOYMENT_TARGET" in os.environ:
     OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"]
     OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"]
@@ -170,6 +171,7 @@ def parseopts(args):
     global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL
     global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL
     global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION
     global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION
     global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER
     global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER
+    global COPY_PYTHON
 
 
     # Options for which to display a deprecation warning.
     # Options for which to display a deprecation warning.
     removedopts = [
     removedopts = [
@@ -183,7 +185,7 @@ def parseopts(args):
         "version=","lzma","no-python","threads=","outputdir=","override=",
         "version=","lzma","no-python","threads=","outputdir=","override=",
         "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
         "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
         "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
         "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
-        "universal", "target=", "arch=", "git-commit=",
+        "universal", "target=", "arch=", "git-commit=", "no-copy-python",
         ] + removedopts
         ] + removedopts
 
 
     anything = 0
     anything = 0
@@ -249,6 +251,7 @@ def parseopts(args):
                 MSVC_VERSION = value.strip().lower()
                 MSVC_VERSION = value.strip().lower()
             elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True
             elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True
             elif (option=="--clean"): clean_build = True
             elif (option=="--clean"): clean_build = True
+            elif (option=="--no-copy-python"): COPY_PYTHON = False
             elif (option[2:] in removedopts):
             elif (option[2:] in removedopts):
                 Warn("Ignoring removed option %s" % (option))
                 Warn("Ignoring removed option %s" % (option))
             else:
             else:
@@ -3058,7 +3061,8 @@ if tp_dir is not None:
                 CopyFile(GetOutputDir() + "/bin/", fn)
                 CopyFile(GetOutputDir() + "/bin/", fn)
 
 
             # Copy the whole Python directory.
             # Copy the whole Python directory.
-            CopyTree(GetOutputDir() + "/python", SDK["PYTHON"])
+            if COPY_PYTHON:
+                CopyTree(GetOutputDir() + "/python", SDK["PYTHON"])
 
 
             # NB: Python does not always ship with the correct manifest/dll.
             # NB: Python does not always ship with the correct manifest/dll.
             # Figure out the correct one to ship, and grab it from WinSxS dir.
             # Figure out the correct one to ship, and grab it from WinSxS dir.
@@ -3067,7 +3071,7 @@ if tp_dir is not None:
                 os.unlink(manifest)
                 os.unlink(manifest)
             oscmd('mt -inputresource:"%s\\python.exe";#1 -out:"%s" -nologo' % (SDK["PYTHON"], manifest), True)
             oscmd('mt -inputresource:"%s\\python.exe";#1 -out:"%s" -nologo' % (SDK["PYTHON"], manifest), True)
 
 
-            if os.path.isfile(manifest):
+            if COPY_PYTHON and os.path.isfile(manifest):
                 import xml.etree.ElementTree as ET
                 import xml.etree.ElementTree as ET
                 tree = ET.parse(manifest)
                 tree = ET.parse(manifest)
                 idents = tree.findall('./{urn:schemas-microsoft-com:asm.v1}dependency/{urn:schemas-microsoft-com:asm.v1}dependentAssembly/{urn:schemas-microsoft-com:asm.v1}assemblyIdentity')
                 idents = tree.findall('./{urn:schemas-microsoft-com:asm.v1}dependency/{urn:schemas-microsoft-com:asm.v1}dependentAssembly/{urn:schemas-microsoft-com:asm.v1}assemblyIdentity')
@@ -3097,11 +3101,12 @@ if tp_dir is not None:
                     CopyFile(GetOutputDir() + "/python/", file)
                     CopyFile(GetOutputDir() + "/python/", file)
 
 
             # Copy python.exe to ppython.exe.
             # Copy python.exe to ppython.exe.
-            if not os.path.isfile(SDK["PYTHON"] + "/ppython.exe") and os.path.isfile(SDK["PYTHON"] + "/python.exe"):
-                CopyFile(GetOutputDir() + "/python/ppython.exe", SDK["PYTHON"] + "/python.exe")
-            if not os.path.isfile(SDK["PYTHON"] + "/ppythonw.exe") and os.path.isfile(SDK["PYTHON"] + "/pythonw.exe"):
-                CopyFile(GetOutputDir() + "/python/ppythonw.exe", SDK["PYTHON"] + "/pythonw.exe")
-            ConditionalWriteFile(GetOutputDir() + "/python/panda.pth", "..\n../bin\n")
+            if COPY_PYTHON:
+                if not os.path.isfile(SDK["PYTHON"] + "/ppython.exe") and os.path.isfile(SDK["PYTHON"] + "/python.exe"):
+                    CopyFile(GetOutputDir() + "/python/ppython.exe", SDK["PYTHON"] + "/python.exe")
+                if not os.path.isfile(SDK["PYTHON"] + "/ppythonw.exe") and os.path.isfile(SDK["PYTHON"] + "/pythonw.exe"):
+                    CopyFile(GetOutputDir() + "/python/ppythonw.exe", SDK["PYTHON"] + "/pythonw.exe")
+                ConditionalWriteFile(GetOutputDir() + "/python/panda.pth", "..\n../bin\n")
 
 
 # Copy over the MSVC runtime.
 # Copy over the MSVC runtime.
 if GetTarget() == 'windows' and "VISUALSTUDIO" in SDK:
 if GetTarget() == 'windows' and "VISUALSTUDIO" in SDK: