-patch the following file /data/pkgsrc/lang/python313/work/Python-3.13.12/Objects/mimalloc/prim/unix/prim.c efined(__NetBSD__) #define MI_HAS_SYSCALL_H // #include #endif -patch the same file #if defined(__QNX__) # undef madvise # define madvise posix_madvise # if !defined(MADV_DONTNEED) && defined(POSIX_MADV_DONTNEED) # define MADV_DONTNEED POSIX_MADV_DONTNEED # endif #endif -patch the following file /data/pkgsrc/lang/python313/work/Python-3.13.12/Modules/faulthandler.c +#ifdef SA_RESTART + action.sa_flags = SA_RESTART; +#else + action.sa_flags = 0; /* QNX / other platforms without SA_RESTART */ +#endif -patch the following file /data/pkgsrc/lang/python313/work/Python-3.13.12/Modules/posixmodule.c #elif defined(HAVE_SYS_IOCTL_H) # include # if defined(HAVE_TERMIOS_H) # include # endif +#if defined(__QNX__) +#include /* openpty(), login_tty(), forkpty() on QNX 8.0 */ +#include +#include +#endif -symlink gcc(clang) to qcc ln -s /usr/bin/gcc /usr/bin/qcc -patch the following file /data/pkgsrc/lang/python313/work/Python-3.13.12/Makefile -LINKFORSHARED= -Wl,-E -N 2048K +LINKFORSHARED= -Wl,-z,stack-size=2097152 -patch the follwing file /data/pkgsrc/lang/python313/work/Python-3.13.12/Modules/selectmodule.c #if defined(__QNX__) # define FD_SETSIZE 1024 # include /* provides fd_set, FD_ZERO, FD_SET, FD_ISSET on QNX */ # include /* provides struct timeval */ #endif #ifdef __APPLE__ /* Perform runtime testing for a broken poll on OSX to make it easier * to use the same binary on multiple releases of the OS. */ -patch the following file /data/pkgsrc/lang/python313/work/Python-3.13.12/Modules/termios.c #if defined(__QNX__) #define __TERMIO_H_INCLUDED #include #define NCC 18 /* QNX is strictly POSIX; the old SVR4-style TCGETA etc. cause header conflicts. We don't need them in the termios module. */ #undef TCGETA #undef TCSETA #undef TCSETAW #undef TCSETAF #endif -patch the follwing file /data/pkgsrc/lang/python313/work/Python-3.13.12/Modules/_testinternalcapi/pytime.c #if defined(__QNX__) #include /* defines struct timeval on QNX 8.0 */ #endif --last step is to do the following : --the build fails so we fix it as [root@qnxpi /data/pkgsrc/lang/python313/work/Python-3.13.12 ]# clang -fPIC -I. -IInclude -I../Include -I/usr/include -DNCURSES_WIDECHAR=1 -c ./Modules/_ctypes/_ctypes_test.c -o Modules/_ctypes/_ctypes_test [root@qnxpi /data/pkgsrc/lang/python313/work/Python-3.13.12]# clang -shared -L/usr/lib -Wl,-R/usr/lib -L/data/pkg/lib -Wl,-R/data/pkg/lib \ Modules/_ctypes/_ctypes_test.o -lm -o Modules/_ctypes_test.so --one last fix is needed [root@qnxpi /data/pkgsrc/lang/python313/work/Python-3.13.12 ]# make LINKFORSHARED="$LINKFORSHARED -Wl,-E" python --Fix PLIST --- Also make sure to put this file in /data/pkg/lib/python3.13/itecustomize.py ### This is QNX 8 specific fix for pkgsrc python-setup-tools import os import shutil import sys import tempfile if sys.platform.startswith('qnx'): print("Applying QNX rmtree workaround for NotADirectoryError races", file=sys.stderr) original_rmtree_safe_fd = shutil._rmtree_safe_fd def qnx_rmtree_safe_fd(stack, onexc): """QNX-tolerant wrapper for _rmtree_safe_fd to handle races where dir becomes non-dir.""" try: return original_rmtree_safe_fd(stack, onexc) except NotADirectoryError as err: # Race: the path is no longer a directory (common on QNX during heavy build cleanup) path = getattr(err, 'filename', None) or str(err) if not os.path.exists(path) or not os.path.isdir(path): return # safely ignore - already gone or turned non-dir # If it's a file, try to unlink it if os.path.isfile(path): try: os.unlink(path) return except Exception: pass # Re-raise only if it's truly unexpected raise shutil._rmtree_safe_fd = qnx_rmtree_safe_fd # Also reinforce TemporaryDirectory original_TempDir = tempfile.TemporaryDirectory class QnxTemporaryDirectory(original_TempDir): def __init__(self, *args, **kwargs): kwargs.setdefault('ignore_cleanup_errors', True) super().__init__(*args, **kwargs) tempfile.TemporaryDirectory = QnxTemporaryDirectory