From e2d9d3ef7ce56b37f417b6f2e455279433f67635 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 Oct 2024 20:09:31 +0100 Subject: [PATCH 01/10] makepanda: Fix python DLL not being copied into wheel on 3.13t --- makepanda/makewheel.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index 5be77f4b5c..c0fe650fdf 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -635,11 +635,16 @@ def makewheel(version, output_dir, platform=None): whl.ignore_deps.update(MANYLINUX_LIBS) # Add libpython for deployment. + suffix = '' + gil_disabled = get_config_var("Py_GIL_DISABLED") + if gil_disabled and int(gil_disabled): + suffix = 't' + if sys.platform in ('win32', 'cygwin'): - pylib_name = 'python{0}{1}.dll'.format(*sys.version_info) + pylib_name = 'python{0}{1}{2}.dll'.format(sys.version_info[0], sys.version_info[1], suffix) pylib_path = os.path.join(get_config_var('BINDIR'), pylib_name) elif sys.platform == 'darwin': - pylib_name = 'libpython{0}.{1}.dylib'.format(*sys.version_info) + pylib_name = 'libpython{0}.{1}{2}.dylib'.format(sys.version_info[0], sys.version_info[1], suffix) pylib_path = os.path.join(get_config_var('LIBDIR'), pylib_name) else: pylib_name = get_config_var('LDLIBRARY') From c2de5c306f8430ed95b303d7edccbf132a240601 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 Oct 2024 20:19:05 +0100 Subject: [PATCH 02/10] makepanda: Don't link p3dcparse with pystub pystub doesn't really define enough symbols to be useful with newer Python versions, and it seems that there are compile errors with python 3.13t on manylinux2014 due to conflicts with the Python library itself --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index fc547bd234..17699c3074 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -5796,7 +5796,7 @@ if (PkgSkip("PYTHON")==0 and PkgSkip("DIRECT")==0 and not RTDIST and not RUNTIME PyTargetAdd('p3dcparse.exe', input='dcparse_dcparse.obj') PyTargetAdd('p3dcparse.exe', input='libp3direct.dll') PyTargetAdd('p3dcparse.exe', input=COMMON_PANDA_LIBS) - PyTargetAdd('p3dcparse.exe', input='libp3pystub.lib') + #PyTargetAdd('p3dcparse.exe', input='libp3pystub.lib') PyTargetAdd('p3dcparse.exe', opts=['ADVAPI']) # From ff91f127bf2c11d05adb20f6e7f2ba234f1d6ec9 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 Oct 2024 21:51:56 +0100 Subject: [PATCH 03/10] py_compat: Fix Python 2.7 compilation error This code never actually gets compiled in Python 3 [skip ci] --- dtool/src/interrogatedb/py_compat.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index 91fe93d456..722bc8300b 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -33,11 +33,7 @@ size_t PyLongOrInt_AsSize_t(PyObject *vv) { size_t bytes; int one = 1; int res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes, - SIZEOF_SIZE_T, (int)*(unsigned char*)&one, 0, -#if PY_VERSION_HEX >= 0x030d0000 - , 1 // with_exceptions -#endif - ); + SIZEOF_SIZE_T, (int)*(unsigned char*)&one, 0); if (res < 0) { return (size_t)res; From e5ac1d0141295330ad4aa329d80c8412ce63dd37 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 12:50:26 +0100 Subject: [PATCH 04/10] build_apps: Don't warn about missing ld-linux lib on aarch64 --- direct/src/dist/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 5b325d725c..ef1bfa2e81 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -317,7 +317,8 @@ class build_apps(setuptools.Command): # manylinux1/linux 'libdl.so.*', 'libstdc++.so.*', 'libm.so.*', 'libgcc_s.so.*', - 'libpthread.so.*', 'libc.so.*', 'ld-linux-x86-64.so.*', + 'libpthread.so.*', 'libc.so.*', + 'ld-linux-x86-64.so.*', 'ld-linux-aarch64.so.*', 'libgl.so.*', 'libx11.so.*', 'libncursesw.so.*', 'libz.so.*', 'librt.so.*', 'libutil.so.*', 'libnsl.so.1', 'libXext.so.6', 'libXrender.so.1', 'libICE.so.6', 'libSM.so.6', 'libEGL.so.1', From a311ad876f4dd64201b78c477364016efacffc3e Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 12:51:07 +0100 Subject: [PATCH 05/10] test_wheel: Add --ignore option to ignore tests --- makepanda/test_wheel.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/makepanda/test_wheel.py b/makepanda/test_wheel.py index d181c403f2..66373b0d1d 100755 --- a/makepanda/test_wheel.py +++ b/makepanda/test_wheel.py @@ -14,7 +14,7 @@ import tempfile from optparse import OptionParser -def test_wheel(wheel, verbose=False): +def test_wheel(wheel, verbose=False, ignores=[]): envdir = tempfile.mkdtemp(prefix="venv-") print("Setting up virtual environment in {0}".format(envdir)) sys.stdout.flush() @@ -70,6 +70,9 @@ def test_wheel(wheel, verbose=False): test_cmd = [python, "-m", "pytest", "tests"] if verbose: test_cmd.append("--verbose") + for ignore in ignores: + test_cmd.append("--ignore") + test_cmd.append(ignore) # Put the location of the python DLL on the path, for deploy-stub test # This is needed because venv does not install a copy of the python DLL @@ -96,6 +99,7 @@ def test_wheel(wheel, verbose=False): if __name__ == "__main__": parser = OptionParser(usage="%prog [options] file...") parser.add_option('', '--verbose', dest = 'verbose', help = 'Enable verbose output', action = 'store_true', default = False) + parser.add_option('', '--ignore', dest = 'ignores', help = 'Ignores given test directory (may be repeated)', action = 'append', default = []) (options, args) = parser.parse_args() if not args: @@ -103,4 +107,4 @@ if __name__ == "__main__": sys.exit(1) for arg in args: - test_wheel(arg, verbose=options.verbose) + test_wheel(arg, verbose=options.verbose, ignores=options.ignores) From 32ad388a51a40c7f35a515b7c8819621f614a574 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 12:51:31 +0100 Subject: [PATCH 06/10] gobj: Don't try to resolve empty alpha filename when writing bam --- panda/src/gobj/texture.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 99c5d10c02..29da1ba92a 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -10101,13 +10101,15 @@ do_write_datagram_header(CData *cdata, BamWriter *manager, Datagram &me, bool &h << "Texture file " << cdata->_fullpath << " found as " << filename << "\n"; } - if (!has_bam_dir || !alpha_filename.make_relative_to(bam_dir, true)) { - alpha_filename.find_on_searchpath(get_model_path()); - } - if (gobj_cat.is_debug()) { - gobj_cat.debug() - << "Alpha image " << cdata->_alpha_fullpath - << " found as " << alpha_filename << "\n"; + if (!alpha_filename.empty()) { + if (!has_bam_dir || !alpha_filename.make_relative_to(bam_dir, true)) { + alpha_filename.find_on_searchpath(get_model_path()); + } + if (gobj_cat.is_debug()) { + gobj_cat.debug() + << "Alpha image " << cdata->_alpha_fullpath + << " found as " << alpha_filename << "\n"; + } } break; From 2a6f4fc6ff4521b224a840d7064171f132600a66 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 12:51:52 +0100 Subject: [PATCH 07/10] putil: Fix file_texture_mode on BamWriter not being writable --- panda/src/putil/bamWriter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index be07d80411..fa9c0ca188 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -96,7 +96,7 @@ PUBLISHED: MAKE_PROPERTY(file_version, get_file_version); MAKE_PROPERTY(file_endian, get_file_endian); MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double); - MAKE_PROPERTY(file_texture_mode, get_file_texture_mode); + MAKE_PROPERTY(file_texture_mode, get_file_texture_mode, set_file_texture_mode); MAKE_PROPERTY(root_node, get_root_node, set_root_node); public: From 5dcd70dcb5c513a26702df8708b98b84d5271bc2 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 12:52:17 +0100 Subject: [PATCH 08/10] build_apps: Fix wrong relative paths with bam_model_extensions Fixes #1642 --- direct/src/dist/commands.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index ef1bfa2e81..d22f7583fd 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -92,6 +92,7 @@ def _model_to_bam(_build_cmd, srcpath, dstpath): src_fn = p3d.Filename.from_os_specific(srcpath) dst_fn = p3d.Filename.from_os_specific(dstpath) + dst_fn.set_binary() _register_python_loaders() @@ -102,8 +103,27 @@ def _model_to_bam(_build_cmd, srcpath, dstpath): if not node: raise IOError('Failed to load model: %s' % (srcpath)) - if not p3d.NodePath(node).write_bam_file(dst_fn): - raise IOError('Failed to write .bam file: %s' % (dstpath)) + stream = p3d.OFileStream() + if not dst_fn.open_write(stream): + raise IOError('Failed to open .bam file for writing: %s' % (dstpath)) + + # We pass it the source filename here so that texture files are made + # relative to the original pathname and don't point from the destination + # back into the source directory. + dout = p3d.DatagramOutputFile() + if not dout.open(stream, src_fn) or not dout.write_header("pbj\0\n\r"): + raise IOError('Failed to write to .bam file: %s' % (dstpath)) + + writer = p3d.BamWriter(dout) + writer.root_node = node + writer.init() + writer.set_file_texture_mode(p3d.BamEnums.BTM_relative) + writer.write_object(node) + writer.flush() + writer = None + dout.close() + dout = None + stream.close() def egg2bam(_build_cmd, srcpath, dstpath): From 89c0371cbb8009a4a04438424c53e3c037e4fe47 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 13:05:31 +0100 Subject: [PATCH 09/10] putil: BamWriter doc fix, initialize _root_node field properly --- panda/src/putil/bamWriter.I | 3 +++ panda/src/putil/bamWriter.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index ad8b119edf..b9e36d421f 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -96,6 +96,9 @@ get_file_texture_mode() const { * Changes the BamTextureMode preference for the Bam file currently being * written. Texture objects written to this Bam file will be encoded * according to the specified mode. + * + * This should be called after the call to init(), or it will be overwritten + * with the default mode in the config file. */ INLINE void BamWriter:: set_file_texture_mode(BamTextureMode file_texture_mode) { diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index fa9c0ca188..63328de177 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -135,7 +135,7 @@ private: // Stores the PandaNode representing the root of the node hierarchy we are // currently writing, if any, for the purpose of writing NodePaths. This is // a TypedWritable since PandaNode is defined in pgraph. - TypedWritable *_root_node; + TypedWritable *_root_node = nullptr; // This is the set of all TypeHandles already written. pset _types_written; From 6f2231620d796b47916397625f4bbfb78aaf76ad Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 31 Oct 2024 13:06:26 +0100 Subject: [PATCH 10/10] build_apps: Add bam_embed_textures option --- direct/src/dist/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index d22f7583fd..68ce14ac82 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -117,7 +117,10 @@ def _model_to_bam(_build_cmd, srcpath, dstpath): writer = p3d.BamWriter(dout) writer.root_node = node writer.init() - writer.set_file_texture_mode(p3d.BamEnums.BTM_relative) + if _build_cmd.bam_embed_textures: + writer.set_file_texture_mode(p3d.BamEnums.BTM_rawdata) + else: + writer.set_file_texture_mode(p3d.BamEnums.BTM_relative) writer.write_object(node) writer.flush() writer = None @@ -323,6 +326,7 @@ class build_apps(setuptools.Command): ] self.file_handlers = {} self.bam_model_extensions = [] + self.bam_embed_textures = False self.exclude_dependencies = [ # Windows 'kernel32.dll', 'user32.dll', 'wsock32.dll', 'ws2_32.dll',