armory3d / armsdk

Single-clone Armory SDK
37 stars 30 forks source link

Fix SDK updater: also update armory.py #46

Closed MoritzBrueckner closed 2 years ago

MoritzBrueckner commented 2 years ago

Fixes https://github.com/armory3d/armory/issues/2473.

Previously, only the individual SDK submodules were cloned when using the "Update SDK" button in the Armory preferences, which eventually led to problems because armory.py wasn't compatible with the SDK.

Now, the entire SDK repo is cloned recursively which solves this issue. Due to the now removed os.chdir(sdk_path) calls, Blender previously locked the SDK path, but they are not needed (anymore?) here so I could remove them and now it works. In case an error happens e.g. due to other applications locking the path, it is shown in the user interface and the user is prompted to try again. Parts of the solution are a bit ugly since now some of the I/O calls need to be wrapped in a function to ensure correct error handling without redundant code all over the place, but I think it's pretty solid despite that.

UI Screenshot

There are still many cases where both the old and the new code can fail (e.g. there is no backup created when an old backup already exists), so there is still some work that needs to be done in order to make the updater more fail-safe. Also, it would be possible to find out what processes lock the SDK path (if any) and then ask the user whether they should be automatically closed for them. However this is not possible out of the box without some very platform-specific fiddling involved. There is a package called psutil that could be used for this (and it could also help with some other parts of Armory), but I don't know whether you want to have an additional dependency and how we would cope with conflicting versions if other addons use that package as well.

luboslenco commented 2 years ago

👍👍

Happy to consider psutil in the future if needed.