From da6d5f442cee7395a17fac8e49347126065b2003 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 20 Nov 2015 00:56:31 +0100 Subject: [PATCH 1/3] Don't require setting system PATH to import panda3d.* (backport from master) --- makepanda/makepanda.py | 35 ++++++++++++++++++++++++++++++++++- makepanda/makepandacore.py | 3 +-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0bf937f683..020dafab45 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1790,7 +1790,7 @@ def RunGenPyCode(target, inputs, opts): if (PkgSkip("PYTHON") != 0): return - cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"]) + " " + cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"].replace('\\', '/')) + " " if sys.version_info >= (2, 6): cmdstr += "-B " @@ -2591,6 +2591,39 @@ if (PkgSkip("DIRECT")==0): if os.path.isfile(GetOutputDir() + '/direct/ffi/panda3d.pyc'): os.remove(GetOutputDir() + '/direct/ffi/panda3d.pyc') +# These files used to exist; remove them to avoid conflicts. +del_files = ['core.py', 'core.pyc', 'core.pyo', + '_core.pyd', '_core.so', + 'direct.py', 'direct.pyc', 'direct.pyo', + '_direct.pyd', '_direct.so'] + +for basename in del_files: + path = os.path.join(GetOutputDir(), 'panda3d', basename) + if os.path.isfile(path): + print("Removing %s" % (path)) + os.remove(path) + +# Write an appropriate panda3d/__init__.py +p3d_init = """"Python bindings for the Panda3D libraries" +""" + +if GetTarget() == 'windows': + p3d_init += """ +import os + +bindir = os.path.join(os.path.dirname(__file__), '..', 'bin') +if os.path.isfile(os.path.join(bindir, 'libpanda.dll')): + if not os.environ.get('PATH'): + os.environ['PATH'] = bindir + else: + os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH'] + +del os, bindir +""" + +if not PkgSkip("PYTHON"): + ConditionalWriteFile(GetOutputDir() + '/panda3d/__init__.py', p3d_init) + ########################################################################################## # # Generate the PRC files into the ETC directory. diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index f14179fb84..41c0c941eb 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1061,7 +1061,6 @@ def MakeBuildTree(): MakeDirectory(OUTPUTDIR + "/pandac") MakeDirectory(OUTPUTDIR + "/pandac/input") MakeDirectory(OUTPUTDIR + "/panda3d") - CreateFile(OUTPUTDIR + "/panda3d/__init__.py") if GetTarget() == 'darwin': MakeDirectory(OUTPUTDIR + "/Frameworks") @@ -2423,7 +2422,7 @@ def SetupBuildEnvironment(compiler): return # Add our output directories to the environment. - builtdir = os.path.join(os.path.abspath(GetOutputDir())) + builtdir = GetOutputDir() AddToPathEnv("PYTHONPATH", builtdir) AddToPathEnv("PANDA_PRC_DIR", os.path.join(builtdir, "etc")) AddToPathEnv("PATH", os.path.join(builtdir, "bin")) From 7fa407a1186c4384bd2e3b77f064531e4ddadc2c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 20 Nov 2015 02:05:18 +0100 Subject: [PATCH 2/3] Add code to locate June 2010 DirectX SDK outside of the registry --- makepanda/makepandacore.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 41c0c941eb..fa3746b181 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1704,6 +1704,18 @@ def SdkLocateDirectX( strMode = 'default' ): print("Using DirectX SDK June 2010") SDK["DX9"] = dir.replace("\\", "/").rstrip("/") SDK["GENERIC_DXERR_LIBRARY"] = 1; + if ("DX9" not in SDK): + dir = "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)" + if os.path.isdir(dir): + print("Using DirectX SDK June 2010") + SDK["DX9"] = dir + SDK["GENERIC_DXERR_LIBRARY"] = 1 + if ("DX9" not in SDK): + dir = "C:/Program Files/Microsoft DirectX SDK (June 2010)" + if os.path.isdir(dir): + print("Using DirectX SDK June 2010") + SDK["DX9"] = dir + SDK["GENERIC_DXERR_LIBRARY"] = 1 if ("DX9" not in SDK): dir = GetRegistryKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX\\Microsoft DirectX SDK (August 2009)", "InstallPath") if (dir != 0): @@ -1738,21 +1750,32 @@ def SdkLocateDirectX( strMode = 'default' ): SDK["DX9"] = dir.replace("\\", "/").rstrip("/") if ("DX9" not in SDK): return + elif strMode == 'jun2010': if ("DX9" not in SDK): dir = GetRegistryKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX\\Microsoft DirectX SDK (June 2010)", "InstallPath") if (dir != 0): - print("Found DirectX SDK June 2010") SDK["DX9"] = dir.replace("\\", "/").rstrip("/") SDK["GENERIC_DXERR_LIBRARY"] = 1; if ("DX9" not in SDK): dir = GetRegistryKey("SOFTWARE\\Microsoft\\DirectX\\Microsoft DirectX SDK (June 2010)", "InstallPath") if (dir != 0): - print("Found DirectX SDK June 2010") SDK["DX9"] = dir.replace("\\", "/").rstrip("/") SDK["GENERIC_DXERR_LIBRARY"] = 1; + if ("DX9" not in SDK): + dir = "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)" + if os.path.isdir(dir): + SDK["DX9"] = dir + SDK["GENERIC_DXERR_LIBRARY"] = 1 + if ("DX9" not in SDK): + dir = "C:/Program Files/Microsoft DirectX SDK (June 2010)" + if os.path.isdir(dir): + SDK["DX9"] = dir + SDK["GENERIC_DXERR_LIBRARY"] = 1 if ("DX9" not in SDK): exit("Couldn't find DirectX June2010 SDK") + else: + print("Found DirectX SDK June 2010") elif strMode == 'aug2009': if ("DX9" not in SDK): dir = GetRegistryKey("SOFTWARE\\Wow6432Node\\Microsoft\\DirectX\\Microsoft DirectX SDK (August 2009)", "InstallPath") From d3885b665eb223465fa3a9a7ad9f4cf7780fc1a5 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 20 Nov 2015 02:05:44 +0100 Subject: [PATCH 3/3] Fix static MAKE_SEQs (eg WebcamVideo.get_options(), MicrophoneAudio.get_options()) --- .../interfaceMakerPythonNative.cxx | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 1d5520470c..181bbb80f5 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -6114,27 +6114,46 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, // because it probably makes more sense for it to be immutable (as // changes to it won't be visible on the C++ side anyway). - out << " " << cClassName << " *local_this = NULL;\n" - << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - << " return NULL;\n" - << " }\n" - << "\n" - << " PyObject *getter = PyDict_GetItemString(Dtool_" << ClassName << "._PyType.tp_dict, \"" << element_name << "\");\n" - << " if (getter == (PyObject *)NULL) {\n" + if (!obj->is_static_method(make_seq->_num_name)) { + out << " " << cClassName << " *local_this = NULL;\n" + << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" + << " return NULL;\n" + << " }\n\n"; + } + + if (obj->is_static_method(make_seq->_element_name)) { + out << " PyObject *getter = PyObject_GetAttrString((PyObject *)&Dtool_" << ClassName << ", \"" << element_name << "\");\n"; + } else { + out << " PyObject *getter = PyDict_GetItemString(Dtool_" << ClassName << "._PyType.tp_dict, \"" << element_name << "\");\n"; + } + + out << " if (getter == (PyObject *)NULL) {\n" << " return Dtool_Raise_AttributeError(self, \"" << element_name << "\");\n" << " }\n" - << "\n" - << " Py_ssize_t count = (Py_ssize_t)local_this->" << make_seq->_num_name << "();\n" - << " PyObject *tuple = PyTuple_New(count);\n" + << "\n"; + + if (obj->is_static_method(make_seq->_num_name)) { + out << " Py_ssize_t count = (Py_ssize_t)" << obj->_itype.get_scoped_name() << "::" << make_seq->_num_name << "();\n"; + } else { + out << " Py_ssize_t count = (Py_ssize_t)local_this->" << make_seq->_num_name << "();\n"; + } + + out << " PyObject *tuple = PyTuple_New(count);\n" << "\n" << " for (Py_ssize_t i = 0; i < count; ++i) {\n" << "#if PY_MAJOR_VERSION >= 3\n" << " PyObject *index = PyLong_FromSsize_t(i);\n" << "#else\n" << " PyObject *index = PyInt_FromSsize_t(i);\n" - << "#endif\n" - << " PyObject *value = PyObject_CallFunctionObjArgs(getter, self, index, NULL);\n" - << " PyTuple_SET_ITEM(tuple, i, value);\n" + << "#endif\n"; + + if (obj->is_static_method(make_seq->_element_name)) { + out << " PyObject *value = PyObject_CallFunctionObjArgs(getter, index, NULL);\n"; + } else { + out << " PyObject *value = PyObject_CallFunctionObjArgs(getter, self, index, NULL);\n"; + } + + out << " PyTuple_SET_ITEM(tuple, i, value);\n" << " Py_DECREF(index);\n" << " }\n" << "\n"