Skip to content

Comments

Port RISC OS support skeleton to Python 3.14#29

Draft
Copilot wants to merge 4 commits intopython-314from
copilot/port-riscos-support-to-python314
Draft

Port RISC OS support skeleton to Python 3.14#29
Copilot wants to merge 4 commits intopython-314from
copilot/port-riscos-support-to-python314

Conversation

Copy link

Copilot AI commented Feb 10, 2026

Establishes RISC OS platform support structure from the riscos branch (Python 3.8.8 base) to enable Python 3.14 builds for RISC OS. Code uses Python 3.8 APIs and requires follow-up API modernization.

Directory Structure

  • RISCOS/ - Platform-specific build files, module config, and path handling
    • Makefile - RISC OS build system (updated VERSION=3.14)
    • config.c, pyconfig.h - Module configuration
    • getpath.c - Module search paths with RISC OS conventions
    • swimodule.c - Software Interrupt (SWI) interface
    • RiscPkg-314/ - Package metadata (renamed from RiscPkg-38)
    • _Python3/, _PythonSite/, _PythonUser/ - Boot files and resources

Platform Conditionals

Added #ifdef RISCOS blocks for platform-specific behavior:

Path Handling

  • Include/osdefs.h - Path separators: . for directory, , for search paths (RISC OS convention)

Exception Handling

  • Include/cpython/pyerrors.h, Objects/exceptions.c - RISCOSError exception type with errnum and errmsg attributes

Build Integration

  • Programs/python.c, Programs/_freeze_module.c - Riscosify control flags to handle path translation
  • Modules/getbuildinfo.c - Build identifier override ("riscos-1")

Dynamic Loading

  • Python/dynload_shlib.c - Extension suffix /so instead of .so, path unixification via __unixify()

System Integration

  • Modules/timemodule.c - Sleep via OS_ReadMonotonicTime SWI instead of select()
  • Modules/_ssl.c - Certificate path stubs (X509 defaults unused on RISC OS)
  • Python/initconfig.c - Config string-to-int parsing stub (returns 0)

API Modernization Required

Module initialization in RISCOS/config.c and RISCOS/swimodule.c uses Python 3.8 patterns. Follow-up work needed to update to Python 3.14 PyModuleDef structure and exception APIs.

Original prompt

Objective

Port the RISC OS-specific changes from the riscos branch (based on Python 3.8.8) to the python-314 branch (Python 3.14). This PR provides the skeleton structure for RISC OS support in Python 3.14.

Background

The RISC OS port of Python includes:

  • Platform-specific modules (riscos, swi)
  • Path handling adaptations (RISC OS uses . as directory separator and , as search path delimiter)
  • Build system for RISC OS
  • Platform-specific implementations for dynamic loading, sleep, and exception handling

Changes Required

Phase 1: Copy RISCOS Directory Structure

Copy the entire RISCOS/ directory from the riscos branch, containing:

  • RISCOS/Makefile - Build system
  • RISCOS/config.c - Module configuration
  • RISCOS/pyconfig.h - Platform configuration
  • RISCOS/getpath.c - Module search paths
  • RISCOS/swimodule.c - SWI (Software Interrupt) interface
  • RISCOS/ReleaseNotes - Documentation
  • RISCOS/_Python3/ - Boot files and sprites
  • RISCOS/_PythonUser/ - User files
  • RISCOS/RiscPkg-38/ - Package metadata (rename to RiscPkg-314 and update version)

Note: The code in these files will need to be updated for Python 3.14 API changes in a follow-up, but copy them as-is first to establish the structure.

Phase 2: Add Conditional Compilation Blocks

Add #ifdef RISCOS blocks to the following files based on the riscos branch:

Include/osdefs.h

Add RISC OS path separators:

#ifdef RISCOS
#define DELIM L','
#define SEP L'.'
#endif

Include/cpython/pyerrors.h

Add RISCOSError exception structure:

#ifdef RISCOS
typedef struct {
    PyException_HEAD
    PyObject *errnum;
    PyObject *errmsg;
} PyRISCOSErrorObject;
#endif

Objects/exceptions.c

Add RISCOSError exception initialization:

#ifdef RISCOS
    PRE_INIT(RISCOSError);
#endif

Programs/python.c

Add riscosify control settings at the top:

#ifdef RISCOS
#include <unixlib/local.h>
int __riscosify_control =  __RISCOSIFY_NO_PROCESS |
                           __RISCOSIFY_NO_SUFFIX |
                           __RISCOSIFY_NO_REVERSE_SUFFIX;
#endif

Programs/_freeze_importlib.c

Add:

  1. Include and riscosify control (same as python.c)
  2. In the main() function, replace the _Py_fstat_noraise block with:
#ifdef RISCOS
    fseek(infile, 0, SEEK_END);
    text_size = ftell(infile);
    fseek(infile, 0, SEEK_SET);
#else
    if (_Py_fstat_noraise(fileno(infile), &stat)) {
        fprintf(stderr, "cannot fstat '%s'\n", inpath);
        goto error;
    }
    text_size = (size_t)stat.st_size;
#endif

Modules/getbuildinfo.c

In the Py_GetBuildInfo() function, replace the gitid initialization with:

#ifdef RISCOS
    const char *gitid = "riscos-1";
#else
    const char *gitid = _Py_gitidentifier();
    if (!(*gitid))
        gitid = "default";
#endif

Python/dynload_shlib.c

Add multiple changes:

  1. After includes, add:
#ifdef RISCOS
#include <unixlib/local.h>
#endif
  1. In the file extension table _PyImport_DynLoadFiletab:
const char *_PyImport_DynLoadFiletab[] = {
#if defined(RISCOS)
    "/so",
    "/" SOABI "/so",
#elif defined(__CYGWIN__)
    ".dll",
#else
    "." SOABI ".so",
#ifdef ALT_SOABI
    "." ALT_SOABI ".so",
#endif
    ".abi" PYTHON_ABI_STRING ".so",
    ".so",
#endif
    NULL,
};
  1. In _PyImport_FindSharedFuncptr(), add RISCOS-specific path handling:
#ifndef RISCOS
    char pathbuf[260];

    if (strchr(pathname, '/') == NULL) {
        /* Prefix bare filename with "./" */
        PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname);
        pathname = pathbuf;
    }
#endif
  1. In the dlopen call section:
#ifdef RISCOS
    char* unixpath = __unixify(pathname, 0x0, 0, 0, -1);
    handle = dlopen(unixpath, dlopenflags);
    free(unixpath);
#else
    handle = dlopen(pathname, dlopenflags);
#endif

Modules/_ssl.c

In the _ssl_get_default_verify_paths_impl() function, add:

#ifdef RISCOS
    // The defaults from the X509_... calls are somewhat useless.
    ofile_env = Py_None; Py_INCREF(Py_None);
    ofile     = Py_None; Py_INCREF(Py_None);
    odir_env  = Py_None; Py_INCREF(Py_None);
    odir      = Py_None; Py_INCREF(Py_None);
#else
    CONVERT(X509_get_default_cert_file_env(), ofile_env);
    CONVERT(X509_get_default_cert_file(), ofile);
    CONVERT(X509_get_default_cert_dir_env(), odir_env);
    CONVERT(X509_get_default_cert_dir(), odir);
#endif

Modules/timemodule.c

In the pysleep() function, replace the select() call with:

#ifdef RISCOS
        unsigned int end = _swi(OS_ReadMonotonicTime, _RETURN(0)) +
                           (timeout.tv_sec * 100 + timeout.tv_usec / 10000);
       while ((unsigned)_swi(OS_ReadMonotonicTime, _RETURN(0)) < end) ;
#else
        err = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout);
#endif

Python/initconfig.c

Add a RISC OS-specific version of config_wstr_to_int():

#...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI and others added 3 commits February 10, 2026 09:58
Co-authored-by: c-jo <1500011+c-jo@users.noreply.github.com>
Co-authored-by: c-jo <1500011+c-jo@users.noreply.github.com>
Co-authored-by: c-jo <1500011+c-jo@users.noreply.github.com>
Copilot AI changed the title [WIP] Port RISC OS-specific changes to Python 3.14 branch Port RISC OS support skeleton to Python 3.14 Feb 10, 2026
Copilot AI requested a review from c-jo February 10, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants