JoseConseco / texture_synthesis

texture_synthesis
GNU General Public License v3.0
97 stars 6 forks source link

Please extend the addon to also work on macOS and Linux #5

Closed robw001 closed 4 years ago

robw001 commented 4 years ago

The texture-synthesis executable is available for several platforms, including Windows, macOS and Linux.

At current, the blender addon only works for MS Windows. It specifically looks for "texture-synthesis.exe' and fails to find the macOS executable "texture-synthesis". Please update the addon to include other platforms.

I got the addon to work on macOS by editing addon_preferences.py as follows:

import os, platform
(...)

class TextureSynthPreferences(bpy.types.AddonPreferences):
    bl_idname = addon_name_lowercase()

    def check_ts_exist(self, context):
        absPath, ts_exists = check_file_exist(self.text_synth_path)
        self['text_synth_path'] = absPath
        if platform.system() in ["Darwin","Linux"]:
            if ts_exists and os.path.basename(absPath) == "texture-synthesis":
                self.display_info = "texture-synthesis found in: " + absPath
        else:
            if ts_exists and os.path.basename(absPath) == "texture-synthesis.exe":
                self.display_info = "texture-synthesis.exe found in: " + absPath
            else:
                self.display_info = "texture-synthesis.exe not found in: " + absPath

(...)
AndreaMonzini commented 4 years ago

In GNU/Linux as alternative i just renamed the executable binary synthesis to synthesis.exe and it works. Link to the to binary releases: https://github.com/EmbarkStudios/texture-synthesis/releases

robw001 commented 4 years ago

Actually, I'd like to see the problem fixed, not the symptom. Renaming the original executable to make this addon work is not a fix.

An even cleaner way to fix the code would be like this:

import os, platform

(...)

class TextureSynthPreferences(bpy.types.AddonPreferences):
    bl_idname = addon_name_lowercase()

    ts_executable = "texture-synthesis"
    if platform.system() == "Windows":
        tx_executable += ".exe"

    def check_ts_exist(self, context):
        absPath, ts_exists = check_file_exist(self.text_synth_path)
        self['text_synth_path'] = absPath

        if ts_exists and os.path.basename(absPath) == tx_executable:
            self.display_info = "texture-synthesis executable found in: " + absPath
        else:
            self.display_info = "texture-synthesis executable not found in: " + absPath

(...)
JoseConseco commented 4 years ago

Fixed in 1.1 update using: if platform.system() == "Windows"

robw001 commented 4 years ago

Thanks!