Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Fix SDK updater: also update armory.py #46

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

MoritzBrueckner
Copy link
Contributor

Fixes armory3d/armory#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.

Fixes armory3d/armory#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.

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`](https://pypi.org/project/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 luboslenco merged commit 725a4ea into armory3d:main Jun 20, 2022
@luboslenco
Copy link
Member

👍👍

Happy to consider psutil in the future if needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On Event node does not compile
2 participants