Moo-Ack-Productions / bpy-build

A build sytem to make building Blender addons 10 times easier
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Include source and build paths vars in run scripts #7

Closed TheDuckCow closed 2 months ago

TheDuckCow commented 5 months ago

This is coming back to the thing I keep mentioning which is the slowest part of trying to follow test driven development: running tests often is painful, as it takes several minutes to just put the addons in place. With the old system, all installs with the fast option would happen in less than 2 seconds.

In my experience and in doing some testing today, the real crux of the problem is a) the large size of blend files and b) the sheer number of (resource pack image) files being created for the zip. No matter what we do, zipping and unzipping all those files will be slow.

My proposal:

This is probably the simplest thing we could do and, from my standpoint, would be the #1 time saver pretty quickly while doing testing and PR reviews.

Let me know what you think @StandingPadAnimations! Open to other suggestions

StandingPadAnimations commented 5 months ago

Funnily enough I've already thought about creating a basic API for BpyBuild that exposes a couple of variables, namely:

In addition, for hooks I think we could have them take in a function instead, to make it a bit more flexible, similar to the Python map function.

TheDuckCow commented 5 months ago

The main thought I'm having about the function hooks is whether we have to do some funny things like assume for any given script it does have the given hook and just try/except pass if not, or if we want to do a more inherited class structure.

tbh I still vaguely question if we're over engineering the build system, so I'd personally be fine with the approach of having bpy builder assume each script has a given function and then just gracefully move on via exception if not. It does mean where we currently do subprocess.Popen() for the runner scripts we might want to not always run the whole thing via main and instead have each operation within a function and try to just import/directly call that function. Just an idea.

What do you think of that?

StandingPadAnimations commented 5 months ago

I'm personally not a big fan of looking for the existence of functions in files, it reminds me a bit too much of C. Of course. Overengineering is a good concern to have for when creating something like this, but I think we could get the best of both worlds if we keep things pretty simple.

For starters, BpyBuild could expose a few variables through a global dataclass. What I have in mind is the following:

@dataclasss
class BpyBuildProps:
    project: Path
    cwd_path: Path
    config: Config 

From there, we could have the following hooks, where each hook takes in a basic function of some type, and act like the register function in bpy:

In addition, although slightly unrelated, we could also add some basic report_error function for actions in general if something occurs that requires BpyBuild to stop and gracefully exit from building.

I believe with these 2 things, we could cover most use cases, while keeping things ergonomic and easy to maintain. What do you think?

StandingPadAnimations commented 4 months ago

Began working on this in api-addition, though opting to use reserved names like prebuild instead of explicit registration functions. This does make some breaking changes to script requires, notably main functions and if __name__ == "__main__" checks are required now. This is because the API imports modules dynamically, and Python executes all modules when they're imported.

The following hooks are planned:

StandingPadAnimations commented 4 months ago

Alright, so I've gotten pre_build and post_install implemented. Now I just need to implement pre_install and post_build

TheDuckCow commented 4 months ago

Great, thanks for working on this!

StandingPadAnimations commented 4 months ago

Hooks have been added now, just need to work on some documentation for said hooks