grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Rebuild tool for automated refactoring #143

Open XVilka opened 4 years ago

XVilka commented 4 years ago

A good example on how this can be done is c2rust. It not only converts the source, but keeps it compilable, provides the refactoring tool and means to script the refactoring with Lua language. See their manual for more information.

image

alanjds commented 4 years ago

This is interesting, but what exactly is your issue/concern/proposal?

XVilka commented 4 years ago

@alanjds Idea is to convert the current Python codebase to Go, with a similar workflow as c2rust - first, transpile, this is what grumpy already does, but extend the tool with refactoring capabilities of the produced code, to help the porters to keep project running and passing tests while the slow porting is progressing.

alanjds commented 4 years ago

Well, you can already do that.

Passing grumpy -v debug --keep-main script.py, all the transpiled code will be kept and the Go compiler command will also be echoed. You can collect this and start rewriting your Py modules to Go and replacing it via from '__go__/mymodule' import Myfunc

The main() is wrote to a location on /tmp that is kept when --keep-main flag is set. There you can follow the execution line.