I was curious so I had a look at how the "pip install ast-grep-cli" command works. It downloads a wheel for the correct platform from https://pypi.org/project/ast-grep-cli/#files
The wheel just contains the two binaries (sg and ast-grep) and no Python code:
$ unzip -l ast_grep_cli-0.14.2-py3-none-macosx_10_7_x86_64.whl
Archive: ast_grep_cli-0.14.2-py3-none-macosx_10_7_x86_64.whl
Length Date Time Name
--------- ---------- ----- ----
6207 12-03-2023 07:34 ast_grep_cli-0.14.2.dist-info/METADATA
102 12-03-2023 07:34 ast_grep_cli-0.14.2.dist-info/WHEEL
1077 12-03-2023 07:34 ast_grep_cli-0.14.2.dist-info/license_files/LICENSE
1077 12-03-2023 07:34 ast_grep_cli-0.14.2.dist-info/license_files/LICENSE
32865880 12-03-2023 07:34 ast_grep_cli-0.14.2.data/scripts/sg
32865880 12-03-2023 07:34 ast_grep_cli-0.14.2.data/scripts/ast-grep
639 12-03-2023 07:34 ast_grep_cli-0.14.2.dist-info/RECORD
--------- -------
65740862 7 files
I haven't seen pip and wheels used to distribute a purely binary tool like this before.