OpenSite/Reference/Features/Python scripting: Difference between revisions
BathAfrica (talk | contribs) Publish organized OpenSite guides and reference navigation |
BathAfrica (talk | contribs) Link adjacent OpenSite reference pages in reading order |
||
| Line 28: | Line 28: | ||
[[Category:OpenSite documentation]] | [[Category:OpenSite documentation]] | ||
<div class="os-page-nav">{{Docnav|OpenSite/ | <div class="os-page-nav">{{Docnav|OpenSite/Reference/Features/Python workbench|OpenSite/Reference/Features/Quantities and expressions|OpenSite/Guides|All guides}}</div> | ||
Latest revision as of 14:15, 29 October 2026
Use the embedded Python interpreter to call OpenSite quantities, settings, commands and documents.
- Stable identifier
python.scripting
Status reported by source
Implemented in the reviewed development source. Historical test evidence is recorded by the repository; no test rerun or product release is claimed by this publication.
Units
Quantity math and formatting call the C++ engine. A profile change does not change the canonical SI value.
Behavior
PythonHost owns one interpreter, one application, and the unavailable account portal. An expression displays its value. A script sets __file__ and argv and does not add its directory to the search path. Each call restores the previous stdout and stderr. opensite.execute runs the command registry. A closed document raises stale_document. Production execution does not install the development policy.
Errors
opensite.Error carries the ErrorCode name, message, and context. A Python exception keeps earlier stdout and stderr with the traceback. A failed initialize is inactive. cancel requests KeyboardInterrupt and does not abort native code.
Limitations
Python and native providers are trusted code, not a sandbox. Cancellation is cooperative and does not forcibly stop native code. Production authorization is distinct from the explicit development host. Debug and Release Python binaries use different ABIs. Scientific packages belong to the matching internal scientific prefix, not the older base bundle. No public production shipment or Linux/macOS runtime validation is claimed here.
Available hosts
Windows headless opensite-python and OpenSiteConsole.exe, plus the desktop dockable console and Python workbench when GUI and Python are enabled. They share the interpreter/execution lane; they do not create independent runtimes.
Licensing and access
The production module does not install the development allow-all policy. CPython and pybind11 licenses are recorded with bundle 0.1.0. The scientific notice pack is prefix/notices. The review is docs/verification/Phase-7B-Redistribution-Review.md. The owner approved the FreeType License and the identified GCC runtime and winpthreads notices. That approval is not independent legal advice. A permissive package license does not clear a static codec, font, or GCC runtime object.
Verification evidence
Repository evidence references (not rerun for this publication): CTest python.production, python.development, python.installed, python.init_empty, python.init_missing, and python.relocated on Windows Debug and Release. ADR-0026. docs/verification/Phase-6-Acceptance.md. On 2026-10-11 the complete Visual Studio 2026 suites passed 30 of 30 in Debug and 30 of 30 in Release after the scientific runtime was staged. Linux and macOS were not built.
Try this workflow
Run your first script — a worked lesson with expected results.
Documentation basis
Source-reviewed against development commit 77c3fee13944bcc4b5d487c77eb1f82fbe4c6ea7, branch feature/phase-13c-properties-python-expressions. This review inspected the implementation and repository evidence; it did not run the Windows application or repeat CTest.
src/python/bindings.cppsrc/gui/python_console_service.cppdocs/verification/Phase-8-Runtime-Acceptance.md