Skip to content

cli: pyfun build --native compiles a program with mypyc - #156

Merged
simontreanor merged 1 commit into
mainfrom
cli/build-native
Sep 28, 2026
Merged

simontreanor merged 1 commit into
mainfrom
cli/build-native

Conversation

@simontreanor

Copy link
Copy Markdown
Owner

The build step the ROADMAP lists after typed emit (#155).

pyfun build --native <file.pyfun> -o <dir>:

  1. compiles natively (ladders + annotations),
  2. runs python -m mypyc --allow-redefinition-new --local-partial-types <module>.py in <dir> (interpreter from PYFUN_PYTHON or PATH),
  3. removes the Python source (so an import finds the extension) and mypyc's build/ scratch,
  4. writes __main__.py importing the module, so the result runs as python <dir>.

It needs mypy and a C compiler in that environment; when mypyc fails the error says so. --native is required for now, since native is the only build there is. Single file for now (projects error clearly).

bench/mypyc_run.py now builds its mypyc variant with pyfun build --native, so this PR's native-bench run exercises the command end to end on Linux. Locally on Windows it reaches mypyc's build_ext and stops for lack of the MSVC Build Tools, with the intended error message.

DESIGN §5.6 and ROADMAP updated.

pyfun build --native <file> -o <dir> compiles the program natively (ladders
and annotations), runs mypyc on it with --allow-redefinition-new and
--local-partial-types, removes the Python source so an import finds the
extension, and writes a __main__.py, so the result runs as python <dir>.
It needs mypy and a C compiler in the interpreter's environment and says so
when mypyc fails. Single file for now.

bench/mypyc_run.py now builds its mypyc variant with this command, so the
native-bench job exercises it.
@simontreanor
simontreanor merged commit 57e3e2e into main Sep 28, 2026
21 checks passed
@simontreanor
simontreanor deleted the cli/build-native branch September 28, 2026 01:45
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