Skip to content

flow run without Python on the flowc host - #960

Merged
godofecht merged 5 commits into
mainfrom
port/run-without-python
Sep 27, 2026
Merged

godofecht merged 5 commits into
mainfrom
port/run-without-python

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

What

Default ./flow run and ./flow compile on the flowc host now work with no Python on PATH.

Python calls removed from the default paths:

  • flow run (and flow audio) called python3 -m flow.package sync --program for every program. The decision is now scripts/tools/pkg_sync/main.flow, a Flow program that flow-driver builds once with the Stage-A driver. It mirrors FlowPackageManager.sync_for_program: no flow.toml, an empty [dependencies], or flow.lock plus every flow_packages/<name> present means nothing to do. A project that must fetch something, or whose manifest uses TOML the reader leaves alone (dotted dependency keys, multi-line strings), still goes to package.py exactly as before.
  • compiler/scripts/ensure_flowc.sh judged the bootstrap C stale by mtime. A fresh clone writes compiler/src after compiler/bootstrap, so every clean checkout went to the Python Gen0 roundtrip on its first flow run (and on this tree that roundtrip fails, so the first run failed). Staleness now means uncommitted edits under compiler/src (mtime only outside git). Otherwise flowc_bootstrap is built from the checked-in C with cc. Python is used only for real local edits when python3 exists.
  • flow_resolve_flowc no longer wraps ensure_flowc in FLOW_HOST=python, and returns an absolute path, so flow run works from any working directory.
  • flow test-lang runs on flowc when FLOW_HOST=flowc is set. The Python strict transpile stays its default: flowc passes 100 of 126 programs, Python 123 (the 3 Python failures also fail on main).

Also: the flow-driver hunk from #956 (bundle programs with imports on flowc), copied byte for byte so either PR rebases cleanly over the other. Without it no example with an import builds on the default host. flow-driver is added to the CI path filters, which listed flow but not the driver.

Proof

scripts/check_run_without_python.sh puts python/python3 stubs that log and exit 127 first on PATH, clears compiler/build and build/, and runs:

PASS run examples/basics/hello_world.flow (exit 0)
PASS run hello_world.flow from another directory (exit 0)
PASS run examples/basics/fibonacci.flow (exit 55)
PASS compile examples/basics/fibonacci.flow (exit 0)
PASS execute build/fibonacci (exit 55)
PASS run examples/basics/result_pipeline.flow (import stdlib/result) (exit 0)
PASS run examples/dsp/pipeline.flow (import stdlib/dsp) (exit 0)
PASS FLOW_HOST=flowc test-lang tests/lang/test_strings.flow (exit 0)
PASS run project with empty [dependencies] (exit 7)
PASS run project with installed registry dependency (json) (exit 3)
PASS control: missing dependency is handed to the package manager (exit 127)
PASS control: stub logged the package manager call

programs: pass=12 fail=0
python stubs called: 0
check_run_without_python: PASS

The same script against main's flow-driver and ensure_flowc fails every run case and logs python3 -m flow.package sync --program ... for each, plus python3 -c import flow.transpiler from the Gen0 fallback. It runs in the flowc self-host (no Python) CI job.

Still needs Python

  • Installing a missing package dependency (package.py). compiler/src/pkg.flow also delegates fetching to it; that file is out of scope here.
  • Programs that import a registry package (import json.lib): flowc cannot resolve package imports yet, with or without Python. The registry case in the check therefore uses a program that does not import the package.
  • flow test in project mode (flow.project_test_runner), FLOW_RUN_PYTHON=1, FLOW_HOST=python|auto, and non-default commands (MLIR, gfx, audio compile, wasm, pkg subcommands).

Docs were not updated in this PR: the repo's pre-commit prose check rejects the existing em dashes in docs/project/self-hosting.md, python-in-flow.md, package-registry.md and compiler/README.md. Note that self-hosting.md Phase D slice 2 says flow run needed no Python; that held for flow compile only, until this change.

No Python became dead: sync_for_program is still the install path.

A fresh clone writes compiler/src after compiler/bootstrap, so the mtime
check always saw the sources as newer than the bootstrap C and sent the
default flowc host down the Python Gen0 roundtrip. Decide staleness from
uncommitted edits under compiler/src instead, freshen flowc_bootstrap
against the bootstrap C it was built from, and use Python only for real
local edits when python3 is on PATH.
Same hunk as the flow-driver part of #956, so either branch rebases
cleanly over the other. Without it no example with an import builds on
the default host, and the no-Python run check needs some that do.
Every flow run and flow audio called python3 -m flow.package sync, even
for programs with no manifest or an empty [dependencies] table. The
check now lives in scripts/tools/pkg_sync, a Flow program the driver
builds once with the Stage-A flowc driver. It mirrors
FlowPackageManager.sync_for_program: no flow.toml, no dependencies, or
flow.lock plus every flow_packages/<name> present means nothing to do.
A project that must fetch something, or whose manifest uses TOML the
reader leaves alone (dotted dependency keys, multi-line strings), still
goes to the package manager exactly as before.

flow_resolve_flowc now returns an absolute path, so flow run works from
any working directory, and no longer sets FLOW_HOST=python around
ensure_flowc.
scripts/check_run_without_python.sh puts python and python3 stubs that
log and exit 127 first on PATH, clears compiler/build and build/, and
runs flow run / flow compile on programs with and without stdlib
imports, from the repo root and another directory, plus a project with
an empty [dependencies] table and one with an installed registry
package. It fails if a program misbehaves or any stub is called. A
control removes the installed package and checks the package manager
call still happens.

The no-Python CI job runs it. flow-driver is added to the workflow path
filters, which listed flow but not the driver it delegates to.
The language suite always transpiled with python3 -m flow.transpiler
--strict. With FLOW_HOST=flowc set explicitly it now bundles each
program with the Stage-A driver (FLOWC_TYPECHECK=1) and compiles with
-I tests/lang, needing no Python. The Python strict transpile stays the
default: on this tree flowc passes 100 of 126 programs and Python 123.
The no-Python check covers one test-lang run.
@godofecht
godofecht force-pushed the port/run-without-python branch from 4869fd2 to 7401e51 Compare September 27, 2026 21:05
@godofecht
godofecht merged commit 58a5fea into main Sep 27, 2026
25 checks passed
godofecht added a commit that referenced this pull request Sep 27, 2026
)

ensure_flowc returns flowc_bootstrap on a clean checkout since #960, and that driver reads FLOWC_IN and FLOWC_OUT. The eight flowc conformance cases now set both.
godofecht added a commit that referenced this pull request Sep 29, 2026
Adds the scripts and tools ported to Flow in #959, #965 and #981, notes
that flow run needs no Python since #960, and lists open pull requests
as in progress. The LSP is Python and the only server; the Flow REPL is
in open PR #987.
godofecht added a commit that referenced this pull request Sep 29, 2026
Adds the scripts and tools ported to Flow in #959, #965 and #981, notes
that flow run needs no Python since #960, and lists open pull requests
as in progress. The LSP is Python and the only server; the Flow REPL is
in open PR #987.
@godofecht
godofecht deleted the port/run-without-python branch October 1, 2026 12:50
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.

1 participant