diegogarciahuerta / tk-substancepainter

:moyai: Shotgun Toolkit Engine for Allegorithmic Substance Painter https://www.allegorithmic.com/products/substance-painter
Other
45 stars 37 forks source link

Plugin directory for non-default documents folder #2

Closed alfonsocasadodiez closed 5 years ago

alfonsocasadodiez commented 5 years ago

Hello, I've been trying to run the plugin on my personal workstation which has most of the main folders moved to a secondary drive (i.e: D:\Documents\Allegorithmic).

Looking at the console output I can see that the files are being copied to the default documents folder instead of the actual one, rendering the plugin unusable as far as my understanding goes. I've tried to move the files manually to the correct path but I'm getting on the logs on Substance that the connection to toolkit has been lost, without any chances of getting it to work 😢

2019-05-19 20:09:19,559 [    INFO] [PROXY] running "&SGTK_SUBSTANCEPAINTER_ENGINE_STARTUP=C:/Users/alfon/AppData/Roaming/Shotgun/bundle_cache/git/tk-substancepainter/v1.1.0/startup/bootstrap.py&SGTK_SUBSTANCEPAINTER_ENGINE_PORT=60505&SGTK_SUBSTANCEPAINTER_SGTK_MODULE_PATH=C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python&SGTK_SUBSTANCEPAINTER_ENGINE_PYTHON=C:/Program Files/Shotgun/Python/python.exe"
2019-05-19 20:09:19,561 [    INFO] [PROXY] Updating scripts...: C:\Users\alfon\AppData\Roaming\Shotgun\bundle_cache\git\tk-substancepainter\v1.1.0\resources\plugins
2019-05-19 20:09:19,562 [    INFO] [PROXY]                      scripts_folder: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins
2019-05-19 20:09:19,562 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\CommandServer.qml
2019-05-19 20:09:19,562 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\icons\sg_hover.png
2019-05-19 20:09:19,563 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\icons\sg_idle.png
2019-05-19 20:09:19,565 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\LICENSE
2019-05-19 20:09:19,565 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\main.qml
2019-05-19 20:09:19,565 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\menu.qml
2019-05-19 20:09:19,566 [    INFO] [PROXY] Same file, skipping: C:\Users\alfon/Documents/Allegorithmic/Substance Painter/plugins\shotgun_bridge\plugin.json

image

diegogarciahuerta commented 5 years ago

Hi Alfonso,

Thanks for taking a look at the engine. The scripts are copied to whatever the documents folder is for your system. I used this code to find the :

user_scripts_path = (
            os.path.expanduser(r'~/Documents/Allegorithmic/Substance Painter/plugins')
        )

which according to the python documentation, it resolves in whatever your home folder is for your platform.

At the time, I took a look at how to configure this, but it seems like substance painter expects the plugins to be there. It seems to not have an environment variable to specify where to search for plugins. People have already requested this feature though.

environment-variable-support

Do you have other substance painter plugins installed in D:\Documents\Allegorithmic ?

As for the engine trying to reconnect, without more information it is a bit tricky. Would you mind checking the logs from the shotgun engine and see if there is more details, please ? tk-substancepainter.log Where-Are-My-Log-Files

alfonsocasadodiez commented 5 years ago

About the home folder, the fact is that the user profile folder is still in C:/Users/ mostly for avoiding issues with AppData. I've checked this thread that gets around this issue by using this snip of code that gets directly the documents folder path which will probably make it work out

import ctypes.wintypes
CSIDL_PERSONAL = 5       # My Documents
SHGFP_TYPE_CURRENT = 0   # Get current, not default value

buf= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)

print(buf.value)

Checking the logs, looks like tk-substancepainter is requiring the tk-framework-unrealqt

2019-05-19 20:33:53,637 [25400 DEBUG sgtk.core.log] Debug logging enabled. To permanently enable it, set the TK_DEBUG environment variable.
2019-05-19 20:33:53,637 [25400 DEBUG sgtk.core.log] Setting TK_DEBUG in the environment for this session. This ensures that subprocesses spawned from this process will inherit the global debug logging setting from this process.
2019-05-19 20:33:53,637 [25400 DEBUG sgtk.env.project.tk-substancepainter] Detected setting 'config/env/project.yml:tk-substancepainter.debug_logging: true' in your environment configuration. Turning on debug output.
2019-05-19 20:33:53,640 [25400 ERROR sgtk.ext.__main__] Shotgun Error | SubstancePainter engine | Shotgun: Could not start engine. Details: The framework instance tk-framework-unrealqt_v1.x.x required by tk-substancepainter v1.1.0 can not be found in environment Environment project.yml. 
The currently installed frameworks are: 
Name: 'tk-framework-shotgunutils', Version: 'v5.6.1'
Name: 'tk-framework-widget', Version: 'v0.2.7'
Name: 'tk-framework-qtwidgets', Version: 'v2.8.3'
Name: 'tk-framework-adobe', Version: 'v1.0.2'
Name: 'tk-framework-shotgunutils', Version: 'v4.4.15'
Name: 'tk-framework-adminui', Version: 'v0.5.2'
Name: 'tk-framework-desktopserver', Version: 'v1.3.7'Traceback (most recent call last):
  File "C:/Users/alfon/AppData/Roaming/Shotgun/bundle_cache/git/tk-substancepainter/v1.1.0/startup/bootstrap.py", line 79, in start_toolkit_classic
    engine = sgtk.platform.start_engine(env_engine, context.sgtk, context)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python\tank\platform\engine.py", line 2809, in start_engine
    return _start_engine(engine_name, tk, None, context)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python\tank\platform\engine.py", line 2956, in _start_engine
    engine = class_obj(tk, new_context, engine_name, env)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\bundle_cache\git\tk-substancepainter\v1.1.0\engine.py", line 150, in __init__
    Engine.__init__(self, *args, **kwargs)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python\tank\platform\engine.py", line 149, in __init__
    setup_frameworks(self, self, self.__env, descriptor)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python\tank\platform\framework.py", line 226, in setup_frameworks
    framework_instance_names = validation.validate_and_return_frameworks(parent_descriptor, env)
  File "C:\Users\alfon\AppData\Roaming\Shotgun\u-tad\p124c119.basic.desktop\cfg\install\core\python\tank\platform\validation.py", line 246, in validate_and_return_frameworks
    raise TankError(msg)
TankError: The framework instance tk-framework-unrealqt_v1.x.x required by tk-substancepainter v1.1.0 can not be found in environment Environment project.yml. 
The currently installed frameworks are: 
Name: 'tk-framework-shotgunutils', Version: 'v5.6.1'
Name: 'tk-framework-widget', Version: 'v0.2.7'
Name: 'tk-framework-qtwidgets', Version: 'v2.8.3'
Name: 'tk-framework-adobe', Version: 'v1.0.2'
Name: 'tk-framework-shotgunutils', Version: 'v4.4.15'
Name: 'tk-framework-adminui', Version: 'v0.5.2'
Name: 'tk-framework-desktopserver', Version: 'v1.3.7'
diegogarciahuerta commented 5 years ago

So, if I understood well, your Documents folder has been changed to live in D:\ drive. Do Substance Painter plugins live there too when you install it ? ( D:\Documents\Allegorithmic\Substance Painter\plugins )

Regarding the missing framework, I would have thought that running the cache_apps command in hte config folder (as listed in the docs): tank cache_apps would have downloaded that framework as well, since the engine depends on it.

I'm going to test if this is enough, but in case it is not, the fix is to add the framework to the frameworks.yml file:

  # unrealqt - PySide build for Unreal (Windows-only)
  tk-framework-unrealqt_v1.x.x:
    location:
      type: git_branch
      path: https://github.com/shotgunsoftware/tk-framework-unrealqt.git
      branch: master
      version: 58c2f7b

If you want to give this a try on your side and let me know, that would be great.

alfonsocasadodiez commented 5 years ago

So, if I understood well, your Documents folder has been changed to live in D:\ drive. Do Substance Painter plugins live there too when you install it ? ( D:\Documents\Allegorithmic\Substance Painter\plugins )

Indeed that's the case. It's the normal way of redirecting folders by setting the custom location on the properties of each folder.

About the unrealqt we cannot cache the apps as usual, as we are currently running a cloud configuration for easier deployment on artist's personal workstations (we depend on a decentralized structure with a common mountpoint) on the expense of not being able to run tank commands. Thanks for the framework snippet :) 👍

diegogarciahuerta commented 5 years ago

Changes suggested to frameworks.yml can be found now here: commit f46fb8e50306d5a71fa3e785f3dfe811fab3c6e3

3th3r commented 5 years ago

Hi everybody, I ran into the same error,

In Painter I got: [Plugin - shotgun_bridge] (DEBUG) Shotgun engine | Starting tk-substancepainter engine with params: "C:/Program Files/Shotgun/Python/python.exe" "C:/Users/3g0/AppData/Roaming/Shotgun/bundle_cache/git/tk-substancepainter.git/v1.1.1/startup/bootstrap.py" [Plugin - shotgun_bridge] Shotgun engine | Shotgun Substance Painter Engine connection was lost. Restarting engine...

My Painter configuration is the default one, and I'm also using a distributed configuration. I use the version 1.1.1 of your plugin. Also I was forced to declare the path of substance into the "software page" and manually add an icon. Both weren't showing up on shotgun desktop.

Windows 10, substance 2018.2.2 ( an "eye-patch" version on my personal computer, a regular one at work)

alfonsocasadodiez commented 5 years ago

Have you correctly merged your frameworks.yml file so it has this snippet in it? Remember to follow all the instructions to get it working :)

  # unrealqt - PySide build for Unreal (Windows-only)
  tk-framework-unrealqt_v1.x.x:
    location:
      type: git_branch
      path: https://github.com/shotgunsoftware/tk-framework-unrealqt.git
      branch: master
      version: 58c2f7b
3th3r commented 5 years ago

Yes, I have merged the untealqt, and he is present in the bundle_cache.

I will fallback on previous version of my config, and redone all the steps, it's maybe a error on my side. Also I will try withe last versrion of substance, just in case.

alfonsocasadodiez commented 5 years ago

You can merge in my config if you want to quickly test out if that works for you, just merge in your roots.yml on the config I've published and try :)

3th3r commented 5 years ago

No need, it was Substance Painter the 'problem', it is needed to have at least a 2019.1.0 for the shotgun integration to work. Maybe an earlier version (2019.0.0), but 2018 seem's not to be compatible.

It work perfectly, thanks a lot.

alfonsocasadodiez commented 5 years ago

Closing thread!