Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: allow extract addon folder inside subdir of git repo #205

Closed
wants to merge 1 commit into from

Conversation

zhuoqun-chen
Copy link

Scenario:

Assuming I'm developing an extension called dummy_addon and I have a github repo for it, the actual addon with blender_manifest.toml actually lives one level deeper.

dummy_addon
├── README.md
├── dummy_addon
│   ├── __init__.py
│   ├── blender_manifest.toml
│   ├── packageA
│   └── packageB
└── tests

Current extension can only recognize the structure where the project root has a blender_manifest.toml and my commit will allow the user to create a symlink that points to the actual addon package folder, which can be more convenient. This also works inside multi-root workspace where many add-ons are developed together.

@Mateusz-Grzelinski
Copy link
Collaborator

Mateusz-Grzelinski commented Sep 28, 2024

Just a quick reply,
Are you sure this is not done by setting blender.addonFolders?

Unfortunately I will not be able to review it in following week's.

edit: or are you trying to resolve blender.addonFolders automatically?

@zhuoqun-chen
Copy link
Author

Hi @Mateusz-Grzelinski, yes, I'm trying to auto-resolve the actual addon folder.

However, after some investigation and your suggested blender.addonFolders, it seems that two functions under addon_folder.js:

async function tryFindActualAddonFolder(root) {
    if (await folderContainsAddonEntry(root))
        return root;
    for (let folder of await (0, utils_1.getSubfolders)(root)) {
        if (await folderContainsAddonEntry(folder)) {
            return folder;
        }
    }
    return Promise.reject(new Error('cannot find actual addon code, please set the path in the settings'));
}

async function folderContainsAddonEntry(folderPath) {
    let manifestPath = path.join(folderPath, "blender_manifest.toml");
    if (await (0, utils_1.pathExists)(manifestPath)) {
        return true;
    }
    let initPath = path.join(folderPath, '__init__.py');
    try {
        let content = await (0, utils_1.readTextFile)(initPath);
        return content.includes('bl_info');
    }
    catch {
        return false;
    }
}

alreay does the job. I made the commit because I had some trouble as described in #191, and this commit + pin dependency can fix this.

Now I can't reproduce my problem either. So maybe I can close it for now. Thanks for the info!

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

Successfully merging this pull request may close these issues.

2 participants