IQ.Pilot Release Commit @ bec7652

This commit is contained in:
IQ.Lvbs history cleanup
2026-08-22 23:42:41 -05:00
commit 58039e647c
4603 changed files with 1236178 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
import os
import sys
import SCons.Script.Main as _main
try:
from site_tools import pretty as _pretty
except Exception:
_pretty = None
def _tty():
return sys.stdout.isatty() and not os.environ.get("NO_COLOR")
_DIM = "\033[2;38;5;246m"
_BLUE = "\033[38;5;111m"
_GREEN = "\033[38;5;114m"
_RED = "\033[38;5;203m"
_RST = "\033[0m"
_READING = "scons: Reading SConscript files ..."
_PHASES = {
_READING: f"{_DIM}reading sconscripts…{_RST}",
"scons: done reading SConscript files.": f"{_DIM}sconscripts read{_RST}",
"scons: Building targets ...": f"{_BLUE}building…{_RST}",
"scons: done building targets.": f"{_GREEN}✓ build complete{_RST}",
"scons: done building targets (errors occurred during build).": f"{_RED}✗ build failed{_RST}",
"scons: writing .sconsign file.": f"{_DIM}writing .sconsign{_RST}",
"scons: Cleaning targets ...": f"{_DIM}cleaning…{_RST}",
"scons: done cleaning targets.": f"{_GREEN}✓ clean complete{_RST}",
"scons: done cleaning targets (errors occurred during clean).": f"{_RED}✗ clean failed{_RST}",
}
def _phase(text):
if _tty() and isinstance(text, str) and text in _PHASES:
return _PHASES[text]
return text
def _clean(text):
if not (_tty() and _pretty and isinstance(text, str)):
return text
for prefix in ("Removed directory ", "Removed "):
if text.startswith(prefix):
return _pretty._format("CLEAN", text[len(prefix):])
return text
class _Restyle:
# delegates unknown attrs (.set_mode etc.) to the wrapped DisplayEngine
def __init__(self, orig, transform):
self._orig = orig
self._transform = transform
def __call__(self, text, *args, **kwargs):
return self._orig(self._transform(text), *args, **kwargs)
def __getattr__(self, name):
return getattr(self._orig, name)
if not isinstance(_main.progress_display, _Restyle):
_main.progress_display = _Restyle(_main.progress_display, _phase)
if not isinstance(_main.display, _Restyle):
_main.display = _Restyle(_main.display, _clean)
# SConstruct imports this instead of scons auto-loading a root site_scons dir, so the reading
# banner is already on screen by now; rewrite that one line in place
if not getattr(_main, "_iq_banner_restyled", False):
_main._iq_banner_restyled = True
if _tty() and _main.progress_display.print_it:
sys.stdout.write(f"\033[F\033[2K{_PHASES[_READING]}\n")
sys.stdout.flush()
# drop only "Could not remove ... No such file" during clean; real errors still print
import builtins as _builtins
def _wrap_clean(orig):
def wrapper(self, *args, **kwargs):
if getattr(_builtins.print, "_iq_clean", False):
return orig(self, *args, **kwargs)
real = _builtins.print
def filtered(*a, **k):
if a and isinstance(a[0], str) and a[0].startswith("scons: Could not remove"):
if "No such file" in " ".join(str(x) for x in a):
return
return real(*a, **k)
filtered._iq_clean = True
_builtins.print = filtered
try:
return orig(self, *args, **kwargs)
finally:
_builtins.print = real
return wrapper
if not getattr(_main.CleanTask.fs_delete, "_iq_wrapped", False):
_main.CleanTask.fs_delete = _wrap_clean(_main.CleanTask.fs_delete)
_main.CleanTask.remove = _wrap_clean(_main.CleanTask.remove)
_main.CleanTask.fs_delete._iq_wrapped = True
_main.CleanTask.remove._iq_wrapped = True

View File

@@ -0,0 +1,82 @@
import re
import sys
import SCons
from SCons.Action import Action
from SCons.Scanner import Scanner
import numpy as np
pyx_from_import_re = re.compile(r'^from\s+(\S+)\s+cimport', re.M)
pyx_import_re = re.compile(r'^cimport\s+(\S+)', re.M)
cdef_import_re = re.compile(r'^cdef extern from\s+.(\S+).:', re.M)
np_version = SCons.Script.Value(np.__version__)
def pyx_scan(node, env, path, arg=None):
contents = node.get_text_contents()
env.Depends(str(node).split('.')[0] + env['CYTHONCFILESUFFIX'], np_version)
# from <module> cimport ...
matches = pyx_from_import_re.findall(contents)
# cimport <module>
matches += pyx_import_re.findall(contents)
# Modules can be either .pxd or .pyx files
files = [m.replace('.', '/') + '.pxd' for m in matches]
files += [m.replace('.', '/') + '.pyx' for m in matches]
# cdef extern from <file>
files += cdef_import_re.findall(contents)
# Handle relative imports
cur_dir = str(node.get_dir())
files = [cur_dir + f if f.startswith('/') else f for f in files]
# Filter out non-existing files (probably system imports)
files = [f for f in files if env.File(f).exists()]
return env.File(files)
pyxscanner = Scanner(function=pyx_scan, skeys=['.pyx', '.pxd'], recursive=True)
cythonAction = Action("$CYTHONCOM", "$CYTHONCOMSTR")
def create_builder(env):
try:
cython = env['BUILDERS']['Cython']
except KeyError:
cython = SCons.Builder.Builder(
action=cythonAction,
emitter={},
suffix=cython_suffix_emitter,
single_source=1
)
env.Append(SCANNERS=pyxscanner)
env['BUILDERS']['Cython'] = cython
return cython
def cython_suffix_emitter(env, source):
return "$CYTHONCFILESUFFIX"
def generate(env):
env["CYTHON"] = f'"{sys.executable}" -m Cython.Build.Cythonize'
# drop cythonize's stdout progress; errors stay on stderr. kept under --verbose
try:
from SCons.Script import GetOption
quiet = not GetOption("verbose")
except Exception:
quiet = True
env["CYTHONCOM"] = "$CYTHON $CYTHONFLAGS $SOURCE" + (" > /dev/null" if quiet else "")
env["CYTHONCFILESUFFIX"] = ".cpp"
c_file, _ = SCons.Tool.createCFileBuilders(env)
c_file.suffix['.pyx'] = cython_suffix_emitter
c_file.add_action('.pyx', cythonAction)
c_file.suffix['.py'] = cython_suffix_emitter
c_file.add_action('.py', cythonAction)
create_builder(env)
def exists(env):
return True

View File

@@ -0,0 +1,125 @@
import os
import sys
from SCons.Action import Action
from SCons.Script import GetOption
_GRAD = {
"CC": ((95, 215, 255), (70, 130, 245)),
"CXX": ((95, 205, 255), (130, 110, 250)),
"LINK": ((95, 240, 150), (40, 200, 120)),
"AR": ((120, 235, 220), (40, 175, 185)),
"RANLIB": ((140, 240, 225), (45, 165, 180)),
"SKIP": ((150, 160, 185), (100, 110, 145)),
"CLEAN": ((200, 130, 145), (120, 120, 155)),
"OBJCOPY": ((255, 200, 90), (255, 120, 50)),
"SIGN": ((255, 190, 90), (230, 80, 70)),
"CYTHON": ((215, 130, 255), (140, 80, 250)),
"CAPNP": ((255, 120, 225), (190, 90, 255)),
"RCC": ((200, 160, 255), (150, 110, 250)),
"FONTS": ((130, 190, 255), (90, 120, 250)),
"GEN": ((160, 160, 255), (120, 90, 250)),
"CDB": ((150, 175, 210), (105, 135, 185)),
"MODEL": ((255, 170, 70), (240, 60, 60)),
"META": ((255, 205, 110), (230, 130, 80)),
"MOC": ((255, 140, 205), (215, 90, 240)),
"UIC": ((255, 160, 190), (225, 110, 225)),
"MO": ((100, 235, 200), (55, 200, 155)),
}
_DEFAULT = ((120, 200, 255), (90, 140, 250))
_TARGET_RGB = (150, 152, 178)
def _mode():
if not sys.stdout.isatty() or os.environ.get("NO_COLOR"):
return None
if os.environ.get("COLORTERM", "").lower() in ("truecolor", "24bit"):
return "true"
return "256"
def _fg(rgb, mode):
r, g, b = rgb
if mode == "true":
return f"\033[38;2;{r};{g};{b}m"
if abs(r - g) < 12 and abs(g - b) < 12 and abs(r - b) < 12:
idx = 232 + min(23, round((r + g + b) / 3 / 255 * 23))
else:
idx = 16 + 36 * round(r / 255 * 5) + 6 * round(g / 255 * 5) + round(b / 255 * 5)
return f"\033[38;5;{idx}m"
def _gradient(word, start, end, mode):
n = max(1, len(word) - 1)
out = []
for i, ch in enumerate(word):
t = i / n
rgb = tuple(int(s + (e - s) * t) for s, e in zip(start, end))
out.append(f"\033[1m{_fg(rgb, mode)}{ch}")
return "".join(out) + "\033[0m"
def _format(label, body):
mode = _mode()
if mode is None:
return f"{label:>8} {body}"
start, end = _GRAD.get(label, _DEFAULT)
pad = " " * max(0, 8 - len(label))
word = _gradient(label, start, end, mode)
return f"{pad}{word} {_fg(_TARGET_RGB, mode)}{body}\033[0m"
def _line(label):
return _format(label, "$TARGET")
def _verbose():
try:
return bool(GetOption("verbose"))
except Exception:
return False
def generate(env):
def pretty_action(e, cmd, label, logfile=None, capture_stderr=False):
if _verbose():
return Action(cmd)
if callable(cmd):
return Action(cmd, _line(label))
if logfile:
cmd = f"{cmd} > {logfile}" + (" 2>&1" if capture_stderr else "")
return Action(cmd, _line(label))
env.AddMethod(pretty_action, "PrettyAction")
env.AddMethod(lambda e, label, msg: _format(label, msg), "PrettyNote")
# real errors are exceptions, not warnings, so they still surface with these ignored
env["PYWARN"] = "" if _verbose() else "PYTHONWARNINGS=ignore::UserWarning"
if _verbose():
return
try:
import SCons.CacheDir as _cachedir
_cachedir.CacheRetrieve.strfunction = lambda target, source, env: ""
except Exception:
pass
env["CCCOMSTR"] = _line("CC")
env["SHCCCOMSTR"] = _line("CC")
env["CXXCOMSTR"] = _line("CXX")
env["SHCXXCOMSTR"] = _line("CXX")
env["ASCOMSTR"] = _line("CC")
env["ASPPCOMSTR"] = _line("CC")
env["LINKCOMSTR"] = _line("LINK")
env["SHLINKCOMSTR"] = _line("LINK")
env["ARCOMSTR"] = _line("AR")
env["RANLIBCOMSTR"] = _line("RANLIB")
env["CYTHONCOMSTR"] = _line("CYTHON")
env["COMPILATIONDB_COMSTR"] = _line("CDB")
env["QT3_MOCFROMHCOMSTR"] = _line("MOC")
env["QT3_MOCFROMCXXCOMSTR"] = _line("MOC")
env["QT3_UICCOMSTR"] = _line("UIC")
def exists(env):
return True