proboscis / pinjected

MIT License
11 stars 0 forks source link

Portability Improvement #10

Open proboscis opened 1 year ago

proboscis commented 1 year ago

Currently, our design makes the code reusable within the same project, where a design can be easily importable. However, when it comes to porting the design to another project, it is difficult to reuse, since all the depending scripts must be importable. The only way we can reuse our design in other projects is to use pypi's packaging system.

Proposal: Make each Injected portable across projects

proboscis commented 1 year ago

This is like as if we just want to interpret the python in our way..

We can for example parse a script and get import statement, and replace it with our injections.

proboscis commented 1 year ago

Since we are importing our modules through injections, we rarely import own modules, The main things we need to import are the classes and constants.

proboscis commented 1 year ago

I guess we should analyze the script and find import statements for dependencies. Given a design, we can check each binding for its definition, and find the import statements

proboscis commented 1 year ago

I hope if we could purify the design depending on the purpose, but it is very difficult... Ah, but maybe we can use GPT for the help? We can ask gpt to extract a injected function from a file, and an injected class from a file Then, we can ask it to find whether it has outer imports that depends on it...

The cases we need to handle is

  1. pure injected function without any module dependency
  2. pure injected function with pypi module dependency
  3. pure injected function with own module dependency

In order to purify this,

  1. build a tree of imports using AST
  2. move dependency to a flat file
  3. move module imports along with it
  4. remove the import statement