diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example similarity index 63% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example index 080b4e92f7..29c1739992 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example @@ -4,18 +4,18 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # -# -- This line is 75 characters ------------------------------------------- +# ------------------------------------------------------------------------- # Sets up the project environment for python scripting using the export DYNACONF_COMPANY=Amazon -# if a lumberyard project isn't set use this gem -export DYNACONF_LY_PROJECT=DccScriptingInterface -export DYNACONF_LY_PROJECT_PATH=`pwd` -export DYNACONF_LY_DEV=${LY_PROJECT_PATH}\..\..\..\.. +# if a O3DE project isn't set use this gem +export DYNACONF_O3DE_PROJECT=DccScriptingInterface +export DYNACONF_O3DE_PROJECT_PATH=`pwd` +export DYNACONF_O3DE_DEV=${O3DE_PROJECT_PATH}\..\..\..\.. # LY build folder -export DYNACONF_LY_BUILD_PATH=${LY_DEV}\build -export DYNACONF_LY_BIN_PATH=${LY_BUILD_PATH}\bin\profile +export DYNACONF_O3DE_BUILD_PATH=${O3DE_DEV}\build +export DYNACONF_O3DE_BIN_PATH=${O3DE_BUILD_PATH}\bin\profile # default IDE and debug settings #export DYNACONF_DCCSI_GDEBUG=false @@ -24,9 +24,9 @@ export DYNACONF_DCCSI_GDEBUGGER=WING export DYNACONF_DCCSI_LOGLEVEL=20 # defaults for DccScriptingInterface (DCCsi) -export DYNACONF_DCCSIG_PATH=${LY_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +export DYNACONF_DCCSIG_PATH=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface -# set up default python interpreter (Lumberyard) +# set up default python interpreter (O3DE) # we may want to entirely remove these and rely on config.py to dynamically set up # however VScode can be configured with a .env so might be valueable to keep export DYNACONF_DCCSI_PY_VERSION_MAJOR=3 @@ -40,13 +40,13 @@ export DYNACONF_DCCSI_PYTHON_PATH=${DCCSIG_PATH}\3rdParty\Python export DYNACONF_DCCSI_PYTHON_LIB_PATH=${DCCSI_PYTHON_PATH}\Lib\${DCCSI_PY_VERSION_MAJOR}.x\${DCCSI_PY_VERSION_MAJOR}.${DCCSI_PY_VERSION_MINOR}.x\site-packages # TO DO: figure out how to best deal with OS folder (i.e. 'windows') -export DYNACONF_DCCSI_PYTHON_INSTALL=${LY_DEV}\python -export DYNACONF_DDCCSI_PY_BASE=${DCCSI_PYTHON_INSTALL}\python.cmd +export DYNACONF_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python +export DYNACONF_DCCSI_PY_BASE=${O3DE_PYTHON_INSTALL}\python.cmd # set up Qt / PySide2 # TO DO: These should NOT be set in the global env as they will cause conflicts # with other Qt apps (like DCC tools), only set in local.env, or modify config.py # for utils/tools/apps that need them ( see config.init_ly_pyside() ) -#export DYNACONF_QTFORPYTHON_PATH=${LY_DEV}\Gems\QtForPython\3rdParty\pyside2\windows\release -#export DYNACONF_QT_PLUGIN_PATH=${LY_BUILD_PATH}\bin\profile\EditorPlugins -#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${LY_BUILD_PATH}\bin\profile\EditorPlugins\platforms +#export DYNACONF_QTFORPYTHON_PATH=${O3DE_DEV}\Gems\QtForPython\3rdParty\pyside2\windows\release +#export DYNACONF_QT_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins +#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins\platforms diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.gitignore index 9ad4717873..086d189eba 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.gitignore +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.gitignore @@ -8,4 +8,6 @@ workspace.xml # Ignore dynaconf secret files .secrets.* settings.local.json -azpy/_sample_package_/* \ No newline at end of file +azpy/_sample_package_/* +.env +settings_export.json.tmp \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.p4ignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.p4ignore index dedde06bc4..2ff9b6b614 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.p4ignore +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.p4ignore @@ -19,3 +19,4 @@ __WIP__/* !.gitignore .secrets.* settings.local.json +.env \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt new file mode 100644 index 0000000000..7f5a72fb1c --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt @@ -0,0 +1,36 @@ +DccScriptingInterface (DCCsi) + +This location can be extended with additional 3rdParty Python Utils, Tools, Packages, etc. + +These are not installed or distributed with O3DE + +However, there is some stubbed scaffolding in place. + +This is a bootstrapped sandbox for installing python libs (version bootstrapped procedurally): +C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages +C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\3.x\3.7.x\site-packages + +Any libs installed to this location will be accessible (use at your own risk) + +For instance, if you want to add py2.7 compatible libs, for apps like Maya2020: +"C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Tools\DCC\Maya\readme.txt" + +These pyside2-tools can be useful, and they are not pip installed, nor distributed. +C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\pyside2-tools + +pyside2-tools instructions: + +1. clone the repo in this location: C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python + >git clone https://github.com/pyside/pyside2-tools + +2. to use as a python package ... + find this and copy: + "< local DCCsi >\3rdParty\Python\pyside2-tools\pyside2uic\__init__.py.in" + + and rename to this: + "< local DCCsi >\3rdParty\Python\pyside2-tools\pyside2uic\__init__.py" + +3. add to PYTHONPATH: < local DCCsi >\3rdParty\Python + in .py something like: site.addsitedir(DCCSI_PYSIDE2_TOOLS) + +See: "< local DCCsi >\config.py" \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py index d417c572e9..406e2b04ff 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py @@ -7,9 +7,9 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # -# -- This line is 75 characters ------------------------------------------- +# ------------------------------------------------------------------------- """This module is for use in boostrapping the DccScriptingInterface Gem -with Lumberyard. Note: this boostrap is only designed fo be py3 compatible. +with O3DE. Note: this boostrap is only designed fo be py3 compatible. If you need DCCsi access in py27 (Autodesk Maya for instance) you may need to implement your own boostrapper module. Currently this is boostrapped from add_dccsi.py, as a temporty measure related to this Jira: @@ -24,40 +24,64 @@ import logging as _logging # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +_O3DE_RUNNING=None +try: + import azlmbr + _O3DE_RUNNING=True +except: + _O3DE_RUNNING=False +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # we don't use dynaconf setting here as we might not yet have access # to that site-dir. -_MODULE = 'DCCsi.bootstrap' +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'O3DE.DCCsi.bootstrap' + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) # we need to set up basic access to the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) - -# we can get basic access to the DCCsi.azpy api now -import azpy - -# early attach WingIDE debugger (can refactor to include other IDEs later) -while 0: # flag on to attemp to connect wingIDE debugger - from azpy.env_bool import env_bool - if not env_bool('DCCSI_DEBUGGER_ATTACHED', False): - # if not already attached lets do it here - from azpy.test.entry_test import connect_wing - foo = connect_wing() +_DCCSI_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..')) +_DCCSI_PATH = os.getenv('DCCSI_PATH', _DCCSI_PATH) +site.addsitedir(_DCCSI_PATH) + +# now we have azpy api access +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import ENVAR_DCCSI_LOGLEVEL +from azpy.constants import FRMT_LOG_LONG + +# set up global space, logging etc. +# set these true if you want them set globally for debugging +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) +if _DCCSI_GDEBUG: + _DCCSI_LOGLEVEL = int(10) + +_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# settings.setenv() # doing this will add the additional DYNACONF_ envars -def get_dccsi_config(DCCSIG_PATH=_DCCSIG_PATH): +# _settings.setenv() # doing this will add the additional DYNACONF_ envars +def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH): """Convenience method to set and retreive settings directly from module.""" # we can go ahead and just make sure the the DCCsi env is set - # config is SO generic this ensures we are importing a specific one - _spec_dccsi_config = importlib.util.spec_from_file_location("dccsi.config", - Path(DCCSIG_PATH, + # _config is SO generic this ensures we are importing a specific one + _spec_dccsi_config = importlib.util.spec_from_file_location("dccsi._config", + Path(DCCSI_PATH, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -65,9 +89,12 @@ def get_dccsi_config(DCCSIG_PATH=_DCCSIG_PATH): return _dccsi_config # ------------------------------------------------------------------------- -# set and retreive the base settings on import -config = get_dccsi_config() -settings = config.get_config_settings() +# set and retreive the base env context/_settings on import +_config = get_dccsi_config() +_settings = _config.get_config_settings() + +if _DCCSI_DEV_MODE: + _config.attach_debugger() # attempts to start debugger # done with basic setup # --- END ----------------------------------------------------------------- @@ -77,50 +104,99 @@ settings = config.get_config_settings() # ------------------------------------------------------------------------- if __name__ == '__main__': """Run this file as main""" + + # ------------------------------------------------------------------------- + _O3DE_RUNNING=None + try: + import azlmbr + _O3DE_RUNNING=True + except: + _O3DE_RUNNING=False + # ------------------------------------------------------------------------- + + _MODULENAME = __name__ + if _MODULENAME is '__main__': + _MODULENAME = 'O3DE.DCCsi.bootstrap' + + from azpy.constants import STR_CROSSBAR - _G_DEBUG = False - _G_TEST_PYSIDE = False + # module internal debugging flags + while 0: # temp internal debug flag + _DCCSI_GDEBUG = True + break + + # overide logger for standalone to be more verbose and log to file + import azpy + _LOGGER = azpy.initialize_logger(_MODULENAME, + log_to_file=_DCCSI_GDEBUG, + default_log_level=_DCCSI_LOGLEVEL) + # happy print + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('~ constants.py ... Running script as __main__') + _LOGGER.info(STR_CROSSBAR) + + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi Boostrap (Test)', + epilog="Will externally test the DCCsi boostrap") _config = get_dccsi_config() - _settings = config.get_config_settings() - - _log_level = int(_settings.DCCSI_LOGLEVEL) - if _G_DEBUG: - _log_level = int(10) # force debug level - _LOGGER = azpy.initialize_logger(_MODULE, - log_to_file=True, - default_log_level=_log_level) + _settings = _config.get_config_settings(enable_o3de_python=True, + enable_o3de_pyside2=True) + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') + parser.add_argument('-tp', '--test-pyside2', + type=bool, + required=False, + help='Runs Qt/PySide2 tests and reports.') + args = parser.parse_args() + + # easy overrides + if args.global_debug: + _DCCSI_GDEBUG = True + if args.developer_mode: + _DCCSI_DEV_MODE = True + _config.attach_debugger() # attempts to start debugger - # we can now grab values from the DCCsi.config.py dynamic env settings - # the rest of this block is basic debug testing the dynamic settings at boot - _LOGGER.info(f'Running module: {_MODULE}') - _LOGGER.info(f'DCCSIG_PATH: {_settings.DCCSIG_PATH}') - _LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}') - _LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}') - - _LOGGER.info(f'OS_FOLDER: {_settings.OS_FOLDER}') - _LOGGER.info(f'LY_PROJECT: {_settings.LY_PROJECT}') - _LOGGER.info(f'LY_PROJECT_PATH: {_settings.LY_PROJECT_PATH}') - _LOGGER.info(f'LY_DEV: {_settings.LY_DEV}') - _LOGGER.info(f'LY_BUILD_PATH: {_settings.LY_BUILD_PATH}') - _LOGGER.info(f'LY_BIN_PATH: {_settings.LY_BIN_PATH}') + if _DCCSI_GDEBUG: + _LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}') + _LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}') + _LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}') - _LOGGER.info(f'DCCSIG_PATH: {_settings.DCCSIG_PATH}') - _LOGGER.info(f'DCCSI_PYTHON_LIB_PATH: {_settings.DCCSI_PYTHON_LIB_PATH}') - _LOGGER.info(f'DDCCSI_PY_BASE: {_settings.DDCCSI_PY_BASE}') + _LOGGER.info(f'DCCSI_OS_FOLDER: {_settings.DCCSI_OS_FOLDER}') + _LOGGER.info(f'O3DE_PROJECT: {_settings.O3DE_PROJECT}') + _LOGGER.info(f'O3DE_PROJECT_PATH: {_settings.O3DE_PROJECT_PATH}') + _LOGGER.info(f'O3DE_DEV: {_settings.O3DE_DEV}') + _LOGGER.info(f'O3DE_BUILD_PATH: {_settings.O3DE_BUILD_PATH}') + _LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}') + + _LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}') + _LOGGER.info(f'DCCSI_PYTHON_LIB_PATH: {_settings.DCCSI_PYTHON_LIB_PATH}') + _LOGGER.info(f'DCCSI_PY_BASE: {_settings.DCCSI_PY_BASE}') - if _G_TEST_PYSIDE: + if _DCCSI_GDEBUG or args.test_pyside2: try: import PySide2 except: # set up Qt/PySide2 access and test - _settings = _config.get_config_settings(setup_ly_pyside=True) + _settings = _config.get_config_settings(enable_o3de_pyside2=True) import PySide2 _LOGGER.info(f'PySide2: {PySide2}') - _LOGGER.info(f'LY_BIN_PATH: {_settings.LY_BIN_PATH}') + _LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}') _LOGGER.info(f'QT_PLUGIN_PATH: {_settings.QT_PLUGIN_PATH}') _LOGGER.info(f'QT_QPA_PLATFORM_PLUGIN_PATH: {_settings.QT_QPA_PLATFORM_PLUGIN_PATH}') _config.test_pyside2() + + if not _O3DE_RUNNING: + # return + sys.exit() # --- END ----------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/README.txt new file mode 100644 index 0000000000..9a3efe589a --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/README.txt @@ -0,0 +1,87 @@ +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +This folder contains the DccScriptingInterface (DCCsi) for O3DE + +Notice: The old \\SDK folder is being replaced with \\Tools +The scripts in \\SDK may be out of data (and not run) +When scripts are finished being updated and refactored into \\Tools the \\SDK will be removed + +What is the DCCsi? + +- A shared development environment for technical art oriented to working with Python across a number of DCC tools. +- Leverage the existing python ecosystem for technical art. +- Integrate a DCC app like Substance (or Substance SAT api) from the Python driven VFX and Games ecosystem. +- Extend O3DE and unlock its potential for content creators, and the Technical Artists that service them. + +Tenets: +(1) Interoperability: Design DCC-agnostic modules and DCC-bespoke modules + to work together efficiently and intuitively. + +(2) Encapsulation: Define a module in terms of its essential features and interface to other components, + to facilitate logical layered design and easy maintenance. + +(3) Extensibility: Design the tool set to be easily extensible with new functionality and new tools. + Individual pieces should have a generic communication mechanism to allow newly written tools to slot cleanly and transparently into the tool chain. + +What is provided (High Level): +- DCC-Agnostic Python Framework (as a modular Gem) related to multiple integrations for: + O3DE Editor (python scripting, utils and PySide2 tools) + DCC applications and their Python APIs/SDKs + Custom standalone tools and utils (python based) + external from cmd line + external standalone + integrated to run within O3DE Editor + +What is provided (by folder): + +\3rdParty: Allows third party libs/packages to be integrated outside of O3DE + Example: O3DE is py3, Maya 2020 (and earlier) is py27 + O3DE provides a patterns for Gems to provide a requirements.txt + See: + DccScriptingInterface\reqiurements.txt + ^ These packages will be fetched and installed into O3DE python at build time + + This means for some applications like Maya we need another way to add the same packages + See: + DccScriptingInterface\SDK\Maya\readme.txt + DccScriptingInterface\SDK\Maya\requirements.txt + DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages\* + + Packages that reside in 3rdParty are never commited to the repo (only fetched+installed) + +\Assets: All O3DE Gems can maintain an asset folder + If a Gem contains an \Asset folder, these assets are folded into the projects asset data + These assets are processed by the Asset Processor for use in the Editor and Runtime + In the DCCsi the \Assets folder primarily contains TestData + +\azpy Core (shared) API, A pure python Package and Modules + +\Code Contains the bare bones C++ scaffold to build and integrate the Gem with O3DE + Notes: portions of the DCCsi can be utilized outside of O3DE + thus this Gem doens't have to be enabled and built for some use cases + +\Editor This folder provides an entry point pattern for extending O3DE Editor with python + When a Gem is enabled ... + If the following if found, it will be executed when the Editor boots: + "Editor\Scripts\bootstrap.py" + + This can be used to initialize code access, extend the editor (PySide2), etc. + +\Tools This is where the following is maintained: + +\Tools\DCC Integration for DCC tools: + configuration of tool (managed env, etc.) + bootstrapping, such as providing the tool access to azpy api code + extensibility, such as adding new functionality or tool to the app + +\Tools\DCC\Maya An example of adding a integration for Autodesk Maya + +\Tools\Env\Windows This provides a .bat file managed env to configure and bootsrap windows apps +\Tools\Launchers\windows Provides .bat files based tool launchers for windows (accesses env) + diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/minspect.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/minspect.py deleted file mode 100644 index 760807042c..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/minspect.py +++ /dev/null @@ -1,132 +0,0 @@ -""" -Copyright (c) Contributors to the Open 3D Engine Project. -For complete copyright and license terms please see the LICENSE at the root of this distribution. - -SPDX-License-Identifier: Apache-2.0 OR MIT -""" -# ------------------------------------------------------------------------- - -import pymel.core as pmc -import sys -import types - - -def syspath(): - print 'sys.path:' - for p in sys.path: - print ' ' + p - - -def info(obj): - """Prints information about the object.""" - - lines = ['Info for %s' % obj.name(), - 'Attributes:'] - # Get the name of all attributes - for a in obj.listAttr(): - lines.append(' ' + a.name()) - lines.append('MEL type: %s' % obj.type()) - lines.append('MRO:') - lines.extend([' ' + t.__name__ for t in type(obj).__mro__]) - result = '\n'.join(lines) - print result - - -def _is_pymel(obj): - try: # (1) - module = obj.__module__ # (2) - except AttributeError: # (3) - try: - module = obj.__name__ # (4) - except AttributeError: - return None # (5) - return module.startswith('pymel') # (6) - - -def _py_to_helpstr(obj): - if isinstance(obj, basestring): - return 'search.html?q=%s' % (obj.replace(' ', '+')) - if not _is_pymel(obj): - return None - if isinstance(obj, types.ModuleType): - return ('generated/%(module)s.html#module-%(module)s' % - dict(module=obj.__name__)) - if isinstance(obj, types.MethodType): - return ('generated/classes/%(module)s/' - '%(module)s.%(typename)s.html' - '#%(module)s.%(typename)s.%(methname)s' % dict( - module=obj.__module__, - typename=obj.im_class.__name__, - methname=obj.__name__)) - if isinstance(obj, types.FunctionType): - return ('generated/functions/%(module)s/' - '%(module)s.%(funcname)s.html' - '#%(module)s.%(funcname)s' % dict( - module=obj.__module__, - funcname=obj.__name__)) - if not isinstance(obj, type): - obj = type(obj) - return ('generated/classes/%(module)s/' - '%(module)s.%(typename)s.html' - '#%(module)s.%(typename)s' % dict( - module=obj.__module__, - typename=obj.__name__)) - - -def test_py_to_helpstr(): - def dotest(obj, ideal): - result = _py_to_helpstr(obj) - assert result == ideal, '%s != %s' % (result, ideal) - dotest('maya rocks', 'search.html?q=maya+rocks') - dotest(pmc.nodetypes, - 'generated/pymel.core.nodetypes.html' - '#module-pymel.core.nodetypes') - dotest(pmc.nodetypes.Joint, - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint') - dotest(pmc.nodetypes.Joint(), - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint') - dotest(pmc.nodetypes.Joint().getTranslation, - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint.getTranslation') - dotest(pmc.joint, - 'generated/functions/pymel.core.animation/' - 'pymel.core.animation.joint.html' - '#pymel.core.animation.joint') - dotest(object(), None) - dotest(10, None) - dotest([], None) - dotest(sys, None) - - -def test_py_to_helpstrFAIL(): - assert 1 == 2, '1 != 2' - - -import webbrowser # (1) -HELP_ROOT_URL = ('http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/PyMel/')# (2) - - -def pmhelp(obj): # (3) - """Gives help for a pymel or python object. - - If obj is not a PyMEL object, use Python's built-in - `help` function. - If obj is a string, open a web browser to a search in the - PyMEL help for the string. - Otherwise, open a web browser to the page for the object. - """ - tail = _py_to_helpstr(obj) - if tail is None: - help(obj) # (4) - else: - webbrowser.open(HELP_ROOT_URL + tail) # (5) - - -if __name__ == '__main__': - test_py_to_helpstr() - print 'Tests ran successfully.' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/launcher.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/launcher.bat deleted file mode 100644 index fb07178344..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/launcher.bat +++ /dev/null @@ -1,85 +0,0 @@ -@echo off - -REM -REM Copyright (c) Contributors to the Open 3D Engine Project. -REM For complete copyright and license terms please see the LICENSE at the root of this distribution. -REM -REM SPDX-License-Identifier: Apache-2.0 OR MIT -REM -REM - -:: Set up and run LY Python CMD prompt -:: Sets up the DccScriptingInterface_Env, -:: Puts you in the CMD within the dev environment - -:: Set up window -TITLE Lumberyard DCC Scripting Interface Cmd -:: Use obvious color to prevent confusion (Grey with Yellow Text) -COLOR 8E - -%~d0 -cd %~dp0 - -:: Keep changes local -SETLOCAL enableDelayedExpansion - -:: This maps up to the \Dev folder -IF "%DEV_REL_PATH%"=="" (set DEV_REL_PATH=..\..\..\..\..\..\..\..\..) - -:: Change to root Lumberyard dev dir -:: Don't use the LY_DEV so we can test that ENVAR!!! -CD /d %DEV_REL_PATH% -set Rel_Dev=%CD% -echo Rel_Dev = %Rel_Dev% -:: Restore original directory -popd - -set DCCSI_PYTHON_INSTALL=%Rel_Dev%\Tools\Python\3.7.5\windows - -:: add to the PATH -SET PATH=%DCCSI_PYTHON_INSTALL%;%PATH% - -:: dcc scripting interface gem path -set DCCSIG_PATH=%Rel_Dev%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface -echo DCCSIG_PATH = %DCCSIG_PATH% - -:: add to the PATH -SET PATH=%DCCSIG_PATH%;%PATH% - -:: Constant Vars (Global) -:: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=false) -echo DCCSI_GDEBUG = %DCCSI_GDEBUG% -:: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=false) -echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% -:: sets debugger, options: WING, PYCHARM -IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) -echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% - -echo. -echo _____________________________________________________________________ -echo. -echo ~ LY DCCsi, DCC Material Converter -echo _____________________________________________________________________ -echo. - -:: Change to root dir -CD /D %DCCSIG_PATH% - -:: add to the PATH -SET PATH=%DCCSIG_PATH%;%PATH% - -set PYTHONPATH=%DCCSIG_PATH%;%PYTHONPATH% - -CALL %DCCSI_PYTHON_INSTALL%\python.exe "%DCCSIG_PATH%\SDK\Maya\Scripts\Python\kitbash_converter\standalone.py" - - -ENDLOCAL - -:: Return to starting directory -POPD - -:END_OF_FILE - -exit /b 0 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py index e554b1ca68..d0e9759208 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py @@ -51,8 +51,8 @@ module_name = 'kitbash_converter.main' log_file_path = os.path.join(settings.DCCSI_LOG_PATH, f'{module_name}.log') _log_level = int(20) -_G_DEBUG = True -if _G_DEBUG: +_DCCSI_GDEBUG = True +if _DCCSI_GDEBUG: _log_level = int(10) from azpy.constants import FRMT_LOG_LONG diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Cmd.bat deleted file mode 100644 index ce118d7710..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Cmd.bat +++ /dev/null @@ -1,45 +0,0 @@ -:: coding:utf-8 -:: !/usr/bin/python -:: -:: Copyright (c) Contributors to the Open 3D Engine Project. -:: For complete copyright and license terms please see the LICENSE at the root of this distribution. -:: -:: SPDX-License-Identifier: Apache-2.0 OR MIT -:: -:: - -@echo off -:: Set up and run LY Python CMD prompt -:: Sets up the DccScriptingInterface_Env, -:: Puts you in the CMD within the dev environment - -:: Set up window -TITLE Lumberyard DCC Scripting Interface Cmd -:: Use obvious color to prevent confusion (Grey with Yellow Text) -COLOR 8E - -%~d0 -cd %~dp0 -PUSHD %~dp0 - -:: Keep changes local -SETLOCAL enableDelayedExpansion - -CALL %~dp0\Project_Env.bat - -echo. -echo _____________________________________________________________________ -echo. -echo ~ LY DCC Scripting Interface CMD ... -echo _____________________________________________________________________ -echo. - -:: Create command prompt with environment -CALL %windir%\system32\cmd.exe - -ENDLOCAL - -:: Return to starting directory -POPD - -:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Maya_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Maya_2020.bat deleted file mode 100644 index 32e910790e..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_Maya_2020.bat +++ /dev/null @@ -1,68 +0,0 @@ -:: coding:utf-8 -:: !/usr/bin/python -:: -:: Copyright (c) Contributors to the Open 3D Engine Project. -:: For complete copyright and license terms please see the LICENSE at the root of this distribution. -:: -:: SPDX-License-Identifier: Apache-2.0 OR MIT -:: -:: - -@echo off -:: Launches maya with a bunch of local hooks for Lumberyard -:: ToDo: move all of this to a .json data driven boostrapping system - -%~d0 -cd %~dp0 -PUSHD %~dp0 - -echo ________________________________ -echo ~ calling PROJ_Env.bat - -:: Keep changes local -SETLOCAL enableDelayedExpansion - -:: PY version Major -set DCCSI_PY_VERSION_MAJOR=2 -echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% - -:: PY version Major -set DCCSI_PY_VERSION_MINOR=7 -echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% - -:: Maya Version -set MAYA_VERSION=2020 -echo MAYA_VERSION = %MAYA_VERSION% - -:: if a local customEnv.bat exists, run it -IF EXIST "%~dp0Project_Env.bat" CALL %~dp0Project_Env.bat - -echo ________________________________ -echo Launching Maya %MAYA_VERSION% for Lumberyard... - -:::: Set Maya native project acess to this project -::set MAYA_PROJECT=%LY_PROJECT% -::echo MAYA_PROJECT = %MAYA_PROJECT% - -:: DX11 Viewport -Set MAYA_VP2_DEVICE_OVERRIDE = VirtualDeviceDx11 - -:: Default to the right version of Maya if we can detect it... and launch -IF EXIST "%MAYA_LOCATION%\bin\Maya.exe" ( - start "" "%MAYA_LOCATION%\bin\Maya.exe" %* -) ELSE ( - Where maya.exe 2> NUL - IF ERRORLEVEL 1 ( - echo Maya.exe could not be found - pause - ) ELSE ( - start "" Maya.exe %* - ) -) - -:: Return to starting directory -POPD - -:END_OF_FILE - -exit /b 0 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_WingIDE-7-1.bat deleted file mode 100644 index 4d82bd3e16..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Launch_WingIDE-7-1.bat +++ /dev/null @@ -1,81 +0,0 @@ -:: coding:utf-8 -:: !/usr/bin/python -:: -:: Copyright (c) Contributors to the Open 3D Engine Project. -:: For complete copyright and license terms please see the LICENSE at the root of this distribution. -:: -:: SPDX-License-Identifier: Apache-2.0 OR MIT -:: -:: - -@echo off -:: Launches Wing IDE and the DccScriptingInterface Project Files - -echo. -echo _____________________________________________________________________ -echo. -echo ~ Setting up LY DCCsi WingIDE Dev Env... -echo _____________________________________________________________________ -echo. - -:: Store current dir -%~d0 -cd %~dp0 -PUSHD %~dp0 - -:: Keep changes local -SETLOCAL enableDelayedExpansion - -SET ABS_PATH=%~dp0 -echo Current Dir, %ABS_PATH% - -:: WingIDE version Major -SET WING_VERSION_MAJOR=7 -echo WING_VERSION_MAJOR = %WING_VERSION_MAJOR% - -:: WingIDE version Major -SET WING_VERSION_MINOR=1 -echo WING_VERSION_MINOR = %WING_VERSION_MINOR% - -:: note the changed path from IDE to Pro -set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %WING_VERSION_MAJOR%.%WING_VERSION_MINOR% -echo WINGHOME = %WINGHOME% - -CALL %~dp0\Project_Env.bat - -echo. -echo _____________________________________________________________________ -echo. -echo ~ WingIDE Version %WING_VERSION_MAJOR%.%WING_VERSION_MINOR% -echo _____________________________________________________________________ -echo. - -SET WING_PROJ=%DCCSIG_PATH%\Solutions\.wing\DCCsi_%WING_VERSION_MAJOR%x.wpr -echo WING_PROJ = %WING_PROJ% - -echo. -echo _____________________________________________________________________ -echo. -echo ~ Launching %LY_PROJECT% project in WingIDE %WING_VERSION_MAJOR%.%WING_VERSION_MINOR% ... -echo _____________________________________________________________________ -echo. - - -IF EXIST "%WINGHOME%\bin\wing.exe" ( - start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" -) ELSE ( - Where wing.exe 2> NUL - IF ERRORLEVEL 1 ( - echo wing.exe could not be found - pause - ) ELSE ( - start "" wing.exe "%WING_PROJ%" - ) -) - -ENDLOCAL - -:: Return to starting directory -POPD - -:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Project_Env.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Project_Env.bat deleted file mode 100644 index f958d98616..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/Project_Env.bat +++ /dev/null @@ -1,72 +0,0 @@ -:: coding:utf-8 -:: !/usr/bin/python -:: -:: Copyright (c) Contributors to the Open 3D Engine Project. -:: For complete copyright and license terms please see the LICENSE at the root of this distribution. -:: -:: SPDX-License-Identifier: Apache-2.0 OR MIT -:: -:: - -@echo off -:: Sets up environment for Lumberyard DCC tools and code access - -:: Store current dir -%~d0 -cd %~dp0 -PUSHD %~dp0 - -for %%a in (.) do set LY_PROJECT=%%~na - -echo. -echo _____________________________________________________________________ -echo. -echo ~ Setting up LY DSI PROJECT Environment ... -echo _____________________________________________________________________ -echo. - -echo LY_PROJECT = %LY_PROJECT% - -:: Put you project env vars and overrides here - -:: chanhe the relative path up to dev -set DEV_REL_PATH=../../.. -set ABS_PATH=%~dp0 - -:: Override the default maya version -set MAYA_VERSION=2020 -echo MAYA_VERSION = %MAYA_VERSION% - -set LY_PROJECT_PATH=%ABS_PATH% -echo LY_PROJECT_PATH = %LY_PROJECT_PATH% - -:: Change to root Lumberyard dev dir -CD /d %LY_PROJECT_PATH%\%DEV_REL_PATH% -set LY_DEV=%CD% -echo LY_DEV = %LY_DEV% - -CALL %LY_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Launchers\Windows\Env.bat - -rem :: Constant Vars (Global) -rem SET LYPY_GDEBUG=0 -rem echo LYPY_GDEBUG = %LYPY_GDEBUG% -rem SET LYPY_DEV_MODE=0 -rem echo LYPY_DEV_MODE = %LYPY_DEV_MODE% -rem SET LYPY_DEBUGGER=WING -rem echo LYPY_DEBUGGER = %LYPY_DEBUGGER% - -:: Restore original directory -popd - -:: Change to root dir -CD /D %ABS_PATH% - -:: if the user has set up a custom env call it -IF EXIST "%~dp0User_Env.bat" CALL %~dp0User_Env.bat - -GOTO END_OF_FILE - -:: Return to starting directory -POPD - -:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/main.py index 3b985199bb..09caef836f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/main.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/main.py @@ -80,8 +80,8 @@ module_name = 'legacy_asset_converter.main' log_file_path = os.path.join(settings.DCCSI_LOG_PATH, f'{module_name}.log') _log_level = int(20) -_G_DEBUG = True -if _G_DEBUG: +_DCCSI_GDEBUG = True +if _DCCSI_GDEBUG: _log_level = int(10) from azpy.constants import FRMT_LOG_LONG diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/minspect.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/minspect.py deleted file mode 100644 index 668382480c..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/minspect.py +++ /dev/null @@ -1,135 +0,0 @@ -# -*- coding: utf-8 -*- -# !/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# ------------------------------------------------------------------------- - -import pymel.core as pmc -import sys -import types - - -def syspath(): - print 'sys.path:' - for p in sys.path: - print ' ' + p - - -def info(obj): - """Prints information about the object.""" - - lines = ['Info for %s' % obj.name(), - 'Attributes:'] - # Get the name of all attributes - for a in obj.listAttr(): - lines.append(' ' + a.name()) - lines.append('MEL type: %s' % obj.type()) - lines.append('MRO:') - lines.extend([' ' + t.__name__ for t in type(obj).__mro__]) - result = '\n'.join(lines) - print result - - -def _is_pymel(obj): - try: # (1) - module = obj.__module__ # (2) - except AttributeError: # (3) - try: - module = obj.__name__ # (4) - except AttributeError: - return None # (5) - return module.startswith('pymel') # (6) - - -def _py_to_helpstr(obj): - if isinstance(obj, basestring): - return 'search.html?q=%s' % (obj.replace(' ', '+')) - if not _is_pymel(obj): - return None - if isinstance(obj, types.ModuleType): - return ('generated/%(module)s.html#module-%(module)s' % - dict(module=obj.__name__)) - if isinstance(obj, types.MethodType): - return ('generated/classes/%(module)s/' - '%(module)s.%(typename)s.html' - '#%(module)s.%(typename)s.%(methname)s' % dict( - module=obj.__module__, - typename=obj.im_class.__name__, - methname=obj.__name__)) - if isinstance(obj, types.FunctionType): - return ('generated/functions/%(module)s/' - '%(module)s.%(funcname)s.html' - '#%(module)s.%(funcname)s' % dict( - module=obj.__module__, - funcname=obj.__name__)) - if not isinstance(obj, type): - obj = type(obj) - return ('generated/classes/%(module)s/' - '%(module)s.%(typename)s.html' - '#%(module)s.%(typename)s' % dict( - module=obj.__module__, - typename=obj.__name__)) - - -def test_py_to_helpstr(): - def dotest(obj, ideal): - result = _py_to_helpstr(obj) - assert result == ideal, '%s != %s' % (result, ideal) - dotest('maya rocks', 'search.html?q=maya+rocks') - dotest(pmc.nodetypes, - 'generated/pymel.core.nodetypes.html' - '#module-pymel.core.nodetypes') - dotest(pmc.nodetypes.Joint, - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint') - dotest(pmc.nodetypes.Joint(), - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint') - dotest(pmc.nodetypes.Joint().getTranslation, - 'generated/classes/pymel.core.nodetypes/' - 'pymel.core.nodetypes.Joint.html' - '#pymel.core.nodetypes.Joint.getTranslation') - dotest(pmc.joint, - 'generated/functions/pymel.core.animation/' - 'pymel.core.animation.joint.html' - '#pymel.core.animation.joint') - dotest(object(), None) - dotest(10, None) - dotest([], None) - dotest(sys, None) - - -def test_py_to_helpstrFAIL(): - assert 1 == 2, '1 != 2' - - -import webbrowser # (1) -HELP_ROOT_URL = ('http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/PyMel/')# (2) - - -def pmhelp(obj): # (3) - """Gives help for a pymel or python object. - - If obj is not a PyMEL object, use Python's built-in - `help` function. - If obj is a string, open a web browser to a search in the - PyMEL help for the string. - Otherwise, open a web browser to the page for the object. - """ - tail = _py_to_helpstr(obj) - if tail is None: - help(obj) # (4) - else: - webbrowser.open(HELP_ROOT_URL + tail) # (5) - - -if __name__ == '__main__': - test_py_to_helpstr() - print 'Tests ran successfully.' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter.py index 10cdac813a..4c24a61b59 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter.py @@ -23,7 +23,7 @@ def returnStubDir(stub): break if (len(tail) == 0): path = "" - if _G_DEBUG: + if _DCCSI_GDEBUG: print('~ Debug Message: I was not able to find the ' 'path to that file (stub) in a walk-up from currnet path') break diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter_maya.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter_maya.py index 3ea7b1e5e7..3a7ec49e74 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter_maya.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/stingrayPBS_converter_maya.py @@ -24,7 +24,7 @@ def returnStubDir(stub, start_path): break if (len(tail) == 0): path = "" - if _G_DEBUG: + if _DCCSI_GDEBUG: print('~ Debug Message: I was not able to find the ' 'path to that file (stub) in a walk-up from currnet path') break diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_callbacks.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_callbacks.py index 4dda18c403..8c3b0f6a64 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_callbacks.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_callbacks.py @@ -42,7 +42,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, True) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, True) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, True) _MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_callbacks' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_defaults.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_defaults.py index d6db5e42f4..639b03c297 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_defaults.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_defaults.py @@ -37,7 +37,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_defaults' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_menu.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_menu.py index 4e85a448c1..e417324d0b 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_menu.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/set_menu.py @@ -37,7 +37,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_menu' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py index aee5563c3d..04eb027142 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py @@ -56,7 +56,7 @@ import maya.mel as mel # ------------------------------------------------------------------------- # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) #_DCCSI_DEV_MODE = True # force true for debugger testing @@ -69,7 +69,7 @@ _MODULENAME = str('{0}.{1}'.format(_APP_TAG, _TOOL_TAG)) _LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20)) _LOGGER.info('Initializing: {0}.'.format({_MODULENAME})) -_LOGGER.info('DCCSI_GDEBUG: {0}.'.format({_G_DEBUG})) +_LOGGER.info('DCCSI_GDEBUG: {0}.'.format({_DCCSI_GDEBUG})) _LOGGER.info('DCCSI_DEV_MODE: {0}.'.format({_DCCSI_DEV_MODE})) # flag to turn off setting up callbacks, until they are fully implemented @@ -175,17 +175,17 @@ try: except Exception as e: _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_SDK_PATH])) -_LY_PROJECT_PATH = None +_O3DE_PROJECT_PATH = None try: - _LY_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH] + _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) # check some env var tags (fail if no, likely means no proper code access) -_LY_DEV = _BASE_ENVVAR_DICT[ENVAR_LY_DEV] -_LY_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] -_LY_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] -_LY_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] +_O3DE_DEV = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] +_O3DE_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] +_O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] +_O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] # ------------------------------------------------------------------------- @@ -270,18 +270,18 @@ def post_startup(): install_fix_paths() # set the project workspace - #_LY_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH] - _project_workspace = os.path.join(_LY_PROJECT_PATH, TAG_MAYA_WORKSPACE) + #_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE) if os.path.isfile(_project_workspace): try: # load workspace - maya.cmds.workspace(_LY_PROJECT_PATH, openWorkspace=True) + maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) - maya.cmds.workspace(_LY_PROJECT_PATH, update=True) + maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) except Exception as e: _LOGGER.error(e) else: - _LOGGER.warning('Workspace file not found: {1}'.format(_LY_PROJECT_PATH)) + _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) # Set up Lumberyard, maya default setting from set_defaults import set_defaults @@ -292,7 +292,7 @@ def post_startup(): _LOGGER.info('Add UI dependent tools') # wrap in a try, because we haven't implmented it yet try: - mel.eval(str(r'source "{}"'.format(TAG_LY_DCC_MAYA_MEL))) + mel.eval(str(r'source "{}"'.format(TAG_O3DE_DCC_MAYA_MEL))) except Exception as e: _LOGGER.error(e) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/blender_materials.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/blender_materials.py deleted file mode 100755 index 6d7bd10f89..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/blender_materials.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -import bpy -import collections -import json - - -def get_shader_information(): - """ - Queries all materials and corresponding material attributes and file textures in the Blender scene. - - :return: - """ - # TODO - link file texture location to PBR material plugs- finding it difficult to track down how this is achieved - # in the Blender Python API documentation and/or in forums - - materials_count = 1 - shader_types = get_blender_shader_types() - materials_dictionary = {} - for target_mesh in [o for o in bpy.data.objects if type(o.data) is bpy.types.Mesh]: - material_information = collections.OrderedDict(DccApplication='Blender', AppliedMesh=target_mesh, - SceneName=bpy.data.filepath, MaterialAttributes={}, - FileConnections={}) - for target_material in target_mesh.data.materials: - material_information['MaterialName'] = target_material.name - shader_attributes = {} - shader_file_connections = {} - - for node in target_material.node_tree.nodes: - socket = node.inputs[0] - print('NODE: {}'.format(node)) - print('Socket: {}'.format(socket)) - - for material_input in node.inputs: - attribute_name = material_input.name - try: - attribute_value = material_input.default_value - print('Name: [{}] [{}] ValueType ::::::> {}'.format(attribute_name, attribute_value, - type(attribute_value))) - material_information['MaterialAttributes'].update({attribute_name: str(attribute_value)}) - except Exception as e: - pass - print('\n') - if node.type == 'TEX_IMAGE': - material_information['FileConnections'].update({str(node): str(node.image.filepath)}) - if node.name in shader_types.keys(): - material_information['MaterialType'] = shader_types[node.name] - - -# material_information['MaterialAttributes'] = shader_attributes - materials_dictionary['Material_{}'.format(materials_count)] = material_information - materials_count += 1 - print('_________________________________________________________________\n') - - return materials_dictionary - - -def get_blender_shader_types(): - """ - This returns all the material types present in the Blender scene - :return: - """ - shader_types = {} - ddir = lambda data, filter_str: [i for i in dir(data) if i.startswith(filter_str)] - get_nodes = lambda cat: [i for i in getattr(bpy.types, cat).category.items(None)] - cycles_categories = ddir(bpy.types, "NODE_MT_category_SH_NEW") - for cat in cycles_categories: - if cat == 'NODE_MT_category_SH_NEW_SHADER': - for node in get_nodes(cat): - shader_types[node.label] = node.nodetype - return shader_types - - -materials_dictionary = get_shader_information() -#print('Materials Dictionary:') -#print(materials_dictionary) -#parsed = json.loads(str(materials_dictionary)) -#print(json.dumps(parsed, indent=4, sort_keys=True)) - - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/cli_control.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/cli_control.py deleted file mode 100755 index 1d91275545..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/cli_control.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# -- This line is 75 characters ------------------------------------------- - -import click -import os -import main as app_main - - -@click.version_option('1.0.0') -@click.option('--output', default='PBR', help='Lumberyard material type. Current options: [pbr_basic]') -@click.argument('operands', type=click.STRING, nargs=-1) -@click.command(context_settings=dict(ignore_unknown_options=True)) -def main(output, operands): - target_files = [] - for index, operand in enumerate(operands): - entry_path = os.path.abspath(str(operand)) - if os.path.isdir(entry_path): - for directory_path, directory_names, file_names in os.walk(entry_path): - for file_name in file_names: - if is_valid_file(file_name): - target_files.append(os.path.join(entry_path, file_name)) - else: - if is_valid_file(operand): - target_files.append(operand) - - if len(target_files): - app_main.launch_material_converter('standalone', output, target_files) - - -def is_valid_file(file_name): - """ - Allows only supported DCC application files by extensions - :param file_name: The name of the file. - :return: - """ - target_extensions = 'ma mb fbx blend max'.split(' ') - if file_name.split('.')[-1] in target_extensions: - return True - return False - - -if __name__ == '__main__': - main() - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/dcc_material_mapping.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/dcc_material_mapping.py deleted file mode 100755 index 6369cb5658..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/dcc_material_mapping.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# -- This line is 75 characters ------------------------------------------- - -import logging - -logging.basicConfig(level=logging.DEBUG) - -def get_maya_material_mapping(name, material_type, file_connections): - """ - Helps map found material DCC attribute values/file connections with Lumberyard materials. - - :param name: Material name from within Maya - :param material_type: Maya Material type to match values to (i.e. Stingray PBS, aiStandardSurface(Arnold) - :param file_connections: List of all connected texture files from Maya - :return: Key value pairs for attributes/file textures assigned as Lumberyard material values - """ - material_properties = {} - if material_type == 'StingrayPBS': - logging.debug('Mapping StingrayPBS') - maps = 'color, metallic, roughness, normal, emissive, ao, opacity'.split(', ') - naming_exceptions = {'color': 'baseColor', 'ao': 'ambientOcclusion'} - for m in maps: - texture_attribute = 'TEX_{}_map'.format(m) - for tex in file_connections.keys(): - if tex.find(texture_attribute) != -1: - key = m if m not in naming_exceptions else naming_exceptions.get(m) - logging.debug('Key, Value: {} {}.{}'.format(key, name, texture_attribute)) - material_properties[key] = {'useTexture': 'true', - 'textureMap': file_connections.get( - '{}.{}'.format(name, texture_attribute))} - elif material_type == 'aiStandardSurface': - logging.debug('Mapping AiStandardSurface') - # TODO- Occlusion is based on a more difficult setup- there is no standard channel. Set this up as time permits - maps = 'baseColor, metalness, specularRoughness, normal, emissionColor, opacity'.split(', ') - naming_exceptions = {'metalness': 'metallic', 'specularRoughness': 'roughness', 'emissionColor': 'emissive'} - for m in maps: - key = m if m not in naming_exceptions.keys() else naming_exceptions.get(m) - texture_attribute = m - for tex in file_connections.keys(): - if tex.find(texture_attribute) != -1: - logging.debug('Key, Value: {} {}.{}'.format(key, name, texture_attribute)) - material_properties[key] = {'useTexture': 'true', - 'textureMap': file_connections.get( - '{}.{}'.format(name, texture_attribute))} - else: - pass - - return material_properties - - -def get_blender_material_mapping(name, material_type, file_connections): - pass - - -def get_max_material_mapping(name, material_type, file_connections): - pass - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/drag_and_drop.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/drag_and_drop.py deleted file mode 100755 index d02104b12c..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/drag_and_drop.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# -- This line is 75 characters ------------------------------------------- - -from PySide2 import QtWidgets, QtCore -from PySide2.QtCore import Signal - -class DragAndDrop(QtWidgets.QWidget): - drop_update = QtCore.Signal(list) - drop_over = QtCore.Signal(bool) - - def __init__(self, frame_color=None, highlight=None, parent=None): - super(DragAndDrop, self).__init__(parent) - - self.urls = [] - self.frame_color = frame_color - self.frame_highlight = highlight - self.setContentsMargins(0, 0, 0, 0) - self.setAcceptDrops(True) - - self.drag_and_drop_frame = QtWidgets.QFrame(self) - self.drag_and_drop_frame.setGeometry(0, 0, 5000, 5000) - self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color)) - - def dragEnterEvent(self, e): - if e.mimeData().hasUrls: - e.accept() - self.drop_over.emit(True) - if self.frame_highlight: - self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_highlight)) - else: - e.ignore() - - def dragLeaveEvent(self, e): - self.drop_over.emit(False) - - if self.frame_highlight: - self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color)) - - def dragMoveEvent(self, e): - if e.mimeData().hasUrls: - e.accept() - else: - e.ignore() - - def dropEvent(self, e): - if e.mimeData().hasUrls: - e.setDropAction(QtCore.Qt.CopyAction) - e.accept() - - for url in e.mimeData().urls(): - file_name = str(url.toLocalFile()) - self.urls.append(file_name) - self.drop_update.emit(self.urls) - if self.frame_highlight: - self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color)) - else: - e.ignore() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/launcher.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/launcher.bat deleted file mode 100644 index d609c26897..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/launcher.bat +++ /dev/null @@ -1,85 +0,0 @@ -@echo off - -REM -REM Copyright (c) Contributors to the Open 3D Engine Project. -REM For complete copyright and license terms please see the LICENSE at the root of this distribution. -REM -REM SPDX-License-Identifier: Apache-2.0 OR MIT -REM -REM - -:: Set up and run LY Python CMD prompt -:: Sets up the DccScriptingInterface_Env, -:: Puts you in the CMD within the dev environment - -:: Set up window -TITLE Lumberyard DCC Scripting Interface Cmd -:: Use obvious color to prevent confusion (Grey with Yellow Text) -COLOR 8E - -%~d0 -cd %~dp0 - -:: Keep changes local -SETLOCAL enableDelayedExpansion - -:: This maps up to the \Dev folder -IF "%DEV_REL_PATH%"=="" (set DEV_REL_PATH=..\..\..\..\..\..\..) - -:: Change to root Lumberyard dev dir -:: Don't use the LY_DEV so we can test that ENVAR!!! -CD /d %DEV_REL_PATH% -set Rel_Dev=%CD% -echo Rel_Dev = %Rel_Dev% -:: Restore original directory -popd - -set DCCSI_PYTHON_INSTALL=%Rel_Dev%\Tools\Python\3.7.5\windows - -:: add to the PATH -SET PATH=%DCCSI_PYTHON_INSTALL%;%PATH% - -:: dcc scripting interface gem path -set DCCSIG_PATH=%Rel_Dev%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface -echo DCCSIG_PATH = %DCCSIG_PATH% - -:: add to the PATH -SET PATH=%DCCSIG_PATH%;%PATH% - -:: Constant Vars (Global) -:: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=false) -echo DCCSI_GDEBUG = %DCCSI_GDEBUG% -:: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=false) -echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% -:: sets debugger, options: WING, PYCHARM -IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) -echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% - -echo. -echo _____________________________________________________________________ -echo. -echo ~ LY DCCsi, DCC Material Converter -echo _____________________________________________________________________ -echo. - -:: Change to root dir -CD /D %DCCSIG_PATH% - -:: add to the PATH -SET PATH=%DCCSIG_PATH%;%PATH% - -set PYTHONPATH=%DCCSIG_PATH%;%PYTHONPATH% - -CALL %DCCSI_PYTHON_INSTALL%\python.exe "%DCCSIG_PATH%\SDK\PythonTools\DCC_Material_Converter\standalone.py" - - -ENDLOCAL - -:: Return to starting directory -POPD - -:END_OF_FILE - -exit /b 0 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/main.py deleted file mode 100755 index f9359d7d82..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/main.py +++ /dev/null @@ -1,1026 +0,0 @@ -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -""" -Usage -===== -Put usage instructions here. - -Output -====== -Put output information here. - -Notes: -In order to run this, you'll need to verify that the "mayapy_path" class attribute corresponds to the location on -your machine. Currently I've just included mapping instructions for Maya StingrayPBS materials, although most of -the needed elements are in place to carry out additional materials inside of Maya pretty quickly moving forward. -I've marked areas that still need refinement (or to be added altogether) with TODO comments - -TODO- Docstrings need work... wanted to get descriptions in but they need to be set for Sphinx -TODO- Add 3ds Max interoperability -Links: -https://blender.stackexchange.com/questions/100497/use-blenders-bpy-in-projects-outside-blender -https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/3DSMax-Batch/files/ -GUID-0968FF0A-5ADD-454D-B8F6-1983E76A4AF9-htm.html - -TODO- Look at dynaconf and wire in a solid means for configuration settings -TODO- This hasn't been "designed"- might be worth it to consider the visual design to ensure the most effective and - attractive UI -TODO- Allow revisions to Model - -Reading FBX file information (might come in handy later) --- Materials information can be extracted from ASCII fbx pretty easily, binary is possible but more difficult --- FBX files could be exported as ASCII files and I could use regex there to extract material information --- I couldn't get pyfbx_i42 to work, but purportedly it can extract information from binary files. You may just have -to use the specified python versions -""" -# built-ins -import collections -import logging -import subprocess -import json -import sys -import os -import re - -# should give access to Lumberyard Qt dlls and PySide2 -from PySide2 import QtWidgets, QtCore, QtGui -from PySide2.QtCore import Slot -from PySide2.QtWidgets import QApplication -import shiboken2 -from shiboken2 import wrapInstance - -# local imports -from model import MaterialsModel -from drag_and_drop import DragAndDrop -import dcc_material_mapping as dcc_map - -# global space -main_window_pointer = None -main_app_window = None - - -class MaterialsToLumberyard(QtWidgets.QWidget): - def __init__(self, output_material_type='PBR', cli_values=None, parent=None): - super(MaterialsToLumberyard, self).__init__(parent) - - self.app = QtWidgets.QApplication.instance() - self.setWindowFlags(QtCore.Qt.Window) - self.setGeometry(50, 50, 800, 520) - self.setObjectName('MaterialsToLumberyard') - self.setWindowTitle(' ') - self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowMinMaxButtonsHint) - self.isTopLevel() - - self.cli_enabled = cli_values - self.output_material_type = output_material_type - self.desktop_location = os.path.join(os.path.expanduser('~'), 'Desktop') - self.directory_path = os.path.dirname(os.path.abspath(__file__)) - self.mayapy_path = os.path.abspath("C:/Program Files/Autodesk/Maya2020/bin/mayapy.exe") - self.blender_path = self.get_blender_path() - self.bold_font_large = QtGui.QFont('Helvetica', 7, QtGui.QFont.Bold) - self.medium_font = QtGui.QFont('Helvetica', 7, QtGui.QFont.Normal) - self.blessed_file_extensions = 'ma mb fbx max blend'.split(' ') - - self.dcc_materials_dictionary = {} - self.lumberyard_materials_dictionary = {} - self.lumberyard_material_nodes = [] - self.target_file_list = [] - self.current_scene = None - self.model = None - self.total_materials = 0 - - self.main_container = QtWidgets.QVBoxLayout(self) - self.main_container.setContentsMargins(0, 0, 0, 0) - self.main_container.setAlignment(QtCore.Qt.AlignTop) - self.setLayout(self.main_container) - self.content_layout = QtWidgets.QVBoxLayout() - self.content_layout.setAlignment(QtCore.Qt.AlignTop) - self.content_layout.setContentsMargins(10, 3, 10, 5) - self.main_container.addLayout(self.content_layout) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> Header Bar - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - self.header_bar_layout = QtWidgets.QHBoxLayout() - self.lumberyard_logo_layout = QtWidgets.QHBoxLayout() - self.lumberyard_logo_layout.setAlignment(QtCore.Qt.AlignLeft) - logo_path = os.path.join(self.directory_path, 'resources', 'lumberyard_logo.png') - logo_pixmap = QtGui.QPixmap(logo_path) - self.lumberyard_logo = QtWidgets.QLabel() - self.lumberyard_logo.setPixmap(logo_pixmap) - self.lumberyard_logo_layout.addWidget(self.lumberyard_logo) - self.header_bar_layout.addLayout(self.lumberyard_logo_layout) - - self.switch_combobox_layout = QtWidgets.QHBoxLayout() - self.switch_combobox_layout.setAlignment(QtCore.Qt.AlignRight) - self.switch_layout_combobox = QtWidgets.QComboBox() - self.set_combobox_items_accessibility() - self.switch_layout_combobox.setFixedSize(250, 30) - self.combobox_items = ['Add Source Files', 'Source File List', 'DCC Material Values', 'Export Materials'] - self.switch_layout_combobox.setStyleSheet('QComboBox {padding-left:6px;}') - self.switch_layout_combobox.addItems(self.combobox_items) - self.switch_combobox_layout.addWidget(self.switch_layout_combobox) - self.header_bar_layout.addLayout(self.switch_combobox_layout) - - self.content_layout.addSpacing(5) - self.content_layout.addLayout(self.header_bar_layout) - - # ++++++++++++++++++++++++++++++++++++++++++++++++# - # File Source Table / Attributes (Stacked Layout) # - # ++++++++++++++++++++++++++++++++++++++++++++++++# - - self.content_stacked_layout = QtWidgets.QStackedLayout() - self.content_layout.addLayout(self.content_stacked_layout) - self.switch_layout_combobox.currentIndexChanged.connect(self.layout_combobox_changed) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> Add Source Files - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - frame_color_value = '75,75,75' - highlight_color_value = '20,106,30' - self.drag_and_drop_widget = DragAndDrop(frame_color_value, highlight_color_value) - self.drag_and_drop_widget.drop_update.connect(self.drag_and_drop_file_update) - self.drag_and_drop_widget.drop_over.connect(self.drag_and_drop_over) - self.drag_and_drop_layout = QtWidgets.QVBoxLayout() - self.drag_and_drop_layout.setContentsMargins(0, 0, 0, 0) - self.drag_and_drop_layout.setAlignment(QtCore.Qt.AlignCenter) - self.drag_and_drop_widget.setLayout(self.drag_and_drop_layout) - - start_message = 'Drag source files here, or use file browser button below to get started.' - self.drag_and_drop_label = QtWidgets.QLabel(start_message) - self.drag_and_drop_label.setStyleSheet('color: white;') - self.drag_and_drop_layout.addWidget(self.drag_and_drop_label) - self.drag_and_drop_layout.addSpacing(10) - - self.select_files_button_layout = QtWidgets.QHBoxLayout() - self.select_files_button_layout.setAlignment(QtCore.Qt.AlignCenter) - self.select_files_button = QtWidgets.QPushButton('Select Files') - self.select_files_button_layout.addWidget(self.select_files_button) - self.select_files_button.clicked.connect(self.select_files_button_clicked) - self.select_files_button.setFixedSize(80, 35) - self.drag_and_drop_layout.addLayout(self.select_files_button_layout) - self.content_stacked_layout.addWidget(self.drag_and_drop_widget) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> Files Table - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - self.target_files_table = QtWidgets.QTableWidget() - self.target_files_table.setFocusPolicy(QtCore.Qt.NoFocus) - self.target_files_table.setColumnCount(2) - self.target_files_table.setAlternatingRowColors(True) - self.target_files_table.setHorizontalHeaderLabels(['File List', '']) - self.target_files_table.horizontalHeader().setStyleSheet('QHeaderView::section ' - '{background-color: rgb(220, 220, 220); ' - 'padding-top:7px; padding-left:5px;}') - self.target_files_table.verticalHeader().hide() - files_header = self.target_files_table.horizontalHeader() - files_header.setFixedHeight(30) - files_header.setDefaultAlignment(QtCore.Qt.AlignLeft) - files_header.setContentsMargins(10, 10, 0, 0) - files_header.setDefaultSectionSize(60) - files_header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch) - files_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Fixed) - self.target_files_table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) - self.content_stacked_layout.addWidget(self.target_files_table) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> Scene Information Table - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - self.material_tree_view = QtWidgets.QTreeView() - self.headers = ['Key', 'Value'] - self.material_tree_view.setStyleSheet('QTreeView::item {height:25px;} QHeaderView::section ' - '{background-color: rgb(220, 220, 220); height:30px; padding-left:10px}') - self.material_tree_view.setFocusPolicy(QtCore.Qt.NoFocus) - self.material_tree_view.setAlternatingRowColors(True) - self.material_tree_view.setUniformRowHeights(True) - self.content_stacked_layout.addWidget(self.material_tree_view) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> LY Material Definitions - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - self.lumberyard_material_definitions_widget = QtWidgets.QWidget() - self.lumberyard_material_definitions_layout = QtWidgets.QHBoxLayout(self.lumberyard_material_definitions_widget) - self.lumberyard_material_definitions_layout.setSpacing(0) - self.lumberyard_material_definitions_layout.setContentsMargins(0, 0, 0, 0) - self.lumberyard_material_definitions_frame = QtWidgets.QFrame(self.lumberyard_material_definitions_widget) - self.lumberyard_material_definitions_frame.setGeometry(0, 0, 5000, 5000) - self.lumberyard_material_definitions_frame.setStyleSheet('background-color:rgb(75,75,75);') - self.lumberyard_material_definitions_scroller = QtWidgets.QScrollArea() - self.scroller_widget = QtWidgets.QWidget() - self.scroller_layout = QtWidgets.QVBoxLayout() - self.scroller_widget.setLayout(self.scroller_layout) - self.lumberyard_material_definitions_scroller.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) - self.lumberyard_material_definitions_scroller.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.lumberyard_material_definitions_scroller.setWidgetResizable(True) - self.lumberyard_material_definitions_scroller.setWidget(self.scroller_widget) - self.lumberyard_material_definitions_layout.addWidget(self.lumberyard_material_definitions_scroller) - self.content_stacked_layout.addWidget(self.lumberyard_material_definitions_widget) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> File processing buttons - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - self.process_files_layout = QtWidgets.QHBoxLayout() - self.content_layout.addLayout(self.process_files_layout) - self.process_files_button = QtWidgets.QPushButton('Process Added Files') - self.process_files_button.setFixedHeight(50) - self.process_files_button.clicked.connect(self.process_listed_files_clicked) - self.process_files_layout.addWidget(self.process_files_button) - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - # ---->> Status bar / Loader - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - # TODO- Move all processing of files to another thread and display progress with loader - - self.status_bar = QtWidgets.QStatusBar() - self.status_bar.setStyleSheet('background-color: rgb(220, 220, 220);') - self.status_bar.setContentsMargins(0, 0, 0, 0) - self.status_bar.setSizeGripEnabled(False) - self.message_readout_label = QtWidgets.QLabel('Ready.') - self.message_readout_label.setStyleSheet('padding-left: 10px') - self.status_bar.addWidget(self.message_readout_label) - - self.progress_bar = QtWidgets.QProgressBar() - self.progress_bar_widget = QtWidgets.QWidget() - self.progress_bar_widget_layout = QtWidgets.QHBoxLayout() - self.progress_bar_widget_layout.setContentsMargins(0, 0, 0, 0) - self.progress_bar_widget_layout.setAlignment(QtCore.Qt.AlignRight) - self.progress_bar_widget.setLayout(self.progress_bar_widget_layout) - self.status_bar.addPermanentWidget(self.progress_bar_widget) - self.progress_bar_widget_layout.addWidget(self.progress_bar) - self.progress_bar.setFixedSize(180, 20) - self.main_container.addWidget(self.status_bar) - self.initialize() - - ############################ - # UI Display Layers ######## - ############################ - - def initialize(self): - if self.cli_enabled: - print('CLI ACCESS:::::::::::\nValues passed: {}'.format(self.cli_enabled)) - self.target_file_list = self.cli_enabled - self.process_file_list() - self.export_selected_materials() - - def populate_source_files_table(self): - """ - Adds selected files from the 'Source Files' section of the UI. This creates each item listing in the table - as well as adds a 'Remove' button that will clear corresponding item from the table. Processed files will - get color coded, based on whether or not the materials in the file could be successfully processed. Subsequent - searches will not clear items from the table currently, as each item acts as a register of materials that have - and have not yet been processed. - :return: - """ - self.target_files_table.setRowCount(0) - for index, entry in enumerate(self.target_file_list): - entry = entry[1] if type(entry) == list else entry - self.target_files_table.insertRow(index) - item = QtWidgets.QTableWidgetItem(' {}'.format(entry)) - self.target_files_table.setRowHeight(index, 45) - remove_button = QtWidgets.QPushButton('Remove') - remove_button.setFixedWidth(60) - remove_button.clicked.connect(self.remove_source_file_clicked) - self.target_files_table.setItem(index, 0, item) - self.target_files_table.setCellWidget(index, 1, remove_button) - - def populate_dcc_material_values_tree(self): - """ - Sets the materials model class to the file attribute tree. - :return: - """ - # TODO- Create mechanism for collapsing previously gathered materials, and or pushing them further down the list - self.material_tree_view.setModel(self.model) - self.material_tree_view.expandAll() - self.material_tree_view.resizeColumnToContents(0) - - def populate_export_materials_list(self): - """ - Once all materials have been analyzed inside of DCC applications, the 'Export Materials' view lists all - materials presented as their Lumberyard counterparts. Each listing displays a representation of the material - file based on its corresponding DCC material values and file connections. - :return: - """ - self.reset_export_materials_description() - for count, value in enumerate(self.lumberyard_materials_dictionary): - material_definition_node = MaterialNode([value, self.lumberyard_materials_dictionary[value]], count) - self.lumberyard_material_nodes.append(material_definition_node) - self.scroller_layout.addWidget(material_definition_node) - self.scroller_layout.addLayout(self.create_separator_line()) - - ############################ - # TBD ######## - ############################ - - def process_file_list(self): - """ - The entry point for reading DCC files and extracting values. Files are filtered and separated - by DCC app (based on file extensions) before processing is done. - - Supported DCC applications: - Maya (.ma, .mb, .fbx), 3dsMax(.max), Blender(.blend) - :return: - """ - files_dict = {'maya': [], 'max': [], 'blender': [], 'na': []} - for file_location in self.target_file_list: - file_name = os.path.basename(str(file_location)) - file_extension = os.path.splitext(file_name)[1] - target_application = self.get_target_application(file_extension) - if target_application in files_dict.keys(): - files_dict[target_application].append(file_location) - - for key, values in files_dict.items(): - try: - if key == 'maya' and len(values): - self.get_maya_material_values(values) - elif key == 'max' and len(values): - self.get_max_material_values(values) - elif key == 'blender' and len(values): - self.get_blender_material_values(values) - else: - pass - except Exception as e: - # TODO- Allow corrective actions or some display of errors if this fails? - logging.warning('Could not process files. Error: {}'.format(e)) - - if self.dcc_materials_dictionary: - self.set_transfer_status(self.dcc_materials_dictionary) - # Create Model with extracted values from file list - self.set_material_model() - # Setup Lumberyard Material File Values - self.set_export_materials_description() - # Update UI Layout - self.populate_export_materials_list() - self.switch_layout_combobox.setCurrentIndex(3) - self.set_ui_buttons() - self.message_readout_label.setText('Ready.') - - def reset_export_materials_description(self): - pass - - def reset_all_values(self): - pass - - def create_separator_line(self): - """ Convenience function for adding separation line to the UI. """ - layout = QtWidgets.QHBoxLayout() - line = QtWidgets.QLabel() - line.setFrameStyle(QtWidgets.QFrame.HLine | QtWidgets.QFrame.Sunken) - line.setLineWidth(1) - line.setFixedHeight(10) - layout.addWidget(line) - layout.setContentsMargins(8, 0, 8, 0) - return layout - - def export_selected_materials(self): - """ - This will eventually be revised to save material definitions in the proper place in the user's project folder, - but for now material definitions will be saved to the desktop. - :return: - """ - for node in self.lumberyard_material_nodes: - if node.material_name_checkbox.isChecked(): - output_path = os.path.dirname(node.material_info['sourceFile']) - node.material_info.pop('sourceFile') - output = os.path.join(output_path, '{}.material'.format(node.material_name)) - with open(output, 'w', encoding='utf-8') as material_file: - json.dump(node.material_info, material_file, ensure_ascii=False, indent=4) - - ############################ - # Getters/Setters ########## - ############################ - - @staticmethod - def get_target_application(file_extension): - """ - Searches compatible file extensions and returns one of three Application names- Maya, 3dsMax, or Blender. - :param file_extension: Passed file extension used to determine DCC Application it originated from. - :return: Returns the application corresponding to the extension if found- otherwise returns a Boolean None - """ - app_extensions = {'maya': ['.ma', '.mb', '.fbx'], 'max': ['.max'], 'blender': ['.blend']} - target_dcc_application = [key for key, values in app_extensions.items() if file_extension in values] - if target_dcc_application: - return target_dcc_application[0] - return None - - @staticmethod - def get_lumberyard_material_template(shader_type): - """ - Loads material descriptions from the Lumberyard installation, providing a template to compare and convert DCC - shaders to Lumberyard material definitions. This is the first step in the comparison. The second step is to - compare these values with specific mapping instructions for DCC Application and DCC material type to arrive at - a converted material. - :param shader_type: The type of Lumberyard shader to pair material attributes to (i.e. PBR Shader) - :return: File dictionary of the available boilerplate Lumberyard shader settings. - """ - definitions = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', - '{}.template.material'.format(shader_type)) - if os.path.exists(definitions): - with open(definitions) as f: - return json.load(f) - - @staticmethod - def get_lumberyard_material_properties(name, dcc_app, material_type, file_connections): - """ - This system will probably need rethinking if DCCs and compatible materials grow. I've tried to keep this - flexible so that it can be expanded with more apps and materials. - - :param name: Material name from within the DCC application - :param dcc_app: The application that the material was sourced from - :param material_type: DCC material type - :param file_connections: Texture files found attached to the materials - """ - - material_properties = {} - if dcc_app == 'Maya': - material_properties = dcc_map.get_maya_material_mapping(name, material_type, file_connections) - elif dcc_app == 'Blender': - material_properties = dcc_map.get_blender_material_mapping(name, material_type, file_connections) - elif dcc_app == '3dsMax': - material_properties = dcc_map.get_max_material_mapping(name, material_type, file_connections) - else: - pass - return material_properties - - @staticmethod - def get_filename_increment(name): - """ - Convenience function that assists in ensuring that if any materials are encountered with the same name, an - underscore and number is appended to it to prevent overwrites. - :param name: The name of the material. The function searches the string for increment numbers, and either adds - one to any encountered, or adds an "_1" if passed name is the first duplicate encountered. - :return: The adjusted name with a unique incremental value. - """ - last_number = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+') - number_found = last_number.search(name) - if number_found: - next_number = str(int(number_found.group(1)) + 1) - start, end = number_found.span(1) - name = name[:max(end - len(next_number), start)] + next_number + name[end:] - return name - - def get_maya_material_values(self, target_files): - """ - Launches Maya Standalone and processes list of materials for each scene passed to the 'target_files' argument. - Also sets the environment paths needed for an instance of Maya's Python distribution. After files are processed - a single dictionary of scene materials is returned, and added to the "materials_dictionary" scene attribute. - :param target_files: List of files filtered from total list of files requested for processing that have a - Maya file extension - :return: - """ - - # TODO- Set load process to a separate thread and wire load progress bar up - - try: - script_path = str(os.path.join(self.directory_path, 'maya_materials.py')) - target_files.append(self.total_materials) - runtime_env = os.environ.copy() - runtime_env['MAYA_LOCATION'] = os.path.dirname(self.mayapy_path) - runtime_env['PYTHONPATH'] = os.path.dirname(self.mayapy_path) - command = f'{self.mayapy_path} "{script_path}"' - for file in target_files: - command += f' "{file}"' - p = subprocess.Popen(command, shell=False, env=runtime_env, stdout=subprocess.PIPE) - output = p.communicate()[0] - self.set_material_dictionary(json.loads(output)) - except Exception as e: - logging.warning('maya error: {}'.format(e)) - - def get_max_material_values(self, target_files): - """ - This has not been implemented yet. - - :param target_files: List of files filtered from total list of files requested for processing that have a - .max file extension - :return: - """ - logging.debug('Max Target file: {}'.format(target_files)) - - def get_blender_material_values(self, target_files): - """ - This has not been implemented yet. - - :param target_files: List of files filtered from total list of files requested for processing that have a - .blend file extension - :return: - """ - logging.debug('Blender Target file: {}'.format(target_files)) - script_path = str(os.path.join(self.directory_path, 'blender_materials.py')) - target_files.append(self.total_materials) - p = subprocess.Popen([self.blender_path, '--background', '--python', script_path, '--', target_files]) - output = p.communicate()[0] - self.set_material_dictionary(json.loads(output)) - - def get_blender_path(self): - """ - Finds latest Blender version installed on the user machine for command line file processing. - - :return: Most current version available (or none) - """ - blender_base_directory = os.path.join(os.path.join('C:\\', 'Program Files', 'Blender Foundation')) - blender_versions_found = [] - for (directory_path, directory_name, filenames) in os.walk(blender_base_directory): - for filename in filenames: - if filename == 'blender.exe': - blender_versions_found.append(os.path.join(directory_path, filename)) - - if blender_versions_found: - return max(blender_versions_found, key=os.path.getctime) - else: - return None - - def set_combobox_items_accessibility(self): - """ - Locks items from within the combobox until the sections they connect to have content - :return: - """ - # TODO- Add this functionality - pass - - def set_transfer_status(self, transfer_info): - """ - Colorizes listings in the 'Source Files' view of the UI after processing to green or red, indicating whether or - not scene analysis successfully returned compatible materials and their values. - :param transfer_info: Each file the scripts attempt to process return a receipt of the success or failure of - the analysis. - :return: - """ - - # TODO- Include some way to get error information if analysis fails, and potentially offer the means to - # repair values as they map to intended Lumberyard shader type - - for row in range(self.target_files_table.rowCount()): - for key, values in transfer_info.items(): - row_path = self.target_files_table.item(row, 0).text().strip() - scene_processed = {x for x in transfer_info if values['SceneName'].replace('\\', '/') == row_path} - if scene_processed: - self.target_files_table.item(row, 0).setBackground(QtGui.QColor(192, 255, 171)) - break - else: - self.target_files_table.item(row, 0).setBackground(QtGui.QColor(255, 177, 171)) - - def set_export_materials_description(self): - root = self.model.rootItem - for row in range(self.model.rowCount()): - source_file = self.model.get_attribute_value('SceneName', root.child(row)) - name = self.model.get_attribute_value('MaterialName', root.child(row)) - material_type = self.model.get_attribute_value('MaterialType', root.child(row)) - dcc_app = self.model.get_attribute_value('DccApplication', root.child(row)) - file_connections = {} - shader_attributes = {} - - for childIndex in range(root.child(row).childCount()): - child_item = root.child(row).child(childIndex) - child_value = child_item.itemData - if child_item.childCount(): - target_dict = file_connections if child_value[0] == 'FileConnections' else shader_attributes - for subChildIndex in range(child_item.childCount()): - sub_child_data = child_item.child(subChildIndex).itemData - target_dict[sub_child_data[0]] = sub_child_data[1] - self.set_material_description(source_file, name, dcc_app, material_type, file_connections) - - def set_material_dictionary(self, dcc_dictionary): - """ - Adds all material descriptions pulled from each DCC file analyzed to the "materials_dictionary" class attribute. - This function runs each time a subprocess is launched to gather DCC application material values. - :param dcc_dictionary: The dictionary of values for each material analyzed by each specific DCC file list - return analyzed values - :return: - """ - logging.debug('DCC Dictionary: {}'.format(json.dumps(dcc_dictionary, indent=4))) - self.total_materials += len(dcc_dictionary) - self.dcc_materials_dictionary.update(dcc_dictionary) - - def set_material_model(self, initialize=True): - """ - Once all materials have been gathered across a selected file set query, this organizes the values into a - QT Model Class - :param initialize: Default is set to boolean True. If a model has already been established in the current - session, the initialize parameter would be set to false, and the values added to the Model. All changes to - the model would then be redistributed to other informational views in the UI. - :return: - """ - if initialize: - self.model = MaterialsModel(self.headers, self.dcc_materials_dictionary) - else: - self.model.update() - self.dcc_materials_dictionary.clear() - self.populate_dcc_material_values_tree() - - def set_ui_buttons(self): - """ - Handles UI buttons for each of the three stacked layout views (Source Files, DCC Material Values, - Export Materials) - :return: - """ - display_index = self.content_stacked_layout.currentIndex() - self.switch_layout_combobox.setEnabled(True) - self.process_files_button.setText('Process Listed Files') - # Add Source Files Layout ------------------------------->> - if display_index == 0: - self.process_files_button.setEnabled(True) - - # Source File List -------------------------------------->> - elif display_index == 1: - self.process_files_button.setEnabled(True) - - # DCC Material Values Layout ---------------------------->> - elif display_index == 2: - self.process_files_button.setEnabled(False) - - # Export Materials Layout ------------------------------->> - else: - self.process_files_button.setText('Export Selected Materials') - if self.lumberyard_materials_dictionary: - self.process_files_button.setEnabled(True) - - def set_material_description(self, source_file, name, dcc_app, material_type, file_connections): - """ - Build dictionary for material description based on extracted values - - :param source_file: The file that the material was extracted from - :param name: Name of material - :param dcc_app: Source file type of material (Maya, Blender or 3ds Max) - :param material_type: Material type within app (i.e. Stingray PBS) - :param file_connections: Texture files found connected to the shader - :return: - """ - - default_settings = self.get_lumberyard_material_template('standardPBR') - material = collections.OrderedDict(sourceFile=source_file, description=name, - materialType=default_settings.get('materialType'), - parentMaterial=default_settings.get('parentMaterial'), - propertyLayoutVersion=default_settings.get('propertyLayoutVersion'), - properties=self.get_lumberyard_material_properties(name, dcc_app, - material_type, - file_connections)) - name += self.output_material_type - self.lumberyard_materials_dictionary[name if name not in self.lumberyard_materials_dictionary.keys() else - self.get_filename_increment(name)] = material - - ############################ - # Button Actions ########### - ############################ - - def remove_source_file_clicked(self): - """ - In the Source File view of the UI layout, this will remove the listed file in its respective row. If files - have not been processed yet, it prevents that file from being analyzed. If the files have already been - analyzed, this will remove the materials from stored values. - :return: - """ - file_index = self.target_files_table.indexAt(self.sender().pos()) - del self.target_file_list[file_index.row()] - self.populate_files_table() - - def process_listed_files_clicked(self): - """ - The button serves a dual purpose, depending on the current layout of the window. 'Process listed files' - initiates the DCC file analysis that extracts material information. In the "Export Materials" layout, this - button (for now) will export material files corresponding to each analyzed material. Exported material files - are routed to the directories of the respective files processed. - :return: - """ - - if self.sender().text() == 'Process Added Files': - self.message_readout_label.setText('Gathering Material Information...') - self.app.processEvents() - self.process_file_list() - else: - self.export_selected_materials() - - def select_files_button_clicked(self): - """ - This dialog allows user to select DCC files to be processed for the materials present for conversion. - :return: - """ - - # TODO- Eventually it might be worth it to allow files from multiple locations to be selected. Currently - # this only allows single/multiple files from a single directory to be selected, although drag and drop - # allows multiple locations - - dialog = QtWidgets.QFileDialog(self, 'Shift-Select Target Files', self.desktop_location) - dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile) - dialog.setNameFilter('Compatible Files (*.ma *.mb *.fbx *.max *.blend)') - dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True) - file_view = dialog.findChild(QtWidgets.QListView, 'listView') - - # Workaround for selecting multiple files with File Dialog - if file_view: - file_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) - f_tree_view = dialog.findChild(QtWidgets.QTreeView) - if f_tree_view: - f_tree_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) - - if dialog.exec_() == QtWidgets.QDialog.Accepted: - self.target_file_list += dialog.selectedFiles() - if self.target_file_list: - self.populate_source_files_table() - self.message_readout_label.setText('Source files added: {}'.format(len(self.target_file_list))) - self.process_files_button.setEnabled(True) - - def layout_combobox_changed(self): - """ - Handles main window layout combobox index change. - :return: - """ - self.content_stacked_layout.setCurrentIndex(self.switch_layout_combobox.currentIndex()) - self.set_ui_buttons() - - def reset_clicked(self): - """ - Brings the application and all variables back to their initial state. - :return: - """ - self.reset_all_values() - - ############################ - # Slots #################### - ############################ - - @Slot(list) - def drag_and_drop_file_update(self, file_list): - for file in file_list: - if os.path.basename(file).split('.')[-1] in self.blessed_file_extensions: - self.target_file_list.append(file) - self.drag_and_drop_widget.urls.clear() - self.populate_source_files_table() - self.message_readout_label.setText('Source files added: {}'.format(len(self.target_file_list))) - self.drag_and_drop_label.setStyleSheet('color: white;') - - @Slot(bool) - def drag_and_drop_over(self, is_over): - if is_over: - self.drag_and_drop_label.setStyleSheet('color: rgb(0, 255, 0);') - else: - self.drag_and_drop_label.setStyleSheet('color: white;') - - -class MaterialNode(QtWidgets.QWidget): - def __init__(self, material_info, current_position, parent=None): - super(MaterialNode, self).__init__(parent) - - self.material_name = material_info[0] - self.material_info = material_info[1] - self.current_position = current_position - self.property_settings = {} - - self.small_font = QtGui.QFont("Helvetica", 7, QtGui.QFont.Bold) - self.bold_font = QtGui.QFont("Helvetica", 8, QtGui.QFont.Bold) - self.main_layout = QtWidgets.QVBoxLayout() - self.main_layout.setContentsMargins(0, 0, 0, 0) - self.setLayout(self.main_layout) - - self.background_frame = QtWidgets.QFrame(self) - self.background_frame.setGeometry(0, 0, 5000, 5000) - self.background_frame.setStyleSheet('background-color:rgb(220, 220, 220);') - - # ######################## - # Title Bar - # ######################## - - self.title_bar_widget = QtWidgets.QWidget() - self.title_bar_layout = QtWidgets.QHBoxLayout(self.title_bar_widget) - self.title_bar_layout.setContentsMargins(10, 0, 10, 0) - self.title_bar_layout.setAlignment(QtCore.Qt.AlignTop) - self.title_bar_frame = QtWidgets.QFrame(self.title_bar_widget) - self.title_bar_frame.setGeometry(0, 0, 5000, 40) - self.title_bar_frame.setStyleSheet('background-color:rgb(193,154,255);') - self.main_layout.addWidget(self.title_bar_widget) - self.material_name_checkbox = QtWidgets.QCheckBox(self.material_name) - self.material_name_checkbox.setFixedHeight(35) - self.material_name_checkbox.setStyleSheet('spacing:10px; color:white') - self.material_name_checkbox.setFont(self.bold_font) - self.material_name_checkbox.setChecked(True) - self.title_bar_layout.addWidget(self.material_name_checkbox) - - self.material_file_layout = QtWidgets.QHBoxLayout() - self.material_file_layout.setAlignment(QtCore.Qt.AlignRight) - self.source_file = QtWidgets.QLabel(os.path.basename(self.material_info['sourceFile'])) - self.source_file.setStyleSheet('color:white;') - self.source_file.setFont(self.small_font) - self.material_file_layout.addWidget(self.source_file) - self.material_file_layout.addSpacing(10) - - self.edit_button = QtWidgets.QPushButton('Edit') - self.edit_button.clicked.connect(self.edit_button_clicked) - self.edit_button.setFixedWidth(55) - self.material_file_layout.addWidget(self.edit_button) - self.title_bar_layout.addLayout(self.material_file_layout) - - self.information_layout = QtWidgets.QHBoxLayout() - self.information_layout.setContentsMargins(10, 0, 10, 10) - self.main_layout.addLayout(self.information_layout) - - # ######################## - # Details layout - # ######################## - - self.details_layout = QtWidgets.QVBoxLayout() - self.details_layout.setAlignment(QtCore.Qt.AlignTop) - self.details_groupbox = QtWidgets.QGroupBox("Details") - self.details_groupbox.setFixedWidth(200) - self.details_groupbox.setStyleSheet("QGroupBox {font:bold; border: 1px solid silver; " - "margin-top: 6px;} QGroupBox::title { color: rgb(150, 150, 150); " - "subcontrol-position: top left;}") - self.details_layout.addSpacing(15) - self.material_type_label = QtWidgets.QLabel('Material Type') - self.material_type_label.setStyleSheet('padding-left: 6px; color: white; background-color:rgb(175, 175, 175);') - self.material_type_label.setFixedHeight(25) - self.material_type_label.setFont(self.bold_font) - self.details_layout.addWidget(self.material_type_label) - - self.material_type_combobox = QtWidgets.QComboBox() - self.material_type_combobox.setFixedHeight(30) - self.material_type_combobox.setStyleSheet('QCombobox QAbstractItemView { padding-left: 15px; }') - material_type_items = [' Standard PBR'] - self.material_type_combobox.addItems(material_type_items) - self.details_layout.addWidget(self.material_type_combobox) - self.details_layout.addSpacing(10) - - self.description_label = QtWidgets.QLabel('Description') - self.description_label.setStyleSheet('padding-left: 6px; color: white; background-color:rgb(175, 175, 175);') - self.description_label.setFixedHeight(25) - self.description_label.setFont(self.bold_font) - self.details_layout.addWidget(self.description_label) - - self.description_box = QtWidgets.QTextEdit('This space is reserved for additional information.') - self.details_layout.addWidget(self.description_box) - self.information_layout.addWidget(self.details_groupbox) - self.details_groupbox.setLayout(self.details_layout) - - # ######################## - # Properties layout - # ######################## - - self.properties_layout = QtWidgets.QVBoxLayout() - self.properties_layout.setAlignment(QtCore.Qt.AlignTop) - self.properties_groupbox = QtWidgets.QGroupBox("Properties") - self.properties_groupbox.setFixedWidth(150) - self.properties_groupbox.setStyleSheet("QGroupBox {font:bold; border: 1px solid silver; " - "margin-top: 6px;} QGroupBox::title { color: rgb(150, 150, 150); " - "subcontrol-position: top left;}") - self.properties_list_widget = QtWidgets.QListWidget() - self.material_properties = ['ambientOcclusion', 'baseColor', 'emissive', 'metallic', 'roughness', 'specularF0', - 'normal', 'opacity'] - self.properties_list_widget.addItems(self.material_properties) - self.properties_list_widget.itemSelectionChanged.connect(self.property_selection_changed) - self.properties_layout.addSpacing(15) - self.properties_layout.addWidget(self.properties_list_widget) - self.information_layout.addWidget(self.properties_groupbox) - self.properties_groupbox.setLayout(self.properties_layout) - - # ######################## - # Attributes layout - # ######################## - - self.attributes_layout = QtWidgets.QVBoxLayout() - self.attributes_layout.setAlignment(QtCore.Qt.AlignTop) - self.attributes_groupbox = QtWidgets.QGroupBox("Attributes") - self.attributes_groupbox.setStyleSheet("QGroupBox {font:bold; border: 1px solid silver; " - "margin-top: 6px;} QGroupBox::title { color: rgb(150, 150, 150); " - "subcontrol-position: top left;}") - self.information_layout.addWidget(self.attributes_groupbox) - self.attributes_layout.addSpacing(15) - self.attributes_table = QtWidgets.QTableWidget() - self.attributes_table.setFocusPolicy(QtCore.Qt.NoFocus) - self.attributes_table.setColumnCount(2) - self.attributes_table.setAlternatingRowColors(True) - self.attributes_table.setHorizontalHeaderLabels(['Attribute', 'Value']) - self.attributes_table.verticalHeader().hide() - attributes_table_header = self.attributes_table.horizontalHeader() - attributes_table_header.setStyleSheet('QHeaderView::section {background-color: rgb(220, 220, 220);}') - attributes_table_header.setDefaultAlignment(QtCore.Qt.AlignLeft) - attributes_table_header.setContentsMargins(10, 10, 0, 0) - attributes_table_header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch) - attributes_table_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch) - attributes_table_header.setSectionResizeMode(0, QtWidgets.QHeaderView.Interactive) - self.attributes_layout.addWidget(self.attributes_table) - self.attributes_groupbox.setLayout(self.attributes_layout) - self.initialize_display_values() - - def initialize_display_values(self): - """ - Initializes all of the widget item information for material based on the DCC application info the class has - been passed. - :return: - """ - for material_property in self.material_properties: - if material_property in self.material_info.get('properties'): - self.property_settings[material_property] = self.material_info['properties'].get(material_property) - current_row = self.material_properties.index(material_property) - current_item = self.properties_list_widget.takeItem(current_row) - self.properties_list_widget.insertItem(0, current_item) - else: - self.property_settings[material_property] = 'inactive' - current_row = self.material_properties.index(material_property) - item = self.properties_list_widget.item(current_row) - item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEnabled) - item.setFlags(item.flags() & ~QtCore.Qt.ItemIsSelectable) - - self.properties_list_widget.setCurrentRow(0) - self.set_attributes_table(self.get_selected_property()) - - def set_attributes_table(self, selected_property): - """ - Displays the key, value pairs for the item selected in the Properties list widget - :param selected_property: The item in the Properties list widget that is currently selected. Only active - values are displayed. - :return: - """ - self.attributes_table.setRowCount(0) - row_count = 0 - for key, value in self.property_settings[selected_property].items(): - self.attributes_table.insertRow(row_count) - key_item = QtWidgets.QTableWidgetItem(key) - self.attributes_table.setItem(row_count, 0, key_item) - value_item = QtWidgets.QTableWidgetItem(value) - self.attributes_table.setItem(row_count, 1, value_item) - row_count += 1 - - def get_selected_property(self): - """ - Convenience function to get current value selected in the Properties list widget. - :return: - """ - return self.properties_list_widget.currentItem().text() - - def update_model(self): - """ - Not sure if this will go away, but if desired, I could make attribute values able to be revised after - materials have been scraped from the DCC materials - :return: - """ - pass - - def edit_button_clicked(self): - """ - This is in place in the event that we want to allow material revisions for properties to be made after - DCC processing step has already been executed. The idea would basically be to surface an editable - table where values can be added, removed or changed within the final material definition. - :return: - """ - logging.debug('Edit button clicked') - - def property_selection_changed(self): - """ - Fired when index of list view selected property selection has changed. - :return: - """ - self.set_attributes_table(self.get_selected_property()) - - -def is_valid_file(file_name): - """ - The acts as a clearinghouse for DCC file types supported by the script - :param file_name: Reads the extension of the filename for filtering - :return: - """ - target_extensions = 'ma mb fbx blend max'.split(' ') - if file_name.split('.')[-1] in target_extensions: - return True - return False - - -def launch_material_converter(window_type='standalone', material_type='PBR', target_files=None): - """ - The setup for this will be revised once this is fully integrated into the DCCsi system. Currently only the - standalone (default) and command line entry points work as intended. - :param window_type: The method of access for material conversion (standalone, command_line, maya_native, max_native) - :param material_type: Type of output material desired for import into Lumberyard. Currently only PBR is supported - :param target_files: DCC app files to process for converted Lumberyard materials - :return: - """ - if window_type == 'command_line': - MaterialsToLumberyard(material_type, target_files) - elif window_type == 'maya_native': - from maya import OpenMayaUI as omui - main_window_pointer = omui.MQtUtil.mainWindow() - main_app_window = wrapInstance(long(main_window_pointer), QtWidgets.QWidget) - MaterialsToLumberyard(material_type, None, main_app_window) - elif window_type == 'max_native': - from pymxs import runtime as rt - main_window_pointer = QtWidgets.QWidget.find(rt.windows.getMAXHWND()) - main_app_window = shiboken2.wrapInstance(shiboken2.getCppPointer(main_window_pointer)[0], QtWidgets.QMainWindow) - MaterialsToLumberyard(material_type, None, main_app_window) - else: - app = QApplication(sys.argv) - app_ui = MaterialsToLumberyard() - app_ui.show() - sys.exit(app.exec_()) - - -if __name__ == '__main__': - launch_material_converter() - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/maya_materials.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/maya_materials.py deleted file mode 100755 index 4e66f83661..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/maya_materials.py +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -from PySide2 import QtCore -import maya.standalone -maya.standalone.initialize(name='python') -import maya.cmds as mc -import collections -import logging -import json -import sys -import os - - -for handler in logging.root.handlers[:]: - logging.root.removeHandler(handler) - -logging.basicConfig(level=logging.INFO, - format='%(name)s - %(levelname)s - %(message)s', - datefmt='%m-%d %H:%M', - filename='output.log', - filemode='w') - - -class MayaMaterials(QtCore.QObject): - def __init__(self, files_list, materials_count, parent=None): - super(MayaMaterials, self).__init__(parent) - - self.files_list = files_list - self.current_scene = None - self.materials_dictionary = {} - self.materials_count = int(materials_count) - self.get_material_information() - - def get_material_information(self): - """ - Main entry point for the material information extraction. Because this class is run - in Standalone mode as a subprocess, the list is passed as a string- some parsing/measures - need to be taken in order to separate values that originated as a list before passed. - - :return: A dictionary of all of the materials gathered. Sent back to main UI through stdout - """ - for target_file in file_list: - self.current_scene = os.path.abspath(target_file.replace('\'', '')) - mc.file(self.current_scene, open=True, force=True) - self.set_material_descriptions() - json.dump(self.materials_dictionary, sys.stdout) - - @staticmethod - def get_materials(target_mesh): - """ - Gathers a list of all materials attached to each mesh's shader - - :param target_mesh: The target mesh to pull attached material information from. - :return: List of unique material values attached to the mesh passed as an argument. - """ - shading_group = mc.listConnections(target_mesh, type='shadingEngine') - materials = mc.ls(mc.listConnections(shading_group), materials=1) - return list(set(materials)) - - @staticmethod - def get_shader(material_name): - """ - Convenience function for obtaining the shader that the specified material (as an argument) - is attached to. - - :param material_name: Takes the material name as an argument to get associated shader object - :return: - """ - connections = mc.listConnections(material_name, type='shadingEngine')[0] - shader_name = '{}.surfaceShader'.format(connections) - shader = mc.listConnections(shader_name)[0] - return shader - - def get_shader_information(self, shader, material_mesh): - """ - Helper function for extracting shader/material attributes used to form the DCC specific dictionary - of found material values for conversion. - - :param shader: The target shader object to analyze - :param material_mesh: The material mesh needs to be passed to search for textures attached to it. - :return: Complete set (in the form of two dictionaries) of file connections and material attribute values - """ - shader_file_connections = {} - materials = self.get_materials(material_mesh) - for material in materials: - material_files = [x for x in mc.listConnections(material, plugs=1, source=1) if x.startswith('file')] - for file_name in material_files: - file_texture = mc.getAttr('{}.fileTextureName'.format(file_name.split('.')[0])) - if os.path.basename(file_texture).split('.')[-1] != 'dds': - key_name = mc.listConnections(file_name, plugs=1, source=1)[0] - shader_file_connections[key_name] = file_texture - - shader_attributes = {} - for shader_attribute in mc.listAttr(shader, s=True, iu=True): - try: - shader_attributes[str(shader_attribute)] = str(mc.getAttr('{}.{}'.format(shader, shader_attribute))) - except Exception as e: - logging.error('MayaAttributeError: {}'.format(e)) - - return shader_file_connections, shader_attributes - - def set_material_dictionary(self, material_name, material_type, material_mesh): - """ - When a unique material has been found, this creates a dictionary entry with all relevant material values. This - includes material attributes as well as attached file textures. Later in the process this information is - leveraged when creating the Lumberyard material definition. - - :param material_name: The name attached to the material - :param material_type: Specific type of material (Arnold, Stingray, etc.) - :param material_mesh: Mesh that the material is applied to - :return: - """ - self.materials_count += 1 - shader = self.get_shader(material_name) - shader_file_connections, shader_attributes = self.get_shader_information(shader, material_mesh) - material_dictionary = collections.OrderedDict(MaterialName=material_name, MaterialType=material_type, - DccApplication='Maya', AppliedMesh=material_mesh, - FileConnections=shader_file_connections, - SceneName=str(self.current_scene), - MaterialAttributes=shader_attributes) - material_name = 'Material_{}'.format(self.materials_count) - self.materials_dictionary[material_name] = material_dictionary - logging.info('\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n' - 'MATERIAL DEFINITION: {} \n' - ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n{}'.format( - self.materials_dictionary[material_name]['MaterialType'], - json.dumps(self.materials_dictionary[material_name], indent=4))) - - def set_material_descriptions(self): - """ - This function serves as the clearinghouse for all analyzed materials passing through the system. - It will determine whether or not the found material has already been processed, or if it needs to - be added to the final material dictionary. In the event that an encountered material has already - been processed, this function creates a register of all meshes it is applied to in the 'AppliedMesh' - attribute. - :return: - """ - scene_geo = mc.ls(v=True, geometry=True) - for target_mesh in scene_geo: - material_list = self.get_materials(target_mesh) - for material_name in material_list: - material_type = mc.nodeType(material_name) - - if material_type != 'lambert': - material_listed = [x for x in self.materials_dictionary - if self.materials_dictionary[x]['MaterialName'] == material_name] - - if not material_listed: - self.set_material_dictionary(str(material_name), str(material_type), str(target_mesh)) - else: - mesh_list = self.materials_dictionary[material_name].get('AppliedMesh') - if not isinstance(mesh_list, list): - self.materials_dictionary[str(material_name)]['AppliedMesh'] = [mesh_list, target_mesh] - else: - mesh_list.append(target_mesh) - - -# ++++++++++++++++++++++++++++++++++++++++++++++++# -# Maya Specific Shader Mapping # -# ++++++++++++++++++++++++++++++++++++++++++++++++# - -file_list = sys.argv[1:-1] -count = sys.argv[-1] -instance = MayaMaterials(file_list, count) - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/model.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/model.py deleted file mode 100755 index 3c23635438..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/model.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -from PySide2.QtCore import QAbstractItemModel, QModelIndex, Qt - - -class MaterialsModel(QAbstractItemModel): - def __init__(self, headers, data, parent=None): - super(MaterialsModel, self).__init__(parent) - - self.rootItem = TreeNode(headers) - self.parents = [self.rootItem] - self.indentations = [0] - self.create_data(data) - - def create_data(self, data, indent=-1): - """ - Recursive loop that structures Model data into tree form. - :param data: Row information. - :param indent: Column information. This helps to facilitate the creation of nested rows. - :return: - """ - if type(data) == dict: - indent += 1 - position = 4 * indent - for key, value in data.items(): - if position > self.indentations[-1]: - if self.parents[-1].childCount() > 0: - self.parents.append(self.parents[-1].child(self.parents[-1].childCount() - 1)) - self.indentations.append(position) - else: - while position < self.indentations[-1] and len(self.parents) > 0: - self.parents.pop() - self.indentations.pop() - parent = self.parents[-1] - parent.insertChildren(parent.childCount(), 1, parent.columnCount()) - parent.child(parent.childCount() - 1).setData(0, key) - value_string = str(value) if type(value) != dict else str('') - parent.child(parent.childCount() - 1).setData(1, value_string) - try: - self.create_data(value, indent) - except RuntimeError: - pass - - @staticmethod - def get_attribute_value(search_string, search_column): - """ Convenience function for quickly accessing row information based on attribute keys. """ - for childIndex in range(search_column.childCount()): - child_item = search_column.child(childIndex) - child_value = child_item.itemData - if child_value[0] == search_string: - return child_value[1] - return None - - def index(self, row, column, index=QModelIndex()): - """ Returns the index of the item in the model specified by the given row, column and parent index """ - if not self.hasIndex(row, column, index): - return QModelIndex() - if not index.isValid(): - item = self.rootItem - else: - item = index.internalPointer() - - child = item.child(row) - if child: - return self.createIndex(row, column, child) - return QModelIndex() - - def parent(self, index): - """ - Returns the parent of the model item with the given index If the item has no parent, - an invalid QModelIndex is returned - """ - if not index.isValid(): - return QModelIndex() - item = index.internalPointer() - if not item: - return QModelIndex() - - parent = item.parentItem - if parent == self.rootItem: - return QModelIndex() - else: - return self.createIndex(parent.childNumber(), 0, parent) - - def rowCount(self, index=QModelIndex()): - """ - Returns the number of rows under the given parent. When the parent is valid it means that - rowCount is returning the number of children of parent - """ - if index.isValid(): - parent = index.internalPointer() - else: - parent = self.rootItem - return parent.childCount() - - def columnCount(self, index=QModelIndex()): - """ Returns the number of columns for the children of the given parent """ - return self.rootItem.columnCount() - - def data(self, index, role=Qt.DisplayRole): - """ Returns the data stored under the given role for the item referred to by the index """ - if index.isValid() and role == Qt.DisplayRole: - return index.internalPointer().data(index.column()) - elif not index.isValid(): - return self.rootItem.data(index.column()) - - def headerData(self, section, orientation, role=Qt.DisplayRole): - """ Returns the data for the given role and section in the header with the specified orientation """ - if orientation == Qt.Horizontal and role == Qt.DisplayRole: - return self.rootItem.data(section) - - -class TreeNode(object): - def __init__(self, data, parent=None): - self.parentItem = parent - self.itemData = data - self.children = [] - - def child(self, row): - return self.children[row] - - def childCount(self): - return len(self.children) - - def childNumber(self): - if self.parentItem is not None: - return self.parentItem.children.index(self) - - def columnCount(self): - return len(self.itemData) - - def data(self, column): - return self.itemData[column] - - def insertChildren(self, position, count, columns): - if position < 0 or position > len(self.children): - return False - for row in range(count): - data = [v for v in range(columns)] - item = TreeNode(data, self) - self.children.insert(position, item) - - def parent(self): - return self.parentItem - - def setData(self, column, value): - if column < 0 or column >= len(self.itemData): - return False - self.itemData[column] = value diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/standalone.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/standalone.py deleted file mode 100644 index e7a8445953..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/standalone.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# - -"""Boostraps and Starts Standalone DCC Material Converter utility""" - -# built in's -import os -import site - -# ------------------------------------------------------------------------- -# \dev\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\PythonTools\DCC_Material_Converter\standalone.py -_MODULE_PATH = os.path.abspath(__file__) - -_DCCSIG_REL_PATH = "../../../.." -_DCCSIG_PATH = os.path.join(_MODULE_PATH, _DCCSIG_REL_PATH) -_DCCSIG_PATH = os.path.normpath(_DCCSIG_PATH) - -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', - os.path.abspath(_DCCSIG_PATH)) - -# we don't have access yet to the DCCsi Lib\site-packages -site.addsitedir(_DCCSIG_PATH) # PYTHONPATH - -# azpy bootstrapping and extensions -import azpy.config_utils -_config = azpy.config_utils.get_dccsi_config() -settings = _config.get_config_settings(setup_ly_pyside=True) - -from main import launch_material_converter - -launch_material_converter() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/Launcher/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/Launcher/main.py deleted file mode 100644 index 5812755035..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/Launcher/main.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# -- This line is 75 characters ------------------------------------------- -# built-ins -import os -import sys -import logging as _logging - -# azpy extensions -import azpy.config_utils -_config = azpy.config_utils.get_dccsi_config() -settings = _config.get_config_settings(setup_ly_pyside=True) - -# 3rd Party (we may or do provide) -from pathlib import Path -from pathlib import PurePath - -# Lumberyard extensions -from azpy.env_bool import env_bool -from azpy.constants import ENVAR_DCCSI_GDEBUG -from azpy.constants import ENVAR_DCCSI_DEV_MODE - -# ------------------------------------------------------------------------- -# set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_GDEBUG) - -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) - -_MODULENAME = 'DCCsi.SDK.pythontools.launcher.main' - -_log_level = _logging.INFO -if _G_DEBUG: - _log_level = _logging.DEBUG - -_LOGGER = azpy.initialize_logger(name=_MODULENAME, - log_to_file=True, - default_log_level=_log_level) - -_LOGGER.debug('Starting up: {0}.'.format({_MODULENAME})) -# ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -def main(): - from PySide2.QtWidgets import QApplication, QPushButton - - app = QApplication(sys.argv) -# ------------------------------------------------------------------------- - - -# -------------------------------------------------------------------------- -if __name__ == '__main__': - """Run this file as main""" - -app = QApplication([]) # Start an application. -window = QWidget() # Create a window. -layout = QVBoxLayout() # Create a layout. -button = QPushButton("I'm just a Button man") # Define a button -layout.addWidget(QLabel('Hello World!')) # Add a label -layout.addWidget(button) # Add the button man -window.setLayout(layout) # Pass the layout to the window -window.show() # Show window -app.exec_() # Execute the App diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/atom_material.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/atom_material.py index 4c35861b9c..b7a6bfa3a1 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/atom_material.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/atom_material.py @@ -29,7 +29,7 @@ from pathlib import Path # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py index 50a4d3fdda..f3e91b59ce 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py @@ -34,20 +34,20 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # these are for module debugging, set to false on submit -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = 'DCCsi.SDK.substance.builder.bootstrap' _log_level = int(20) -if _G_DEBUG: +if _DCCSI_GDEBUG: _log_level = int(10) _LOGGER = azpy.initialize_logger(_PACKAGENAME, log_to_file=True, default_log_level=_log_level) _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME})) _LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH)) -_LOGGER.debug('_G_DEBUG: {}'.format(_G_DEBUG)) +_LOGGER.debug('_G_DEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) if _DCCSI_DEV_MODE: @@ -69,7 +69,7 @@ from dynaconf import settings try: from PySide2.QtWidgets import QApplication except: - _dccsi_config.init_ly_pyside(settings.LY_DEV) # init for standalone + _dccsi_config.init_o3de_pyside(settings.O3DE_DEV) # init for standalone # running in the editor if the QtForPython Gem is enabled # you should already have access and shouldn't need to set up @@ -92,20 +92,20 @@ os.environ["PYSBS_DIR_PATH"] = str(_PYSBS_DIR_PATH) # standard paths we may use downstream # To Do: move these into a dynaconf config extension specific to this tool? -from azpy.constants import ENVAR_LY_DEV -_LY_DEV = Path(os.getenv(ENVAR_LY_DEV, - settings.LY_DEV)).resolve() +from azpy.constants import ENVAR_O3DE_DEV +_O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, + settings.O3DE_DEV)).resolve() -from azpy.constants import ENVAR_LY_PROJECT_PATH -_LY_PROJECT_PATH = Path(os.getenv(ENVAR_LY_PROJECT_PATH, - settings.LY_PROJECT_PATH)).resolve() +from azpy.constants import ENVAR_O3DE_PROJECT_PATH +_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, + settings.O3DE_PROJECT_PATH)).resolve() from azpy.constants import ENVAR_DCCSI_SDK_PATH _DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, settings.DCCSIG_SDK_PATH)).resolve() # build some reuseable path parts for the substance builder -_PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Assets').resolve() +_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve() _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() # ------------------------------------------------------------------------- @@ -116,15 +116,15 @@ _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() if __name__ == "__main__": """Run this file as main""" - _LOGGER.info('_LY_DEV: {}'.format(_LY_DEV)) - _LOGGER.info('_LY_PROJECT_PATH: {}'.format(_LY_PROJECT_PATH)) + _LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV)) + _LOGGER.info('_O3DE_PROJECT_PATH: {}'.format(_O3DE_PROJECT_PATH)) _LOGGER.info('_DCCSI_SDK_PATH: {}'.format(_DCCSI_SDK_PATH)) _LOGGER.info('_PYSBS_DIR_PATH: {}'.format(_PYSBS_DIR_PATH)) _LOGGER.info('_PROJECT_ASSETS_PATH: {}'.format(_PROJECT_ASSETS_PATH)) _LOGGER.info('_PROJECT_MATERIALS_PATH: {}'.format(_PROJECT_MATERIALS_PATH)) - if _G_DEBUG: + if _DCCSI_GDEBUG: _dccsi_config.test_pyside2() # runs a small PySdie2 test # remove the logger diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py index cc501fe872..9408b94919 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py @@ -35,7 +35,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_GDEBUG) for handler in _logging.root.handlers[:]: @@ -44,7 +44,7 @@ for handler in _logging.root.handlers[:]: _MODULENAME = 'DCCsi.SDK.substance.builder.sb_gui_main' _log_level = _logging.INFO -if _G_DEBUG: +if _DCCSI_GDEBUG: _log_level = _logging.DEBUG _LOGGER = azpy.initialize_logger(name=_MODULENAME, @@ -71,12 +71,12 @@ import config _LOGGER.debug('config.py is: {}'.format(config)) # initialize the Lumberyard Qt / PySide2 -config.init_ly_pyside(settings.LY_DEV) # for standalone +config.init_o3de_pyside(settings.O3DE_DEV) # for standalone settings.setenv() # for standalone # log debug info about Qt/PySide2 _LOGGER.debug('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) -_LOGGER.debug('LY_BIN_PATH: {}'.format(settings.LY_BIN_PATH)) +_LOGGER.debug('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH)) _LOGGER.debug('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) _LOGGER.debug('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) # ------------------------------------------------------------------------- @@ -123,26 +123,26 @@ from atom_material import AtomMaterial # ------------------------------------------------------------------------- # To Do: still should manage via dynaconf (dynamic config and settings) -from azpy.constants import ENVAR_LY_DEV -_LY_DEV = Path(os.getenv(ENVAR_LY_DEV, None)).resolve() +from azpy.constants import ENVAR_O3DE_DEV +_O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, None)).resolve() -from azpy.constants import ENVAR_LY_PROJECT -_LY_PROJECT = os.getenv(ENVAR_LY_PROJECT, None) +from azpy.constants import ENVAR_O3DE_PROJECT +_O3DE_PROJECT = os.getenv(ENVAR_O3DE_PROJECT, None) -from azpy.constants import ENVAR_LY_PROJECT_PATH -_LY_PROJECT_PATH = Path(os.getenv(ENVAR_LY_PROJECT_PATH, None)).resolve() +from azpy.constants import ENVAR_O3DE_PROJECT_PATH +_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, None)).resolve() from azpy.constants import ENVAR_DCCSI_SDK_PATH _DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, None)).resolve() # build some reuseable path parts -_PROJECT_ASSET_PATH = Path(_LY_PROJECT_PATH).resolve() -_PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Materials').resolve() +_PROJECT_ASSET_PATH = Path(_O3DE_PROJECT_PATH).resolve() +_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Materials').resolve() # To Do: figure out a proper way to deal with Lumberyard game projects -_GEM_MATPLAY_PATH = Path(_LY_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve() -_GEM_ROYALTYFREE = Path(_LY_DEV, 'Gems', 'AtomContent', 'RoyaltyFreeAssets').resolve() -_GEM_SUBSOURCELIBRARY = Path(_LY_DEV, 'Gems', 'AtomContent', 'SubstanceSourceLibrary').resolve() +_GEM_MATPLAY_PATH = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve() +_GEM_ROYALTYFREE = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'RoyaltyFreeAssets').resolve() +_GEM_SUBSOURCELIBRARY = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'SubstanceSourceLibrary').resolve() _SUB_LIBRARY_PATH = Path(_GEM_SUBSOURCELIBRARY, 'Assets', 'SubstanceSource', 'Library').resolve() # ^ This hard codes a bunch of known asset gems, again bad # To Do: figure out a proper way to scrap the gem registry from project @@ -150,9 +150,9 @@ _SUB_LIBRARY_PATH = Path(_GEM_SUBSOURCELIBRARY, 'Assets', 'SubstanceSource', 'Li # path to watcher script _WATCHER_SCRIPT_PATH = Path(_DCCSI_SDK_PATH, 'substance', 'builder', 'watchdog', '__init__.py').resolve() -_TEX_RNDR_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve() -_MAT_OUTPUT_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve() -_SBSAR_COOK_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve() +_TEX_RNDR_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() +_MAT_OUTPUT_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() +_SBSAR_COOK_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() # ------------------------------------------------------------------------- @@ -171,7 +171,7 @@ class Window(QtWidgets.QDialog): # we should really init non-Qt stuff and set things up as properties if project_path is None: - self.project_path = str(_LY_PROJECT_PATH) + self.project_path = str(_O3DE_PROJECT_PATH) else: self.project_path = Path(project_path) @@ -213,7 +213,7 @@ class Window(QtWidgets.QDialog): self.matOutputPathComboBox = self.createComboBox(str(_MAT_OUTPUT_PATH)) # self.directoryComboBox = self.createComboBox(QtCore.QDir.currentPath()) - # I changed this to scan the _LY_PROJECT + # I changed this to scan the _O3DE_PROJECT # self.sbsarDirectory = self.return_1st_sbsar(Path(self.project_path, 'Assets')).resolve().parent self.sbsarDirectory = QtCore.QDir() self.sbsarDirectory.setCurrent(str(_PROJECT_ASSET_PATH)) @@ -672,13 +672,13 @@ class Window(QtWidgets.QDialog): # if you want relative paths here is a better way # first of all, assume we know the project we are in - #_LY_PROJECT_PATH + #_O3DE_PROJECT_PATH texture_output_path = Path(self.texRenderPathComboBox.currentText()).resolve() rel_tex_path = None for p in texture_output_path.parts: - if _LY_PROJECT == p: - index = texture_output_path.parts.index(_LY_PROJECT) + if _O3DE_PROJECT == p: + index = texture_output_path.parts.index(_O3DE_PROJECT) rel_tuple = texture_output_path.parts[index + 1:] rel_tex_path = Path(*list(rel_tuple)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py index 4763bf430c..441110b8d4 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py @@ -47,7 +47,7 @@ import pysbs.context as pysbs_context # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ @@ -68,10 +68,10 @@ _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] +_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py index 2a26f13be2..9652b8990a 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py @@ -47,7 +47,7 @@ import pysbs.context as pysbs_context # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ @@ -62,7 +62,7 @@ _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = os.getenv(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = os.getenv(ENVAR_DCCSI_GDEBUG, False) # global space debug flag _DCCSI_DEV_MODE = os.getenv(ENVAR_DCCSI_DEV_MODE, False) @@ -88,10 +88,10 @@ _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] +_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py index 31e2c81a57..6285ea0335 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py @@ -45,7 +45,7 @@ import pysbs.context as pysbs_context # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ @@ -66,10 +66,10 @@ _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] +_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py index 74293a8d77..8ffdf30e35 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py @@ -28,7 +28,7 @@ from azpy.constants import ENVAR_DCCSI_DEV_MODE from dynaconf import settings from pathlib import Path -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_DEV_MODE) _MODULENAME = 'DCCsi.SDK.substance.builder.sbsar_utils' @@ -190,15 +190,15 @@ if __name__ == "__main__": _SYNTH_ENV_DICT = synthetic_env.stash_env() from azpy.constants import ENVAR_DCCSIG_PATH - from azpy.constants import ENVAR_LY_PROJECT_PATH + from azpy.constants import ENVAR_O3DE_PROJECT_PATH # grab a specific path from the base_env _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] # use DCCsi as the project path for this test - _LY_PROJECT_PATH = _PATH_DCCSI + _O3DE_PROJECT_PATH = _PATH_DCCSI - _PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Assets').resolve() + _PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve() _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() # this will combine two parts into a single path (object) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py index af001902ed..0407a1db08 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py @@ -46,7 +46,7 @@ import pysbs.context as pysbs_context # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ @@ -67,10 +67,10 @@ _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] +_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py index d37a9cb5ec..35c970e711 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py @@ -53,7 +53,7 @@ import pysbs.context as pysbs_context # ------------------------------------------------------------------------- # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ @@ -71,8 +71,8 @@ _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME})) from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) -_LY_DEV = _SYNTH_ENV_DICT[ENVAR_LY_DEV] -_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] +_O3DE_DEV = _SYNTH_ENV_DICT[ENVAR_O3DE_DEV] +_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] # ------------------------------------------------------------------------- @@ -90,7 +90,7 @@ class MyHandler(PatternMatchingEventHandler): """ self.outputName = event.src_path.split(".sbsar")[0].split("/")[-1] self.outputCookPath = event.src_path.split(self.outputName) - self.outputRenderPath = Path(_LY_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm() + self.outputRenderPath = Path(_O3DE_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm() _LOGGER.debug(self.outputCookPath, self.outputName, self.outputRenderPath) pysbs_batch.sbsrender_info(input=event.src_path) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/3dsMax/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/3dsMax/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/3dsMax/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/_init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/_init__.py new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/_init__.py @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/main.py new file mode 100644 index 0000000000..b08991f63e --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/AddOns/MaterialExporter/main.py @@ -0,0 +1,21 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- +# DCCsi\\Tools\\Blender\\AddOns\\MaterialExporter\\main.py + +""" A in Blender tool for exporting BRDF materials as O3DE Atom StandardPBR +""" + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """Run this file as main""" + + print('MaterialExporter.main() not implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/config.py new file mode 100644 index 0000000000..b0f67b1034 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/config.py @@ -0,0 +1,11 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +print('Not Implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.dev/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/settings.json similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.dev/stub rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/settings.json diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/start.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/start.py new file mode 100644 index 0000000000..b0f67b1034 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Blender/start.py @@ -0,0 +1,11 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +print('Not Implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Houdini/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Houdini/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Houdini/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Marmoset/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Marmoset/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Marmoset/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/Prefs/icons/MayaStartupImage.png b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/Prefs/icons/MayaStartupImage.png new file mode 100644 index 0000000000..8f5d8290a8 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/Prefs/icons/MayaStartupImage.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:083ab199e273431963fc5f80bb80b7d1b1d428f7b12a5180d7199a7431291982 +size 311865 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/plugins/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/plugins/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/scripts/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/scripts/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/siteDir/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/2020/siteDir/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Help/HelpStub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Help/HelpStub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Projects/default/workspace.mel b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Projects/default/workspace.mel new file mode 100644 index 0000000000..c6474c4414 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Projects/default/workspace.mel @@ -0,0 +1,36 @@ +//Maya 2016 Project Definition + +workspace -fr "fluidCache" "cache/nCache/fluid"; +workspace -fr "images" "images"; +workspace -fr "offlineEdit" "scenes/edits"; +workspace -fr "furShadowMap" "renderData/fur/furShadowMap"; +workspace -fr "iprImages" "renderData/iprImages"; +workspace -fr "renderData" "renderData"; +workspace -fr "scripts" "scripts"; +workspace -fr "fileCache" "cache/nCache"; +workspace -fr "eps" "data"; +workspace -fr "shaders" "renderData/shaders"; +workspace -fr "3dPaintTextures" "sourceimages/3dPaintTextures"; +workspace -fr "translatorData" "data"; +workspace -fr "mel" "scripts"; +workspace -fr "furFiles" "renderData/fur/furFiles"; +workspace -fr "OBJ" "data"; +workspace -fr "particles" "cache/particles"; +workspace -fr "scene" "scenes"; +workspace -fr "furEqualMap" "renderData/fur/furEqualMap"; +workspace -fr "sourceImages" "sourceimages"; +workspace -fr "furImages" "renderData/fur/furImages"; +workspace -fr "clips" "clips"; +workspace -fr "depth" "renderData/depth"; +workspace -fr "movie" "movies"; +workspace -fr "audio" "sound"; +workspace -fr "bifrostCache" "cache/bifrost"; +workspace -fr "autoSave" "autosave"; +workspace -fr "mayaAscii" "scenes"; +workspace -fr "move" "data"; +workspace -fr "sound" "sound"; +workspace -fr "diskCache" "data"; +workspace -fr "illustrator" "data"; +workspace -fr "mayaBinary" "scenes"; +workspace -fr "templates" "assets"; +workspace -fr "furAttrMap" "renderData/fur/furAttrMap"; diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/IBLbaker_brdf_lut.dds b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/IBLbaker_brdf_lut.dds new file mode 100644 index 0000000000..81e62781b4 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/IBLbaker_brdf_lut.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:646b6d93b2c672bbbbcb46af1bfcaf26ca37c8a0c2b218989b145417bb6b7c93 +size 262272 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_diffuse.dds b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_diffuse.dds new file mode 100644 index 0000000000..980477af4b --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_diffuse.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86209db0389b152c709d529e9d5705219b44bfbf712a26788a5c2ab0adc0c373 +size 98452 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_specular.dds b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_specular.dds new file mode 100644 index 0000000000..fd6e1f99fc --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_lighting_specular.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd95898a04b81b80b095dbef34523f3b70a8c14bc9f82116f732ab648f25658b +size 2096788 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_skybox.dds b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_skybox.dds new file mode 100644 index 0000000000..304aaa0a1f --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/PBR/ly_cubempas/artist_workshop_4k_skybox.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a85a15d5c60102f414b4ad03604dbd1c78e3d1c1fe445f60db158b2c069f792d +size 25165972 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/SourceImages/MayaStartupImage.psd b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/SourceImages/MayaStartupImage.psd new file mode 100644 index 0000000000..8d630620ca --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/SourceImages/MayaStartupImage.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1318f73ca32ec56dfeb0233679504f6fc723081f0cafa8e7e2d0517b878defd1 +size 2000893 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/SourceImages/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/SourceImages/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/workspace.mel b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/workspace.mel new file mode 100644 index 0000000000..2cbf02f1aa --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Resources/workspace.mel @@ -0,0 +1,69 @@ +//Maya 2016 Project Definition + +workspace -fr "fluidCache" "mayaData/cache/nCache/fluid"; +workspace -fr "JT_DC" "mayaData/Trans/JT"; +workspace -fr "CATIAV4_DC" "mayaData/Trans/CATIAV4"; +workspace -fr "images" "mayaData/Images"; +workspace -fr "offlineEdit" "ArtSource/Maya"; +workspace -fr "STEP_DC" "mayaData/Trans/STEP"; +workspace -fr "furShadowMap" "mayaData/renderData/fur/furShadowMap"; +workspace -fr "SPF_DCE" "mayaData/Trans/SPF"; +workspace -fr "scripts" "mayaData/Scripts"; +workspace -fr "CATIAV5_DC" "mayaData/Trans/CATIAV5"; +workspace -fr "DAE_FBX" "mayaData/Trans/DAE_FBX"; +workspace -fr "shaders" "mayaData/renderData/shaders"; +workspace -fr "furFiles" "mayaData/renderData/fur/furFiles"; +workspace -fr "OBJ" "mayaData/OBJ"; +workspace -fr "FBX export" "mayaData/Trans/FBX_export"; +workspace -fr "furEqualMap" "mayaData/renderData/fur/furEqualMap"; +workspace -fr "Autodesk Packet File" "mayaData/Trans"; +workspace -fr "DAE_FBX export" "mayaData/Trans/DAE_FBX_export"; +workspace -fr "SPF_DC" "mayaData/Trans/SPF"; +workspace -fr "movie" "mayaData/movies"; +workspace -fr "DXF_DCE" "mayaData/Trans/DXF"; +workspace -fr "move" "mayaData/move"; +workspace -fr "mayaAscii" "ArtSource"; +workspace -fr "autoSave" "mayaData"; +workspace -fr "sound" "mayaData/Sounds"; +workspace -fr "mayaBinary" "ArtSource"; +workspace -fr "ZPR_DCE" "mayaData/Trans/ZPR"; +workspace -fr "STL_DCE" "mayaData/Trans/STL"; +workspace -fr "iprImages" "mayaData/renderData/iprImages"; +workspace -fr "PhysX" "mayaData/Trans/Physx"; +workspace -fr "DXF_DC" "mayaData/Trans/DXF"; +workspace -fr "FBX" "mayaData/Trans/FBX"; +workspace -fr "studioImport" "mayaData/Trans"; +workspace -fr "UG_DCE" "mayaData/Trans/UG"; +workspace -fr "renderData" "mayaData/renderData"; +workspace -fr "fileCache" "mayaData/cache/nCache"; +workspace -fr "eps" "mayaData/EPS"; +workspace -fr "Fbx" "Objects"; +workspace -fr "3dPaintTextures" "mayaData/images/3dPaintTextures"; +workspace -fr "translatorData" "mayaData"; +workspace -fr "mel" "mayaData/Scripts/Mel"; +workspace -fr "particles" "mayaData/cache/particles"; +workspace -fr "IV_DC" "mayaData/Trans/IV"; +workspace -fr "scene" "ArtSource"; +workspace -fr "DWG_DCE" "mayaData/Trans/DWG"; +workspace -fr "MayaCryExport" "Objects"; +workspace -fr "sourceImages" "ArtSource/Textures"; +workspace -fr "furImages" "mayaData/renderData/fur/furImages"; +workspace -fr "clips" "mayaData/clips"; +workspace -fr "PTC_DC" "mayaData/Trans/PTC"; +workspace -fr "STL_DC" "mayaData/Trans/STL"; +workspace -fr "IPT_DC" "mayaData/Trans/IPT"; +workspace -fr "CSB_DC" "mayaData/Trans/CSB"; +workspace -fr "SW_DC" "mayaData/Trans/SW"; +workspace -fr "depth" "mayaData/renderData/depth"; +workspace -fr "audio" "mayaData/Sounds"; +workspace -fr "DWG_DC" "mayaData/Trans/DWG"; +workspace -fr "bifrostCache" "mayaData/cache/bifrost"; +workspace -fr "IGES_DCE" "mayaData/Trans/IGES"; +workspace -fr "Alembic" "mayaData/Trans/Alembic"; +workspace -fr "illustrator" "mayaData/AI"; +workspace -fr "diskCache" "mayaData"; +workspace -fr "UG_DC" "mayaData/Trans/UG"; +workspace -fr "templates" "mayaData/assets"; +workspace -fr "OBJexport" "mayaData/Trans/Obj"; +workspace -fr "furAttrMap" "mayaData/renderData/fur/furAttrMap"; +workspace -fr "IGES_DC" "mayaData/Trans/IGES"; diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Mel/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Mel/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/max_materials.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub_util.py old mode 100755 new mode 100644 similarity index 51% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/max_materials.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub_util.py index a67c39910e..1dc43d8485 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/PythonTools/DCC_Material_Converter/max_materials.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/Python/stub_util.py @@ -1,18 +1,12 @@ +# coding:utf-8 +#!/usr/bin/python +# # Copyright (c) Contributors to the Open 3D Engine Project. # For complete copyright and license terms please see the LICENSE at the root of this distribution. # # SPDX-License-Identifier: Apache-2.0 OR MIT # # +# ------------------------------------------------------------------------- - -import MaxPlus -import sys - - -def get_material_information(): - for mesh_object in MaxPlus.Core.GetRootNode().Children: - print('Object---> {}'.format(mesh_object)) - - -get_material_information() +print('Not Implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/constants.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/constants.py new file mode 100644 index 0000000000..6ed8297ab9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/constants.py @@ -0,0 +1,32 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- + +""" +Module Documentation: + DccScriptingInterface:: Tools//maya//scripts//constants.py + +This module is mainly a bunch of commony used constants, and default strings +So we can make an update here once that is used elsewhere +""" +# ------------------------------------------------------------------------- +# built-ins +# none + +# -- External Python modules + +# -- DCCsi Extension Modules +#import azpy + +# -- maya imports +# none +# ------------------------------------------------------------------------- +OBJ_DCCSI_MAINMENU = 'O3deDCCsiMainMenu' +TAG_DCCSI_MAINMENU = 'DCCsi (O3DE:Atom)' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_callbacks.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_callbacks.py new file mode 100644 index 0000000000..4a2b756a5e --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_callbacks.py @@ -0,0 +1,201 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +""" +Module Documentation: + DccScriptingInterface:: SDK//maya//scripts//set_callbacks.py + +This module manages a set of predefined callbacks for maya +""" +# ------------------------------------------------------------------------- +# -- Standard Python modules +import os +import sys +import logging as _logging +# -- External Python modules +from box import Box +# maya imports +import maya.cmds as mc +import maya.api.OpenMaya as om +# -- DCCsi Extension Modules +from azpy.constants import * +import azpy.dcc.maya +azpy.dcc.maya.init() # <-- should have already run? +import azpy.dcc.maya.callbacks.event_callback_handler as azEvCbH +import azpy.dcc.maya.callbacks.node_message_callback_handler as azNdMsH +# Node Message Callback Setup +import azpy.dcc.maya.callbacks.on_shader_rename as oSR +from set_defaults import set_defaults +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE + +# global space +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, True) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, True) + +_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_callbacks' + +_LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20)) +_LOGGER.debug('Invoking:: {0}.'.format({_MODULENAME})) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# global scope callbacks, set up set and initialize all to None +# To Do: should callback initialization use data-driven settings? +# To Do: should we move callback initialization to a sub-module? +# To Do: move the callback key like 'NewSceneOpened' here (instead of None) +# ^ this would provide ability to loop through and replace key with CB object + +_G_CALLBACKS = Box(box_dots=True) # global scope container +_G_PRIMEKEY = 'DCCsi_callbacks' +_G_CALLBACKS[_G_PRIMEKEY] = True # required prime key + + +# ------------------------------------------------------------------------- +def init_callbacks(_callbacks=_G_CALLBACKS): + # store as a dict (Box is a fancy dict) + _callbacks[_G_PRIMEKEY] = True # required prime key + + # signature dict['callback key'] = ('CallBack'(type), func, callbackObj) + _callbacks['on_new_file'] = ['NewSceneOpened', set_defaults, None] + _callbacks['new_scene_fix_paths'] = ['NewSceneOpened', install_fix_paths, None] + _callbacks['post_scene_fix_paths'] = ['PostSceneRead', install_fix_paths, None] + _callbacks['workspace_changed'] = ['workspaceChanged', update_workspace, None] + _callbacks['quit_app'] = ['quitApplication', uninstall_callbacks, None] + + # nodeMessage style callbacks + # fire a function + _func_00 = oSR.on_shader_rename_rename_shading_group + # using a nodeMessage callback trigger + _cb_00 = om.MNodeMessage.addNameChangedCallback + # all nodeMessage type callbacks can use 'nodeMessageType' key + _callbacks['shader_rename'] = ['nodeMessageType', (_func_00, _cb_00), None] + + return _callbacks +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def uninstall_callbacks(): + """Bulk uninstalls hte globally defined set of callbacks: + _G_callbacks""" + + global _G_CALLBACKS + + _LOGGER.debug('uninstall_callbacks() fired') + + for key, value in _G_CALLBACKS: + if value[2] is not None: # have a cb + value[2].uninstall() # so uninstall it + else: + _LOGGER.warning('No callback in: key {0}, value:{1}' + ''.format(key, value)) + _G_CALLBACKS = None + _LOGGER.info('DCCSI CALLBACKS UNINSTALLED ... EXITING') + return _G_CALLBACKS +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def install_callbacks(_callbacks=_G_CALLBACKS): + """Bulk installs the globally defined set of callbacks: + _G_callbacks""" + + _LOGGER.debug('install_callback_set() fired') + + _callbacks = init_callbacks(_callbacks) + + # we initialized the box with this so pop it + if 'box_dots' in _callbacks: + _callbacks.pop('box_dots') + + # don't pass anything but carefully considered dict + if _G_PRIMEKEY in _callbacks: + _primekey = _callbacks.pop(_G_PRIMEKEY) + else: + _LOGGER.error('No prime key, use a correct dictionary') + #To Do: implement error handling and return codes + return _callbacks[None] + + for key, value in _G_CALLBACKS.items(): + # we popped the prime key should the rest should be safe + if value[0] != 'nodeMessageType': + # set callback up + _cb = azEvCbH.EventCallbackHandler(value[0], + value[1]) + # ^ installs by default + # stash it back into managed dict + value[2] = _cb + # value[2].install() + else: + # set up callback, value[1] should be tupple(func, trigger) + _cb = azNdMsH.NodeMessageCallbackHandler(value[1][0], + value[1][1]) + # ^ installs by default + # stash it back into managed dict + value[2] = _cb + # value[2].install() + + return _callbacks +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def install_fix_paths(foo=None): + """Installs and triggers a fix paths module. + This can repair broken reference paths in shaders""" + global _fix_paths + _fix_paths = None + + _LOGGER.debug('install_fix_paths() fired') + + # if we don't have it already, this function is potentially triggered + # by a callback, so we don't need to keep importing it. + try: + _fix_paths + reload(_fix_paths) + except Exception as e: + try: + import fixPaths as _fix_paths + except Exception as e: + # To Do: not implemented yet + _LOGGER.warning('NOT IMPLEMENTED: {0}'.format(e)) + + # if we have it, use it + if _fix_paths: + return _fix_paths.main() + else: + # To Do: implement error handling and return codes + return 1 +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def update_workspace(foo=None): + """Forces and update of the workspace (workspace.mel)""" + _LOGGER.debug('update_workspace() fired') + result = mc.workspace(update=True) + return result +# ------------------------------------------------------------------------- + +# install and init callbacks on an import obj +_G_CALLBACKS = install_callbacks(_G_CALLBACKS) + +# ========================================================================== +# Module Tests +#========================================================================== +if __name__ == '__main__': + _G_CALLBACKS = install_callbacks(_G_CALLBACKS) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_defaults.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_defaults.py new file mode 100644 index 0000000000..639b03c297 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_defaults.py @@ -0,0 +1,93 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +""" +Module Documentation: + DccScriptingInterface:: SDK//maya//scripts//set_pref_defaults.py + +This module manages a predefined set of prefs for maya +""" +# ------------------------------------------------------------------------- +# -- Standard Python modules +import os +import sys +# -- External Python modules + +# -- DCCsi Extension Modules +import azpy +from azpy.constants import * + +# -- maya imports +import maya.cmds as mc +import maya.mel as mm + +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE + +# global space +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) + +_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_defaults' + +_LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20)) +_LOGGER.debug('Invoking:: {0}.'.format({_MODULENAME})) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def set_defaults(units='meter'): + """This method will make defined settings changes to Maya prefs, + to better configure maya to work with Lumberyard""" + # To Do: make this data-driven env/settings, game teams should be able + # to opt out and/or set their prefered configuration. + + _LOGGER.debug('set_defaults_lumberyard() fired') + + # set up default units ... this should be moved to bootstrap config + _LOGGER.info('Default, 1 Linear Game Unit in Lumberyard == 1 Meter' + ' in Maya content. Setting default linear units to Meters' + ' (user can change to other units in the preferences)') + + result = mc.currentUnit(linear=units) + + # set up grid defaults + _LOGGER.info('Setting Grid defaults, to match default unit scale.' + '(user can change grid config manually') + try: + mc.grid(size=32, spacing=1, divisions=10) + except Exception as e: + _LOGGER.warning('{0}'.format(e)) + + # viewFit + _LOGGER.info('Changing default mc.viewFit') + try: + mc.viewFit() + except Exception as e: + _LOGGER.warning('{0}'.format(e)) + + # some mel commands + _LOGGER.info('Changing sersp camera clipping planes') + try: + mm.eval(str(r'setAttr "perspShape.nearClipPlane" 0.01;')) + mm.eval(str(r'setAttr "perspShape.farClipPlane" 1000;')) + except Exception as e: + _LOGGER.warning('{0}'.format(e)) + + # set up fixPaths + _LOGGER.info('~ Setting up fixPaths in default scene') + + return 0 +# ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_menu.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_menu.py new file mode 100644 index 0000000000..e417324d0b --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_menu.py @@ -0,0 +1,88 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +""" +Module Documentation: + DccScriptingInterface:: SDK//maya//scripts//set_menu.py + +This module creates and manages a DCCsi mainmenu +""" +# ------------------------------------------------------------------------- +# -- Standard Python modules +# none + +# -- External Python modules +# none + +# -- DCCsi Extension Modules +import azpy +from constants import OBJ_DCCSI_MAINMENU +from constants import TAG_DCCSI_MAINMENU + +# -- maya imports +import pymel.core as pm +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE + +# global space +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) + +_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_menu' + +_LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20)) +_LOGGER.debug('Invoking:: {0}.'.format({_MODULENAME})) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def menu_cmd_test(): + _LOGGER.info('test_func(), is TESTING main menu') + return +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +def set_main_menu(obj_name=OBJ_DCCSI_MAINMENU, label=TAG_DCCSI_MAINMENU): + _main_window = pm.language.melGlobals['gMainWindow'] + + _menu_obj = obj_name + _menu_label = label + + # check if it already exists and remove (so we don't duplicate) + if pm.menu(_menu_obj, label=_menu_label, exists=True, parent=_main_window): + pm.deleteUI(pm.menu(_menu_obj, e=True, deleteAllItems=True)) + + # create the main menu object + _custom_tools_menu = pm.menu(_menu_obj, + label=_menu_label, + parent=_main_window, + tearOff=True) + + # make a dummpy sub-menu + pm.menuItem(label='Menu Item Stub', + subMenu=True, + parent=_custom_tools_menu, + tearOff=True) + + # make a dummy menu item to test + pm.menuItem(label='Test', command=pm.Callback(menu_cmd_test)) + return _custom_tools_menu + +# ========================================================================== +# Run as LICENSE +#========================================================================== +if __name__ == '__main__': + + _custom_menu = set_main_menu() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_shelf.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_shelf.py new file mode 100644 index 0000000000..1bee05afe8 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/set_shelf.py @@ -0,0 +1,130 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +""" +Module Documentation: + DccScriptingInterface:: SDK//maya//scripts//set_shelf.py + +This module manages a custom shelf in maya for the DCCsi +Reference: https://gist.github.com/vshotarov/1c3176fe9e38dcaadd1e56c2f15c95d9 +""" +# ------------------------------------------------------------------------- +# -- Standard Python modules +# none + +# -- External Python modules +# none + +# -- DCCsi Extension Modules +# none + +# -- Maya Extension Modules +import maya.cmds as mc +# ------------------------------------------------------------------------- + +def _null(*args): + pass + +# ------------------------------------------------------------------------- +class customShelf(_Custom_Shelf): + '''This is an example shelf.''' + + def build(self): + self.add_button(label="button1") + self.add_button("button2") + self.add_button("popup") + p = mc.popupMenu(b=1) + self.add_menu_item(p, "popupMenuItem1") + self.add_menu_item(p, "popupMenuItem2") + sub = self.add_submenu(p, "subMenuLevel1") + self.add_menu_item(sub, "subMenuLevel1Item1") + sub2 = self.add_submenu(sub, "subMenuLevel2") + self.add_menu_item(sub2, "subMenuLevel2Item1") + self.add_menu_item(sub2, "subMenuLevel2Item2") + self.add_menu_item(sub, "subMenuLevel1Item2") + self.add_menu_item(p, "popupMenuItem3") + self.add_button("button3") +# ------------------------------------------------------------------------- + + + +class _Custom_Shelf(): + '''A simple class to build custom shelves in maya. + The build method is empty and an inheriting class should override''' + + def __init__(self, name="DCCsi", icon_path=""): + self._name = name + + self._icon_path = icon_path + + self._label_background_color = (0, 0, 0, 0) + self._label_colour = (.9, .9, .9) + + self._clean_old_shlef() + + mc.setParent(self._name) + + self.build() + + def build(self): + '''Override this method in custom class. + Otherwise, nothing is added to the shelf.''' + pass + + def add_button(self, + label='', + icon="commandButton.png", + command=_null, + doubleCommand=_null): + '''Adds a shelf button with the specified label, + command, double click command and image.''' + mc.setParent(self._name) + if icon: + icon = self._icon_path + icon + mc.shelfButton(width=37, height=37, + image=icon, + label=label, + command=command, + doubleClickCommand=doubleCommand, + imageOverlayLabel=label, + overlayLabelBackColor=self._label_background_color, + overlayLabelColor=self._label_colour) + + def add_menu_item(self, parent, label, command=_null, icon=""): + '''Adds a shelf button with the specified label, + command, double click command and image.''' + if icon: + icon = self._icon_path + icon + return mc.menuItem(p=parent, l=label, c=command, i="") + + def add_submenu(self, parent, label, icon=None): + '''Adds a sub menu item with the specified label and icon + to the specified parent popup menu.''' + if icon: + icon = self._icon_path + icon + return mc.menuItem(p=parent, l=label, i=icon, subMenu=1) + + def _clean_old_shlef(self): + '''Checks if the shelf exists and empties it if it does or + creates it if it does not.''' + if mc.shelfLayout(self._name, ex=1): + if mc.shelfLayout(self._name, q=1, ca=1): + for each in mc.shelfLayout(self._name, q=1, ca=1): + mc.deleteUI(each) + else: + mc.shelfLayout(self._name, p="ShelfLayout") + + +# ========================================================================== +# Module Tests +# ========================================================================== +if __name__ == '__main__': + customShelf() + pass diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py new file mode 100644 index 0000000000..c68eb8d256 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py @@ -0,0 +1,325 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +from __future__ import unicode_literals + +""" +This module fullfils the maya bootstrap pattern as described in their docs +https://tinyurl.com/y2aoz8es + +Pattern is similar to Lumberyard Editor\\Scripts\\bootstrap.py + +For now the proper way to initiate Maya boostrapping the DCCsi, is to use +the provided env and launcher bat files. + +If you are developing for the DCCsi you can use this launcher to start Maya: +DccScriptingInterface\\Launchers\\Windows\\Launch_Maya_2020.bat" + +To Do: ATOM-5861 +""" +__project__ = 'DccScriptingInterface' + +# it is really hard to debug userSetup bootstrapping +# this enables some rudimentary logging for debugging +_BOOT_INFO = True + +# ------------------------------------------------------------------------- +# built in's +import os +import sys +import site +import inspect +import traceback +import logging as _logging + +# -- DCCsi Extension Modules +import azpy +from azpy.constants import * +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE + +# To Do: needs to be updated to use dynaconf and config.py +from azpy.env_base import _BASE_ENVVAR_DICT + +# -- maya imports +import maya.cmds as cmds +import maya.mel as mel +#from pymel.all import * +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# global space +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_DEV_MODE = True # force true for debugger testing + +_ORG_TAG = r'Amazon::Lumberyard' +_APP_TAG = r'DCCsi' +_TOOL_TAG = r'SDK.Maya.Scripts.userSetup' +_TYPE_TAG = r'entrypoint' # bootstrap + +_MODULENAME = str('{0}.{1}'.format(_APP_TAG, _TOOL_TAG)) + +_LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20)) +_LOGGER.info('Initializing: {0}.'.format({_MODULENAME})) +_LOGGER.info('DCCSI_GDEBUG: {0}.'.format({_DCCSI_GDEBUG})) +_LOGGER.info('DCCSI_DEV_MODE: {0}.'.format({_DCCSI_DEV_MODE})) + +# flag to turn off setting up callbacks, until they are fully implemented +# To Do: consider making it a settings option to define and enable/disable +_G_LOAD_CALLBACKS = True # couple bugs, couple NOT IMPLEMENTED +_LOGGER.info('DCCSI_MAYA_SET_CALLBACKS: {0}.'.format({_G_LOAD_CALLBACKS})) + +# early attach WingIDE debugger (can refactor to include other IDEs later) +if _DCCSI_DEV_MODE: + from azpy.test.entry_test import connect_wing + foo = connect_wing() +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# To Do REMOVE this block and replace with dev module +# debug prints, To Do: this should be moved to bootstrap config +#_G_DEBUGGER = os.getenv(ENVAR_DCCSI_GDEBUGGER, "WING") + +#if _DCCSI_DEV_MODE: + #if _G_DEBUGGER == "WING": + #_LOGGER.info('{0}'.format('-' * 74)) + #_LOGGER.info('Developer Debug Mode: {0}, Basic debugger: {1}'.format(_G_DEBUG, _G_DEBUGGER)) + #try: + #_LOGGER.info('Attempting to start basic WING debugger') + #import azpy.lmbr.test + + #_LOGGER.info('Package Imported: azpy.test') + #ouput = azpy.entry_test.main(verbose=False, + #connectDebugger=True, + #returnOuput=_G_DEBUG) + #_LOGGER.info(ouput) + #pass + #except Exception as e: + #_LOGGER.info("Error: azpy.test, entry_test (didn't perform)") + #_LOGGER.info("Exception: {0}".format(e)) + #pass + #elif _G_DEBUGGER == "PYCHARM": + ## https://github.com/juggernate/PyCharm-Maya-Debugging + #_LOGGER.info('{0}'.format('-' * 74)) + #_LOGGER.info('Developer Debug Mode: {0}, Basic debugger: {1}'.format(_G_DEBUG, _G_DEBUGGER)) + #sys.path.append('C:\Program Files\JetBrains\PyCharm 2019.1.3\debug-eggs\pydevd-pycharm.egg') + #try: + #_LOGGER.info('Attempting to start basic PYCHARM debugger') + ## Inside Maya Python Console (Tip: add to a shelf button for quick access) + #import pydevd + + #_LOGGER.info('Package Imported: pydevd') + #pydevd.settrace('localhost', port=7720, suspend=False) + #_LOGGER.info('PYCHARM Debugger Attach Success!!!') + ## To disconnect run: + ## pydevd.stoptrace() + #pass + #except Exception as e: + #_LOGGER.info("Error: pydevd.settrace (didn't perform)") + #_LOGGER.info("Exception: {0}".format(e)) + #pass + #else: + #pass +## ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# validate access to the DCCsi and it's Lib site-packages +# bootstrap site-packages by version +from azpy.constants import PATH_DCCSI_PYTHON_LIB_PATH + +try: + os.path.exists(PATH_DCCSI_PYTHON_LIB_PATH) + site.addsitedir(PATH_DCCSI_PYTHON_LIB_PATH) + _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB_PATH)) +except Exception as e: + _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB_PATH)) + raise e + +# 3rdparty +from unipath import Path +from box import Box +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +# Maya is frozen +#_MODULE_PATH = Path(__file__) +# https://tinyurl.com/y49t3zzn +# module path when frozen +_MODULE_FILEPATH = os.path.abspath(inspect.getfile(inspect.currentframe())) +_MODULE_PATH = os.path.dirname(_MODULE_FILEPATH) +if _BOOT_INFO: + _LOGGER.debug('Boot: CWD: {}'.format(os.getcwd())) + _LOGGER.debug('Frozen: _MODULE_FILEPATH: {}'.format(_MODULE_FILEPATH)) + _LOGGER.debug('Frozen: _MODULE_PATH: {}'.format(_MODULE_PATH)) + _LOGGER.debug('Module __name__: {}'.format(__name__)) +# root: INFO: Module __name__: __main__ + +_LOGGER.info('_MODULENAME: {}'.format(_MODULENAME)) + +# ------------------------------------------------------------------------- +# check some env var tags (fail if no, likely means no proper code access) +_STR_ERROR_ENVAR = "Envar 'key' does not exist in base_env: {0}" +_DCCSI_TOOLS_PATH = None +# To Do: needs to be updated to use dynaconf and config.py +try: + _DCCSI_TOOLS_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH] +except Exception as e: + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH])) + +_O3DE_PROJECT_PATH = None +try: + _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] +except Exception as e: + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) + +# check some env var tags (fail if no, likely means no proper code access) +_O3DE_DEV = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] +_O3DE_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] +_O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] +_O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# To Do: implement data driven config +# Currently not used, but will be where we store the ordered dict +# which is parsed from the project bootstrapping config files. +_G_app_config = {} + +# global scope maya callbacks container +_G_callbacks = Box(box_dots=True) # global scope container + +# used to store fixPaths in the global scope +_fix_paths = None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# add appropriate common tools paths to the maya environment variables +def startup(): + """Early starup execution before mayautils.executeDeferred(). + Some things like UI and plugins should be defered to avoid failure""" + _LOGGER.info('startup() fired') + + # get known paths + _KNOWN_PATHS = site._init_pathinfo() + + if os.path.isdir(_DCCSI_TOOLS_PATH): + site.addsitedir(_DCCSI_TOOLS_PATH, _KNOWN_PATHS) + try: + import azpy.test + _LOGGER.info('SUCCESS, import azpy.test') + except Exception as e: + _LOGGER.warning('startup(), could not import azpy.test') + + _LOGGER.info('startup(), COMPLETE') + return 0 +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# verify Shared\Python exists and add it as a site dir. Begin imports and config. +def post_startup(): + """Allows for a defered execution startup sequence""" + + _LOGGER.info('post_startup() fired') + + # plugins, To Do: these should be moved to bootstrapping config + try: + maya.cmds.loadPlugin("dx11Shader") + except Exception as e: + _LOGGER.error(e) # not a hard failure + + # Lumberyard DCCsi environment ready or error out. + try: + import azpy.dcc.maya + _LOGGER.info('Python module imported: azpy.dcc.maya') + except Exception as e: + _LOGGER.error(e) + _LOGGER.error(traceback.print_exc()) + return 1 + + # Dccsi azpy maya ready or error out. + try: + azpy.dcc.maya.init() + _LOGGER.info('SUCCESS, azpy.dcc.maya.init(), code accessible.') + except Exception as e: + _LOGGER.error(e) + _LOGGER.error(traceback.print_exc()) + return 1 + + # callbacks, To Do: these should also be moved to the bootstrapping config + # Defered startup after the Ui is running. + _G_CALLBACKS = Box(box_dots=True) # this just ensures a global scope container + if _G_LOAD_CALLBACKS: + from set_callbacks import _G_CALLBACKS + # ^ need to hold on to this as the install repopulate set + + # this ensures the fixPaths callback is loaded + # even when the other global callbacks are disabled + from set_callbacks import install_fix_paths + install_fix_paths() + + # set the project workspace + #_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE) + if os.path.isfile(_project_workspace): + try: + # load workspace + maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) + _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) + maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) + except Exception as e: + _LOGGER.error(e) + else: + _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) + + # Set up Lumberyard, maya default setting + from set_defaults import set_defaults + set_defaults() + + # Setup UI tools + if not maya.cmds.about(batch=True): + _LOGGER.info('Add UI dependent tools') + # wrap in a try, because we haven't implmented it yet + try: + mel.eval(str(r'source "{}"'.format(TAG_O3DE_DCC_MAYA_MEL))) + except Exception as e: + _LOGGER.error(e) + + # manage custom menu in a sub-module + from set_menu import set_main_menu + set_main_menu() + + # To Do: manage custom shelf in a sub-module + + _LOGGER.info('post_startup(), COMPLETE') + _LOGGER.info('DCCsi Bootstrap, COMPLETE') + return 0 +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +if __name__ == '__main__': + try: + # Early startup config. + startup() + + # This allows defered action post boot (atfer UI is active) + from maya.utils import executeDeferred + post = executeDeferred(post_startup) + + except Exception as e: + traceback.print_exc() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Shaders/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Shaders/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Tools/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Tools/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Tools/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/config.py new file mode 100644 index 0000000000..50d6de8de4 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/config.py @@ -0,0 +1,23 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +# DCCsi\\Tools\\DCC\\Maya\\config.py + +"""DccScriptingInterface (DCCsi) +This is the dynamic config (dynaconf) for O3DE Maya DCCsi interface +""" + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """Run this file as main""" + + print('Maya.config() not implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/constants.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/constants.py new file mode 100644 index 0000000000..6695b6185c --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/constants.py @@ -0,0 +1,16 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +# DCCsi\\Tools\\DCC\\Maya\\constsants.py + +"""DccScriptingInterface (DCCsi) +This module contains constants for the O3DE Maya DCCsi interface +""" + diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/readme.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/readme.txt new file mode 100644 index 0000000000..57c8317737 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/readme.txt @@ -0,0 +1,78 @@ +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +------------------------------------------------------------------------------- + +"DccScriptingInterface" aka DCCsi is a Gem for O3DE to extend and interface with dcc tools +in the python ecosystem. Each dcc tool may have it's own specific version of python. +Most are some version of py3+. O3DE provides an install of py3+ and manages package +dependancies with requirements.txt files and the cmake build system. + +However Autodesk Maya still uses a version of py2.7 and so we need an alternate way +to deal with package management for this DCC tool. + +Maya ships with it's own python interpreter called mayapy.exe + +Generally it is located here: +C:\Program Files\Autodesk\Maya2020\bin\mayapy.exe + +The python install and site-packages are here: +C:\Program Files\Autodesk\Maya2020\Python\Lib\site-packages + +A general goal of the DCCsi is be self-maintained, and to not taint the users installed applications of environment. + +So we boostrap additional access to site-packages in our userSetup.py: +"C:\Depot\Lumberyard\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Maya\Scripts\userSetup.py" + +We don't want users to have to install or use Python2.7 although with maya and possibly other dcc tools we don't have that control. Maya 2020 and earlier versions are still on Python2.7, so instead of forcing another install of python we can just use mayapy to manage extensions. + +Pip may already be installed, you can check like so (your maya install path may be different): + +C:\Program Files\Autodesk\Maya2020\bin>mayapy -m pip --version + +If pip is not available yet for your mayapy. + +First find out where th site-packages is located + +C:\Program Files\Autodesk\Maya2020\bin>mayapy -m site +sys.path = [ + 'C:\\Program Files\\Autodesk\\Maya2020\\bin', + 'C:\\Program Files\\Autodesk\\Maya2020\\bin\\python27.zip', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python\\DLLs', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib\\plat-win', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib\\lib-tk', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python', + 'C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib\\site-packages', +] +USER_BASE: 'C:\\Users\\gallowj\\AppData\\Roaming\\Python' (exists) +USER_SITE: 'C:\\Users\\gallowj\\AppData\\Roaming\\Python\\Python27\\site-packages' (doesn't exist) +ENABLE_USER_SITE: True + +This is the location we are looking for: +C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib\\site-packages + +download get-pip.py and put into the above ^ directory: +https://bootstrap.pypa.io/pip/2.7/get-pip.py + +Put that in the root of site-packages: +C:\\Program Files\\Autodesk\\Maya2020\\Python\\lib\\site-packages\\get-pip.py + +With get-pip module ready, we run it to install pip: +C:\Program Files\Autodesk\Maya2020\bin>mayapy -m get-pip + +Now you should be able to run the following command and verify pip: +C:\Program Files\Autodesk\Maya2020\bin>mayapy -m pip --version +pip 20.3.4 from C:\Users\< you >\AppData\Roaming\Python\Python27\site-packages\pip (python 2.7) + +Now your local maya install is all set up with pip so you can install additional python packages to use in maya. (note: not all packages are compatible with maya) + +Now you will want to run the following file to finish setup... +We have a requirements.txt file with the extension packages we use in the DCCsi. +You'll need the repo/branch path of your O3DE (aka Lumberyard) install. +And you'll need to know where the DCCsi is located, we will install package dependancies there. + +Note: you may need to update the paths below to match your local o3de engine install! + +C:\Program Files\Autodesk\Maya2020\bin>mayapy -m pip install -r C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Maya\requirements.txt -t C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/requirements.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/requirements.txt new file mode 100644 index 0000000000..ceb5be4dea --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/requirements.txt @@ -0,0 +1,84 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --generate-hashes requirements.txt +# +certifi==2020.6.20 \ + --hash=sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3 \ + --hash=sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41 + # via -r requirements.txt +cachetools==3.1.1 \ + --hash=sha256:428266a1c0d36dc5aca63a2d7c5942e88c2c898d72139fca0e97fdd2380517ae \ + --hash=sha256:8ea2d3ce97850f31e4a08b0e2b5e6c34997d7216a9d2c98e0f3978630d4da69a + # via -r requirements.txt +click==7.1.2 \ + --hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a \ + --hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc + # via + # -r requirements.txt + # pip-tools +dynaconf==3.1.4 \ + --hash=sha256:b2f472d83052f809c5925565b8a2ba76a103d5dc1dbb9748b693ed67212781b9 \ + --hash=sha256:e6f383b84150b70fc439c8b2757581a38a58d07962aa14517292dcce1a77e160 + # via -r requirements.txt +hashids==1.3.1 \ + --hash=sha256:6c3dc775e65efc2ce2c157a65acb776d634cb814598f406469abef00ae3f635c \ + --hash=sha256:8bddd1acba501bfc9306e7e5a99a1667f4f2cacdc20cbd70bcc5ddfa5147c94c + # via -r requirements.txt +pathlib2==2.3.5 \ + --hash=sha256:0ec8205a157c80d7acc301c0b18fbd5d44fe655968f5d947b6ecef5290fc35db \ + --hash=sha256:6cd9a47b597b37cc57de1c05e56fb1a1c9cc9fab04fe78c29acd090418529868 + # via -r requirements.txt +pathlib==1.0.1 \ + --hash=sha256:6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f + # via -r requirements.txt +python-box==3.4.6 \ + --hash=sha256:694a7555e3ff9fbbce734bbaef3aad92b8e4ed0659d3ed04d56b6a0a0eff26a9 \ + --hash=sha256:a71d3dc9dbaa34c8597d3517c89a8041bd62fa875f23c0f3dad55e1958e3ce10 + # via -r requirements.txt +scandir==1.10.0 \ + --hash=sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e \ + --hash=sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022 \ + --hash=sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f \ + --hash=sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f \ + --hash=sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae \ + --hash=sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173 \ + --hash=sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4 \ + --hash=sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32 \ + --hash=sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188 \ + --hash=sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d \ + --hash=sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac + # via + # -r requirements.txt + # pathlib2 +six==1.15.0 \ + --hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259 \ + --hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced + # via + # -r requirements.txt + # pathlib2 +typing==3.7.4.3 \ + --hash=sha256:1187fb9c82fd670d10aa07bbb6cfcfe4bdda42d6fab8d5134f04e8c4d0b71cc9 \ + --hash=sha256:283d868f5071ab9ad873e5e52268d611e851c870a2ba354193026f2dfb29d8b5 + # via + # -r requirements.txt + # dynaconf +unipath==1.1 \ + --hash=sha256:09839adcc72e8a24d4f76d63656f30b5a1f721fc40c9bcd79d8c67bdd8b47dae \ + --hash=sha256:e6257e508d8abbfb6ddd8ec357e33589f1f48b1599127f23b017124d90b0fff7 + # via -r requirements.txt +qdarkstyle==3.0.2 \ + --hash=sha256:55d149cf5f40ee297397f1818e091118cefb855a4a9c5c38566c47acd2d8c7ae \ + --hash=sha256:7c791535cc20b3cc1e8e1bf6b88dabe53cb0615983df702be83597e73ada2558 + # via -r c:\temp\requirements.txt +qtpy==1.9.0 \ + --hash=sha256:2db72c44b55d0fe1407be8fba35c838ad0d6d3bb81f23007886dc1fc0f459c8d \ + --hash=sha256:fa0b8363b363e89b2a6f49eddc162a04c0699ae95e109a6be3bb145a913190ea + # via + # -r c:\temp\requirements.txt + # qdarkstyle +wincertstore==0.2 \ + --hash=sha256:22d5eebb52df88a8d4014d5cf6d1b6c3a5d469e6c3b2e2854f3a003e48872356 \ + --hash=sha256:780bd1557c9185c15d9f4221ea7f905cb20b93f7151ca8ccaed9714dce4b327a + # via -r requirements.txt diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/settings.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/settings.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/start.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/start.py new file mode 100644 index 0000000000..4d965aec28 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/start.py @@ -0,0 +1,24 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +# DCCsi\\Tools\\DCC\\Maya\\start.py + +"""DccScriptingInterface (DCCsi) +The DCCsi bootstraps tools like Maya with additional code access and extensions. +This module starts up maya in the DCCsi managed synthetic environment context. +""" + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """Run this file as main""" + + print('Maya.Start() not implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/custom_shaders/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/custom_shaders/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/ly_presets/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/ly_presets/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/templates/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/resources/templates/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/scripts/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/scripts/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/scripts/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/stub new file mode 100644 index 0000000000..d365a5f2c9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Substance/stub @@ -0,0 +1,9 @@ +# coding:utf-8 +#!/usr/bin/python +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/.gitignore similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/.gitignore rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/.gitignore diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Core.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat similarity index 67% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Core.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat index 5146d5f3e8..b37170d605 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Core.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat @@ -31,11 +31,11 @@ echo ~ O3DE DCC Scripting Interface Environment ... echo _____________________________________________________________________ echo. -IF "%DCCSI_LAUNCHERS_PATH%"=="" (set DCCSI_LAUNCHERS_PATH=%~dp0) -echo DCCSI_LAUNCHERS_PATH = %DCCSI_LAUNCHERS_PATH% +IF "%DCCSI_DEV_ENV%"=="" (set DCCSI_DEV_ENV=%~dp0) +echo DCCSI_DEV_ENV = %DCCSI_DEV_ENV% :: add to the PATH -SET PATH=%DCCSI_LAUNCHERS_PATH%;%PATH% +SET PATH=%DCCSI_DEV_ENV%;%PATH% :: Constant Vars (Global) :: global debug flag (propogates) @@ -61,24 +61,21 @@ IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% :: This maps up to the \Dev folder -IF "%DEV_REL_PATH%"=="" (set DEV_REL_PATH=..\..\..\..) -echo DEV_REL_PATH = %DEV_REL_PATH% +IF "%O3DE_REL_PATH%"=="" (set O3DE_REL_PATH=..\..\..\..) +echo O3DE_REL_PATH = %O3DE_REL_PATH% :: You can define the project name -IF "%LY_PROJECT_NAME%"=="" ( - for %%a in (%CD%..\..\..) do set LY_PROJECT_NAME=%%~na +IF "%O3DE_PROJECT%"=="" ( + for %%a in (%CD%..\..\..\..) do set O3DE_PROJECT=%%~na ) -echo LY_PROJECT_NAME = %LY_PROJECT_NAME% - -:: if not defined we just use the DCCsi path as stand-in -IF "%LY_PROJECT%"=="" (set LY_PROJECT=%CD%) -echo LY_PROJECT = %LY_PROJECT% +echo O3DE_PROJECT = %O3DE_PROJECT% :: set up the default project path (dccsi) :: if not set we also use the DCCsi path as stand-in -CD /D ..\..\ -IF "%LY_PROJECT_PATH%"=="" (set LY_PROJECT_PATH=%CD%) -echo LY_PROJECT_PATH = %LY_PROJECT_PATH% +CD /D ..\..\..\ +:: To Do: remove one of these +IF "%O3DE_PROJECT_PATH%"=="" (set O3DE_PROJECT_PATH=%CD%) +echo O3DE_PROJECT_PATH = %O3DE_PROJECT_PATH% IF "%ABS_PATH%"=="" (set ABS_PATH=%CD%) echo ABS_PATH = %ABS_PATH% @@ -87,37 +84,40 @@ echo ABS_PATH = %ABS_PATH% pushd %ABS_PATH% :: Change to root Lumberyard dev dir -CD /d %LY_PROJECT_PATH%\%DEV_REL_PATH% -IF "%LY_DEV%"=="" (set LY_DEV=%CD%) -echo LY_DEV = %LY_DEV% +CD /d %O3DE_PROJECT_PATH%\%O3DE_REL_PATH% +IF "%O3DE_DEV%"=="" (set O3DE_DEV=%CD%) +echo O3DE_DEV = %O3DE_DEV% :: Restore original directory popd :: dcc scripting interface gem path :: currently know relative path to this gem -set DCCSIG_PATH=%LY_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +set DCCSIG_PATH=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface echo DCCSIG_PATH = %DCCSIG_PATH% :: Change to DCCsi root dir CD /D %DCCSIG_PATH% :: per-dcc sdk path -set DCCSI_SDK_PATH=%DCCSIG_PATH%\SDK -echo DCCSI_SDK_PATH = %DCCSI_SDK_PATH% +set DCCSI_TOOLS_PATH=%DCCSIG_PATH%\Tools +echo DCCSI_TOOLS_PATH = %DCCSI_TOOLS_PATH% :: temp log location specific to this gem -set DCCSI_LOG_PATH=%DCCSIG_PATH%\.temp\logs +set DCCSI_LOG_PATH=%O3DE_PROJECT_PATH%\.temp\logs echo DCCSI_LOG_PATH = %DCCSI_LOG_PATH% :: O3DE build path -IF "%TAG_LY_BUILD_PATH%"=="" (set TAG_LY_BUILD_PATH=build) -echo TAG_LY_BUILD_PATH = %TAG_LY_BUILD_PATH% +IF "%O3DE_BUILD_FOLDER%"=="" (set O3DE_BUILD_FOLDER=build) +echo O3DE_BUILD_FOLDER = %O3DE_BUILD_FOLDER% + +IF "%O3DE_BUILD_PATH%"=="" (set O3DE_BUILD_PATH=%O3DE_DEV%\%O3DE_BUILD_FOLDER%) +echo O3DE_BUILD_PATH = %O3DE_BUILD_PATH% -IF "%LY_BUILD_PATH%"=="" (set LY_BUILD_PATH=%LY_DEV%\%TAG_LY_BUILD_PATH%\bin\profile) -echo LY_BUILD_PATH = %LY_BUILD_PATH% +IF "%O3DE_BIN_PATH%"=="" (set O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile) +echo O3DE_BIN_PATH = %O3DE_BIN_PATH% :: add to the PATH -SET PATH=%LY_BUILD_PATH%;%DCCSIG_PATH%;%DCCSI_AZPY_PATH%;%PATH% +SET PATH=%O3DE_BIN_PATH%;%DCCSIG_PATH%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Maya.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat similarity index 87% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Maya.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat index cceaa80b75..5e3c600124 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Maya.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat @@ -27,14 +27,12 @@ IF "%DCCSI_PY_VERSION_MINOR%"=="" (set DCCSI_PY_VERSION_MINOR=7) IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=11) :: Default Maya Version -IF "%DCCSI_MAYA_VERSION%"=="" (set DCCSI_MAYA_VERSION=%MAYA_VERSION%) +IF "%DCCSI_MAYA_VERSION%"=="" (set DCCSI_MAYA_VERSION=2020) :: Initialize env CALL %~dp0\Env_Core.bat CALL %~dp0\Env_Python.bat -::SETLOCAL ENABLEDELAYEDEXPANSION - echo. echo _____________________________________________________________________ echo. @@ -48,14 +46,14 @@ echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% echo DCCSI_MAYA_VERSION = %DCCSI_MAYA_VERSION% :::: Set Maya native project acess to this project -IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%LY_PROJECT%) +IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%O3DE_PROJECT%) echo MAYA_PROJECT = %MAYA_PROJECT% :: maya sdk path -set DCCSI_SDK_MAYA_PATH=%DCCSI_SDK_PATH%\Maya -echo DCCSI_SDK_MAYA_PATH = %DCCSI_SDK_MAYA_PATH% +set DCCSI_TOOLS_MAYA_PATH=%DCCSI_TOOLS_PATH%\DCC\Maya +echo DCCSI_TOOLS_MAYA_PATH = %DCCSI_TOOLS_MAYA_PATH% -set MAYA_MODULE_PATH=%DCCSI_SDK_MAYA_PATH%;%MAYA_MODULE_PATH% +set MAYA_MODULE_PATH=%DCCSI_TOOLS_MAYA_PATH%;%MAYA_MODULE_PATH% echo MAYA_MODULE_PATH = %MAYA_MODULE_PATH% :: Maya File Paths, etc @@ -93,36 +91,36 @@ echo DCCSI_PY_MAYA = %DCCSI_PY_MAYA% SET PATH=%MAYA_BIN_PATH%;%PATH% :: Local DCCsi Maya plugins access (ours) -set DCCSI_MAYA_PLUG_IN_PATH=%DCCSI_SDK_MAYA_PATH%\plugins +set DCCSI_MAYA_PLUG_IN_PATH=%DCCSI_TOOLS_MAYA_PATH%\plugins :: also attached to maya's built-it env var set MAYA_PLUG_IN_PATH=%DCCSI_MAYA_PLUG_IN_PATH%;MAYA_PLUG_IN_PATH echo DCCSI_MAYA_PLUG_IN_PATH = %DCCSI_MAYA_PLUG_IN_PATH% :: Local DCCsi Maya shelves (ours) -set DCCSI_MAYA_SHELF_PATH=%DCCSI_SDK_MAYA_PATH%\Prefs\Shelves +set DCCSI_MAYA_SHELF_PATH=%DCCSI_TOOLS_MAYA_PATH%\Prefs\Shelves set MAYA_SHELF_PATH=%DCCSI_MAYA_SHELF_PATH% echo DCCSI_MAYA_SHELF_PATH = %DCCSI_MAYA_SHELF_PATH% :: Local DCCsi Maya icons path (ours) -set DCCSI_MAYA_XBMLANGPATH=%DCCSI_SDK_MAYA_PATH%\Prefs\icons +set DCCSI_MAYA_XBMLANGPATH=%DCCSI_TOOLS_MAYA_PATH%\Prefs\icons :: also attached to maya's built-it env var set XBMLANGPATH=%DCCSI_MAYA_XBMLANGPATH%;%XBMLANGPATH% echo DCCSI_MAYA_XBMLANGPATH = %DCCSI_MAYA_XBMLANGPATH% :: Local DCCsi Maya Mel scripts (ours) -set DCCSI_MAYA_SCRIPT_MEL_PATH=%DCCSI_SDK_MAYA_PATH%\Scripts\Mel +set DCCSI_MAYA_SCRIPT_MEL_PATH=%DCCSI_TOOLS_MAYA_PATH%\Scripts\Mel :: also attached to maya's built-it env var set MAYA_SCRIPT_PATH=%DCCSI_MAYA_SCRIPT_MEL_PATH%;%MAYA_SCRIPT_PATH% echo DCCSI_MAYA_SCRIPT_MEL_PATH = %DCCSI_MAYA_SCRIPT_MEL_PATH% :: Local DCCsi Maya Python scripts (ours) -set DCCSI_MAYA_SCRIPT_PY_PATH=%DCCSI_SDK_MAYA_PATH%\Scripts\Python +set DCCSI_MAYA_SCRIPT_PY_PATH=%DCCSI_TOOLS_MAYA_PATH%\Scripts\Python :: also attached to maya's built-it env var set MAYA_SCRIPT_PATH=%DCCSI_MAYA_SCRIPT_PY_PATH%;%MAYA_SCRIPT_PATH% echo DCCSI_MAYA_SCRIPT_PY_PATH = %DCCSI_MAYA_SCRIPT_PY_PATH% :: DCCsi Maya boostrap, userSetup.py access (ours) -set DCCSI_MAYA_SCRIPT_PATH=%DCCSI_SDK_MAYA_PATH%\Scripts +set DCCSI_MAYA_SCRIPT_PATH=%DCCSI_TOOLS_MAYA_PATH%\Scripts :: also attached to maya's built-it env var set MAYA_SCRIPT_PATH=%DCCSI_MAYA_SCRIPT_PATH%;%MAYA_SCRIPT_PATH% echo DCCSI_MAYA_SCRIPT_PATH = %DCCSI_MAYA_SCRIPT_PATH% diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_PyCharm.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat similarity index 95% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_PyCharm.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat index 67f2c3d81e..7be9154e6d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_PyCharm.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat @@ -34,7 +34,7 @@ CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Python.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat similarity index 76% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Python.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat index 196d7b09bb..388ab531df 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Python.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat @@ -19,8 +19,6 @@ PUSHD %~dp0 CALL %~dp0\Env_Core.bat -::SETLOCAL ENABLEDELAYEDEXPANSION - echo. echo _____________________________________________________________________ echo. @@ -56,32 +54,29 @@ echo DCCSI_PYTHON_LIB_PATH = %DCCSI_PYTHON_LIB_PATH% SET PATH=%DCCSI_PYTHON_LIB_PATH%;%PATH% :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python -echo DCCSI_PYTHON_INSTALL = %DCCSI_PYTHON_INSTALL% +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\python +echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% :: location for O3DE python 3.7 location -set DCCSI_PY_BASE=%DCCSI_PYTHON_INSTALL%\python.cmd +:: Note, many DCC tools (like Maya) include thier own python interpretter +:: Some DCC apps may not operate correctly if PYTHONHOME is set (this is definitely the case with Maya) +:: Be aware the python.cmd below does set PYTHONHOME +set DCCSI_PY_BASE=%O3DE_PYTHON_INSTALL%\python.cmd echo DCCSI_PY_BASE = %DCCSI_PY_BASE% -:: ide and debugger plug -set DCCSI_PY_DEFAULT=%DCCSI_PY_BASE% +CALL %O3DE_PYTHON_INSTALL%\get_python_path.bat -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE=%DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +:: Some IDEs like Wing, may in some cases need acess directly to the exe to operate correctly +IF "%DCCSI_PY_IDE%"=="" (set DCCSI_PY_IDE=%O3DE_PYTHONHOME%\python.exe) echo DCCSI_PY_IDE = %DCCSI_PY_IDE% -set DCCSI_PY_IDE_PACKAGES=%DCCSI_PY_IDE%\Lib\site-packages -echo DCCSI_PY_IDE_PACKAGES = %DCCSI_PY_IDE_PACKAGES% - :: add to the PATH -SET PATH=%DCCSI_PYTHON_INSTALL%;%DCCSI_PY_IDE%;%DCCSI_PY_IDE_PACKAGES%;%PATH% +SET PATH=%O3DE_PYTHON_INSTALL%;%O3DE_PYTHONHOME%;%DCCSI_PY_IDE%;%PATH% :: add all python related paths to PYTHONPATH for package imports -set PYTHONPATH=%DCCSIG_PATH%;%DCCSI_PYTHON_LIB_PATH%;%LY_BUILD_PATH%;%PYTHONPATH% +set PYTHONPATH=%DCCSIG_PATH%;%DCCSI_PYTHON_LIB_PATH%;%O3DE_BUILD_PATH%;%PYTHONPATH% echo PYTHONPATH = %PYTHONPATH% -::ENDLOCAL - :: Set flag so we don't initialize dccsi environment twice SET DCCSI_ENV_PY_INIT=1 GOTO END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Qt.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat similarity index 85% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Qt.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat index 2ad49b4416..6202ead2f2 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Qt.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat @@ -34,23 +34,23 @@ echo. :: set up Qt/Pyside paths :: set up PySide2/Shiboken -set QTFORPYTHON_PATH=%LY_DEV%\Gems\QtForPython\3rdParty\pyside2\windows\release +set QTFORPYTHON_PATH=%O3DE_DEV%\Gems\QtForPython\3rdParty\pyside2\windows\release echo QTFORPYTHON_PATH = %QTFORPYTHON_PATH% :: add to the PATH SET PATH=%QTFORPYTHON_PATH%;%PATH% SET PYTHONPATH=%QTFORPYTHON_PATH%;%PYTHONPATH% -set QT_PLUGIN_PATH=%LY_BUILD_PATH%\bin\profile\EditorPlugins +set QT_PLUGIN_PATH=%O3DE_BUILD_PATH%\bin\profile\EditorPlugins echo QT_PLUGIN_PATH = %QT_PLUGIN_PATH% :: add to the PATH SET PATH=%QT_PLUGIN_PATH%;%PATH% SET PYTHONPATH=%QT_PLUGIN_PATH%;%PYTHONPATH% -set LY_BIN_PATH=%LY_BUILD_PATH%\bin\profile -echo LY_BIN_PATH = %LY_BIN_PATH% -SET PATH=%LY_BIN_PATH%;%PATH% +set O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile +echo O3DE_BIN_PATH = %O3DE_BIN_PATH% +SET PATH=%O3DE_BIN_PATH%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Substance.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat similarity index 92% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Substance.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat index 3c92b306ca..d44ed985da 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_Substance.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat @@ -31,7 +31,7 @@ echo. : Substance Designer :: maya sdk path -set DCCSI_SUBSTANCE_PATH=%DCCSI_SDK_PATH%\Substance +set DCCSI_SUBSTANCE_PATH=%DCCSI_TOOLS_PATH%\Substance echo DCCSI_SUBSTANCE_PATH = %DCCSI_SUBSTANCE_PATH% :: https://docs.substance3d.com/sddoc/project-preferences-107118596.html#ProjectPreferences-ConfigurationFile :: Path to .exe, "C:\Program Files\Allegorithmic\Substance Designer\Substance Designer.exe" @@ -39,7 +39,7 @@ set SUBSTANCE_PATH="%ProgramFiles%\Allegorithmic\Substance Designer" echo SUBSTANCE_PATH = %SUBSTANCE_PATH% :: default config -set SUBSTANCE_CFG_PATH=%LY_PROJECT_PATH%\DCCsi_default.sbscfg +set SUBSTANCE_CFG_PATH=%O3DE_PROJECT_PATH%\DCCsi_default.sbscfg echo SUBSTANCE_CFG_PATH = %SUBSTANCE_CFG_PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_VScode.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_WingIDE.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat similarity index 78% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_WingIDE.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat index 56209ca5aa..a8c3b3d073 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Env_WingIDE.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat @@ -27,18 +27,9 @@ CALL %~dp0\Env_Core.bat CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python -echo DCCSI_PY_IDE = %DCCSI_PY_IDE% - -:: ide and debugger plug -set DCCSI_PY_DEFAULT=%DCCSI_PY_IDE%\python.exe - :: put project env variables/paths here set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% -SET WING_PROJ=%DCCSIG_PATH%\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr - -::SETLOCAL ENABLEDELAYEDEXPANSION +SET WING_PROJ=%DCCSIG_PATH%\Tools\Dev\Windows\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr echo. echo _____________________________________________________________________ @@ -55,8 +46,6 @@ echo WING_PROJ = %WING_PROJ% :: add to the PATH SET PATH=%WINGHOME%;%PATH% -::ENDLOCAL - :: Set flag so we don't initialize dccsi environment twice SET DCCSI_ENV_WINGIDE_INIT=1 GOTO END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Env_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat similarity index 97% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Env_Cmd.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat index a8476ccc22..5b76de1401 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Env_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat @@ -40,7 +40,7 @@ CALL %~dp0\Env_WingIDE.bat IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_MayaPy_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat similarity index 91% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_MayaPy_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat index d98b8d81e7..e451050ab8 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_MayaPy_PyCharmPro.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat @@ -56,14 +56,14 @@ echo ~ MayaPy.exe (default python interpreter) echo _____________________________________________________________________ echo. -echo LY_DEV = %LY_DEV% +echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python -echo DCCSI_PYTHON_INSTALL = %DCCSI_PYTHON_INSTALL% +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug @@ -80,7 +80,7 @@ IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat echo. :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% IF EXIST "%PYCHARM_HOME%\bin\pycharm64.exe" ( start "" "%PYCHARM_HOME%\bin\pycharm64.exe" "%PYCHARM_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Maya_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Maya_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat index 2c4e1cc941..ee2ea5bf1f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Maya_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat @@ -50,7 +50,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% :: Default to the right version of Maya if we can detect it... and launch IF EXIST "%MAYA_BIN_PATH%\maya.exe" ( diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat similarity index 97% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_PyMin_Cmd.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat index d001d8a75e..193cb40de8 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_PyMin_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat @@ -38,7 +38,7 @@ echo _____________________________________________________________________ echo. :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Qt_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat similarity index 93% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Qt_PyMin_Cmd.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat index d50989004b..75d1ff8cc4 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_Qt_PyMin_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat @@ -10,7 +10,7 @@ REM :: Set up and run LY Python CMD prompt :: Sets up the DccScriptingInterface_Env, -:: Puts you in the CMD within the LY_DEV environment +:: Puts you in the CMD within the O3DE_DEV environment :: Set up window TITLE O3DE DCC Scripting Interface Py Qt Cmd @@ -39,7 +39,7 @@ echo _____________________________________________________________________ echo. :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat similarity index 92% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_VScode.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat index 120584ed6a..2dc5b06032 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_VScode.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat @@ -61,14 +61,14 @@ echo ~ Launching DCCsi Project in VScode echo _____________________________________________________________________ echo. -echo LY_DEV = %LY_DEV% +echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python -echo DCCSI_PYTHON_INSTALL = %DCCSI_PYTHON_INSTALL% +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat similarity index 74% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat index c933670bab..56e278da08 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat @@ -20,6 +20,9 @@ COLOR 8E cd %~dp0 PUSHD %~dp0 +:: if the user has set up a custom env call it +IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat + :: Constant Vars (Global) :: global debug (propogates) IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) @@ -51,35 +54,20 @@ echo. echo _____________________________________________________________________ echo. echo ~ WingIDE Version %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% -echo ~ Launching O3DE %LY_PROJECT% project in WingIDE %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% ... +echo ~ Launching O3DE %O3DE_PROJECT% project in WingIDE %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% ... echo _____________________________________________________________________ echo. -echo LY_DEV = %LY_DEV% +echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python -echo DCCSI_PYTHON_INSTALL = %DCCSI_PYTHON_INSTALL% - -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python -echo DCCSI_PY_IDE = %DCCSI_PY_IDE% - -:: ide and debugger plug -set DCCSI_PY_BASE=%DCCSI_PY_IDE%\python.exe -echo DCCSI_PY_BASE = %DCCSI_PY_BASE% - -:: ide and debugger plug -set DCCSI_PY_DEFAULT=%DCCSI_PY_BASE% -echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT% - -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% echo. :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayaPy_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayaPy_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat index f07ec093cb..33b8bc6392 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayaPy_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat @@ -48,7 +48,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% SETLOCAL ENABLEDELAYEDEXPANSION diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayapy_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat similarity index 87% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayapy_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat index 631250d06b..ca5b175c39 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_mayapy_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat @@ -50,19 +50,19 @@ echo. echo _____________________________________________________________________ echo. echo ~ WingIDE Version %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% -echo ~ Launching O3DE %LY_PROJECT% project in WingIDE %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% ... +echo ~ Launching O3DE %O3DE_PROJECT% project in WingIDE %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% ... echo ~ MayaPy.exe (default python interpreter) echo _____________________________________________________________________ echo. -echo LY_DEV = %LY_DEV% +echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python -echo DCCSI_PYTHON_INSTALL = %DCCSI_PYTHON_INSTALL% +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug @@ -79,7 +79,7 @@ IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat echo. :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_pyBASE.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE.bat similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_pyBASE.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE.bat diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_pyBASE_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat similarity index 97% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_pyBASE_Cmd.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat index 9f8950f59f..e1b075e065 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Launch_pyBASE_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat @@ -33,7 +33,7 @@ CALL %~dp0\Env_Maya.bat IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat :: Change to root dir -CD /D %LY_PROJECT_PATH% +CD /D %O3DE_PROJECT_PATH% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/README.txt new file mode 100644 index 0000000000..e5b7946276 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/README.txt @@ -0,0 +1,78 @@ +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +DccScriptingInterface (DCCsi) is a framework for O3DE extensions, for example: +- Lightweight python integrations with DCC tools like Maya +- O3DE configuration, customization and extensions of tools +- Standalone PySide2/Qt tools +- ^ These might utilize a mix of O3DE and DDC python APIs + +The DccScriptingInterface\config.py, procedurally provides a synthetic env context. +This env is a data-driven approach to configuring layered and managed env settings. + +This env provides the hooks for DDC apps and/or standalone tools, +to configure acess to O3DE code (for boostrapping), safely retreive known paths, set/get developer flags, etc. + +DccScriptingInterface\Tools\Dev\Windows\ + +This is a .bat file based version of the default env context for development on windows. +This is what we use to boot the default env context such that it is available, when launching a development tool such as a IDE. + +This allows a developer to troubleshoot/debug code, like config.py + +Other tools, can use config.py to stand up the env context. + +What is in this folder ... + +Core env modules +--------------------- +Env_Core.bat : core access to O3DE and DCCsi +Env_Python.bat : access to O3DE python and general py configuration +Env_Qt.bat : access to O3DE Qt .dll files and PySide2 + +DCC add on envars +--------------------- +Env_Maya.bat : configures Maya with code O3DE/DCCsi access +Env_Substance.bat : Configures Substance Designer + +IDE env +--------------------- +Env_WingIDE.bat : configures WingIDE for DCCsi development +Env_VScode.bat : configures VScode for DCCsi development +Env_PyCharm.bat : configures PyCharm for DCCsi development + +Launchers +--------------------- +Launch_env_Cmd.bat : Starts a cmd with entire managed env context + : ^ allows use to validate env + : ^ display all default ENVAR plugs + : ^ allows user to test O3DE python + scripts from cmd +Launch_PyMin_Cmd.bat : Starts minimal cmd with O3DE python access only + : ^ for instance, test Dccsi\config.py like this: + : {DCCsi prommpt}>python config.py +Launch_Maya_2020.bat : Starts Maya2020 within managed env context +Launch_WindIDE-7-1.bat : Starts WingIDE within managed env context + +--------------------- +Instructions: How to test the synthetic environment and settings externally + +1. Run the cmd: Launch_PyMin_Cmd.bat + + C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface> + +2. Run command:>python config.py -dm=True -py=True -qt=True + +What this does? +- runs the O3DE python exe +- starts the config.py which begins to procedurally create synthetic/dynamic environment (hooks) +- ^ this starts with DCCsi hooks +- enters 'dev mode'(-dm) and attempts to attach debugger (Wing IDE only for now, others planned) +- enables additional O3DE python hooks and code access +- ^ great for standalone tools, but you don't want that functionality to interfer with other DCC tools python environments (like Maya!) +- enables access to O3DE Qt .dlls and PySide2 python package support(-qt) +- ^ great for standalone PySide2 which can operate outside of the O3DE editor \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Setuo_copy_oiio.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat similarity index 76% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Setuo_copy_oiio.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat index 590e634d54..18a58e1371 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Launchers/Windows/Setuo_copy_oiio.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat @@ -13,12 +13,12 @@ cd %~dp0 PUSHD %~dp0 :: This maps up to the \Dev folder -set LY_DEV=..\..\..\..\..\.. +set O3DE_DEV=..\..\..\..\..\.. :: shared location for default O3DE python location -set DCCSI_PYTHON_INSTALL=%LY_DEV%\Python +set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -set PY_SITE=%DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python\Lib\site-packages +set PY_SITE=%O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python\Lib\site-packages set PACKAGE_LOC=C:\Depot\3rdParty\packages\openimageio-2.1.16.0-rev1-windows\OpenImageIO\2.1.16.0\win_x64\bin diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.dev/readme.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.dev/readme.txt similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.dev/readme.txt rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.dev/readme.txt diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.dev/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.dev/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.gitignore similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.gitignore rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.gitignore diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/.gitignore rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/.p4ignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.p4ignore similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/.p4ignore rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.p4ignore diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/DccScriptingInterface.iml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/DccScriptingInterface.iml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/encodings.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/encodings.xml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/encodings.xml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/encodings.xml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/main.py similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/main.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/main.py diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/misc.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/misc.xml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/modules.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/modules.xml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/modules.xml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/modules.xml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/vcs.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/vcs.xml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/webResources.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/webResources.xml similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.idea/webResources.xml rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/webResources.xml diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/dccsi.code-workspace b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/dccsi.code-workspace similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/dccsi.code-workspace rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/dccsi.code-workspace diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/launch.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/launch.json similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/launch.json rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/launch.json diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/settings.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/settings.json similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.vscode/settings.json rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.vscode/settings.json diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.wing/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.wing/.gitignore similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.wing/.gitignore rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.wing/.gitignore diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.wing/DCCsi_7x.wpr b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.wing/DCCsi_7x.wpr similarity index 57% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.wing/DCCsi_7x.wpr rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.wing/DCCsi_7x.wpr index aa7a8c4bd9..18af1298db 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/.wing/DCCsi_7x.wpr +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.wing/DCCsi_7x.wpr @@ -5,14 +5,14 @@ ################################################################## [project attributes] debug.launch-configs = (2, - {'launch-GeaM41WYMGA1sEfm': ({'shared': True}, + {'launch-0L6se5pxC9AWvpY0': ({'shared': True}, {'buildcmd': ('project', None), - 'env': ('custom', + 'env': ('project', [u'']), - 'name': u'DCCSI_PY_MAYA', + 'name': 'DCCSI_PY_IDE', 'pyexec': ('custom', - u'${DCCSI_PY_MAYA}'), + u'${DCCSI_PY_IDE}'), 'pypath': ('project', []), 'pyrunargs': ('project', @@ -20,14 +20,14 @@ debug.launch-configs = (2, 'runargs': u'', 'rundir': ('project', u'')}), - 'launch-WUN9lgYK6qYU7qE9': ({'shared': True}, + 'launch-GeaM41WYMGA1sEfm': ({'shared': True}, {'buildcmd': ('project', None), 'env': ('custom', [u'']), - 'name': u'DCCSI_PY_BASE', + 'name': u'DCCSI_PY_MAYA', 'pyexec': ('custom', - u'${DCCSI_PY_BASE}'), + u'${DCCSI_PY_MAYA}'), 'pypath': ('project', []), 'pyrunargs': ('project', @@ -35,14 +35,14 @@ debug.launch-configs = (2, 'runargs': u'', 'rundir': ('project', u'')}), - 'launch-oobMrvXFf1SwtYBg': ({'shared': True}, + 'launch-WUN9lgYK6qYU7qE9': ({'shared': True}, {'buildcmd': ('project', None), 'env': ('custom', [u'']), - 'name': u'DCCSI_PY_DEFAULT', + 'name': u'DCCSI_PY_BASE', 'pyexec': ('custom', - u'${DCCSI_PY_DEFAULT}'), + u'${DCCSI_PY_BASE}'), 'pypath': ('project', []), 'pyrunargs': ('project', @@ -50,35 +50,28 @@ debug.launch-configs = (2, 'runargs': u'', 'rundir': ('project', u'')})}) -proj.directory-list = [{'dirloc': loc('../..'), +proj.directory-list = [{'dirloc': loc('../../../../..'), 'excludes': (), 'filter': u'*', - 'include_hidden': True, + 'include_hidden': False, + 'recursive': True, + 'watch_for_changes': True}, + {'dirloc': loc('../../../../../../../../Atom/Feature/Common/Editor/Scripts/ColorGrading'), + 'excludes': (), + 'filter': u'*', + 'include_hidden': False, + 'recursive': True, + 'watch_for_changes': True}, + {'dirloc': loc('../../../../../../../../../python'), + 'excludes': (), + 'filter': u'*', + 'include_hidden': False, 'recursive': True, 'watch_for_changes': True}] proj.file-type = 'shared' -proj.home-dir = loc('../..') -proj.launch-config = {loc('../../SDK/Atom/Scripts/Python/DCC_Materials/maya_materials_export.py'): ('c'\ - 'ustom', - (u'', - 'launch-GeaM41WYMGA1sEfm')), - loc('../../SDK/Maya/Scripts/Python/legacy_asset_converter/main.py'): ('c'\ - 'ustom', - (u'', - 'launch-WUN9lgYK6qYU7qE9')), - loc('../../azpy/__init__.py'): ('custom', - (u'', - 'launch-oobMrvXFf1SwtYBg')), - loc('../../azpy/constants.py'): ('custom', - (u'', - 'launch-GeaM41WYMGA1sEfm')), - loc('../../azpy/env_base.py'): ('project', - (u'', - 'launch-GeaM41WYMGA1sEfm')), - loc('../../azpy/maya/callbacks/node_message_callback_handler.py'): ('c'\ - 'ustom', +proj.launch-config = {loc('../../../../../azpy/core/py2/utils.py'): ('custom', (u'', - 'launch-GeaM41WYMGA1sEfm')), - loc('../../config.py'): ('custom', + 'launch-0L6se5pxC9AWvpY0')), + loc('../../../../../azpy/core/py3/utils.py'): ('custom', (u'', - 'launch-GeaM41WYMGA1sEfm'))} + 'launch-0L6se5pxC9AWvpY0'))} diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/readme.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/readme.txt similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Solutions/readme.txt rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/readme.txt diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/README.txt new file mode 100644 index 0000000000..05aa948943 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/README.txt @@ -0,0 +1,9 @@ +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +This folder resprents a Mock Tool - currently just a scaffold (not implemented) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/Resources/resource.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/Resources/resource.txt new file mode 100644 index 0000000000..30df2e0eb9 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/Resources/resource.txt @@ -0,0 +1,9 @@ +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- + +This folder is for tool resources - this file is a resource stub. \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/config.py new file mode 100644 index 0000000000..1dc43d8485 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/config.py @@ -0,0 +1,12 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- + +print('Not Implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/main.py new file mode 100644 index 0000000000..1dc43d8485 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/main.py @@ -0,0 +1,12 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- + +print('Not Implemented') \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/settings.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/settings.json new file mode 100644 index 0000000000..d58fc7e10c --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/MockTool/settings.json @@ -0,0 +1,17 @@ +{ + "default": { + "DCCSI_GDEBUG": true, + "SPDX-LICENSE-IDENTIFIER": "Apache-2.0 OR MIT", + "COPYWRITE":"Copyright (c) Contributors to the Open 3D Engine Project.", + "COPYWRITE_MSG":"For complete copyright and license terms please see the LICENSE at the root of this distribution." + }, + "development": { + "DCCSI_GDEBUG": true, + "TEST_RULE": "/dccsi_with_json", + "MESSAGE": "The O3DE DCCsi manages dynamic configuration and settings with dynaconf", + "DYNACONF_HELP": "https://dynaconf.readthedocs.io/" + }, + "production": { + "DCCSI_GDEBUG": false + } +} \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/AA_Gun_01_ddna.tif b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/AA_Gun_01_ddna.tif new file mode 100644 index 0000000000..0cefbe9c25 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/AA_Gun_01_ddna.tif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c34bbeafae5c5b62d3571ac9eee295fff12ac0744f81375f53a3faf2c5095e4 +size 286400 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/test_oiio.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/test_oiio.py new file mode 100644 index 0000000000..b33fa8ef56 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/Tests/OpenImageIO/test_oiio.py @@ -0,0 +1,66 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- + +import OpenImageIO as oiio + +def convert(src): + try: + rgba = oiio.ImageBuf(src) + spec = get_image_spec(rgba) + + # Normal output ------> + rgb = oiio.ImageBufAlgo.channels(rgba, (0, 1, 2)) + normal_output = src.replace('ddna', 'Normal') + + # Roughness output ------> + alpha = oiio.ImageBufAlgo.channels(rgba, (3,)) + roughness = oiio.ImageBufAlgo.invert(alpha) + roughness_output = normal_output.replace('Normal', 'Roughness') + + write_image(rgba, normal_output, spec['format']) + write_image(roughness, roughness_output, spec['format']) + # logging.info('Output Normal Map: {}'.format(normal_output)) + # logging.info('Output Roughness Map: {}'.format(roughness_output)) + + except Exception as e: + logging.info('OIIO error in image conversion: {}'.format(e)) + return None + +def get_image_spec(target_image): + spec = target_image.spec() + info = {'resolution': (spec.width, spec.height, spec.x, spec.y), 'channels': spec.channelnames, + 'format': str(spec.format)} + if spec.channelformats : + info['channelformats'] = str(spec.channelformats) + info['alpha channel'] = str(spec.alpha_channel) + info['z channel'] = str(spec.z_channel) + info['deep'] = str(spec.deep) + for i in range(len(spec.extra_attribs)): + if type(spec.extra_attribs[i].value) == str: + info[spec.extra_attribs[i].name] = spec.extra_attribs[i].value + else: + info[spec.extra_attribs[i].name] = spec.extra_attribs[i].value + return info + +def write_image(image, filename, image_format): + if not image.has_error: + image.set_write_format(image_format) + image.write(filename) + if image.has_error: + print("Error writing", filename, ":", image.geterror()) + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + # run a test + convert('AA_Gun_01_ddna.tif') + # validate() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/stub b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Python/stub new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Resources/Atom/StandardPBR_AllProperties.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Resources/Atom/StandardPBR_AllProperties.material new file mode 100644 index 0000000000..7d38d1a1a3 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Resources/Atom/StandardPBR_AllProperties.material @@ -0,0 +1,47 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "general": { + "texcoord": 0 + }, + "baseColor": { + "colorLinear": [ 1.0, 1.0, 1.0 ], + "factor": 1.0, + "useTexture": true, + "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + }, + "metallic": { + "factor": 0.0, + "useTexture": false, + "textureMap": "" + }, + "roughness": { + "factor": 1.0, + "useTexture": true, + "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs_spec.tif" + }, + "specularF0": { + "factor": 0.5, + "useTexture": false, + "textureMap": "" + }, + "normal": { + "factor": 1.0, + "useTexture": true, + "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs_ddn.tif" + }, + "opacity": { + "doubleSided": false, + "factor": 1.0, + "cutoutAlpha": false, + "cutoutThreshold": 0.5, + "useBaseColorTextureAlpha": false, + "useTexture": false, + "textureMap": "" + } + } +} + diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/start_service.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/start_service.py new file mode 100644 index 0000000000..ac9d02cf5d --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/start_service.py @@ -0,0 +1,21 @@ +""" +Copyright (c) Contributors to the Open 3D Engine Project. +For complete copyright and license terms please see the LICENSE at the root of this distribution. + +SPDX-License-Identifier: Apache-2.0 OR MIT +""" +# ------------------------------------------------------------------------- +"""DCCsi Tool and Application service launcher""" + +def start_service(): + """Not Implemented""" + print('DCCsi.Tools.DCC.start_service() not implemented') + return None + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """Run this file as main""" + + start_service() \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py index 0577c50474..958508c227 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py @@ -26,26 +26,18 @@ import logging as _logging # ------------------------------------------------------------------------- -_ORG_TAG = 'Amazon_Lumberyard' -_APP_TAG = 'DCCsi' -_TOOL_TAG = 'azpy' -_TYPE_TAG = 'module' +# global scope +_PACKAGENAME = 'azpy' + +__all__ = ['config_utils', + 'constants', + 'env_bool', + 'return_stub', + 'core', + 'dcc', + 'dev', + 'test'] -_PACKAGENAME = _TOOL_TAG - -__all__ = ['config_utils', 'render', - 'constants', 'return_stub', 'synthetic_env', - 'env_base', 'env_bool', 'test', 'dev', - 'lumberyard', 'marmoset'] # 'blender', 'maya', 'substance', 'houdini'] -# ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -# _ROOT_LOGGER = _logging.getLogger() # only use this if debugging -# https://stackoverflow.com/questions/56733085/how-to-know-the-current-file-path-after-being-frozen-into-an-executable-using-cx/56748839 -#os.chdir(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) -# ------------------------------------------------------------------------- -# global space # we need to set up basic access to the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? _DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) @@ -58,8 +50,11 @@ import azpy.env_bool as env_bool import azpy.constants as constants import azpy.config_utils as config_utils -_G_DEBUG = env_bool.env_bool(constants.ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool.env_bool(constants.ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool.env_bool(constants.ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_LOGLEVEL = int(env_bool.env_bool(constants.ENVAR_DCCSI_LOGLEVEL, int(20))) +if _DCCSI_GDEBUG: + _DCCSI_LOGLEVEL = int(10) # for py2.7 (Maya) we provide this, so we must assume some bootstrapping # has occured, see DccScriptingInterface\\config.py (_DCCSI_PYTHON_LIB_PATH) @@ -69,38 +64,44 @@ try: except: import pathlib2 as pathlib from pathlib import Path -if _G_DEBUG: - print('DCCsi debug breadcrumb, pathlib is: {}'.format(pathlib)) +if _DCCSI_GDEBUG: + print('[DCCsi][AZPY] DEBUG BREADCRUMB, pathlib is: {}'.format(pathlib)) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# set up module logging +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) +_logging.basicConfig(format=constants.FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) +# ------------------------------------------------------------------------- -# to be continued... +# ------------------------------------------------------------------------- # get/set the project name -_LY_DEV = os.getenv(constants.ENVAR_LY_DEV, +_O3DE_DEV = Path(os.getenv(constants.ENVAR_O3DE_DEV, config_utils.get_stub_check_path(in_path=os.getcwd(), - check_stub='engine.json')) + check_stub='engine.json'))) +_LOGGER.debug('_O3DE_DEV" {}'.format(_O3DE_DEV.resolve())) + +_O3DE_PROJECT_PATH = Path(os.getenv(constants.ENVAR_O3DE_PROJECT_PATH, + config_utils.get_o3de_project_path())) +_LOGGER.debug('_O3DE_PROJECT_PATH" {}'.format(_O3DE_PROJECT_PATH.resolve())) # get/set the project name -_LY_PROJECT_NAME = os.getenv(constants.ENVAR_LY_PROJECT, - config_utils.get_current_project().name) +if _O3DE_PROJECT_PATH: + _O3DE_PROJECT = str(os.getenv(constants.ENVAR_O3DE_PROJECT, + _O3DE_PROJECT_PATH.name)) +else: + _O3DE_PROJECT='o3de' # project cache log dir path -_DCCSI_LOG_PATH = Path(os.getenv(constants.ENVAR_DCCSI_LOG_PATH, - Path(_LY_DEV, - _LY_PROJECT_NAME, - 'Cache', - 'pc', 'user', 'log', 'logs'))) - - -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) - -# very basic root logger for early debugging, flip to while 1: -while 0: - _logging.basicConfig(level=_logging.DEBUG, - format=constants.FRMT_LOG_LONG, - datefmt='%m-%d %H:%M') - - _logging.debug('azpy.rootlogger> root logger set up for debugging') # root logger +from azpy.constants import TAG_DCCSI_NICKNAME +from azpy.constants import PATH_DCCSI_LOG_PATH +_DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(O3DE_PROJECT_PATH=_O3DE_PROJECT_PATH.resolve(), + TAG_DCCSI_NICKNAME=TAG_DCCSI_NICKNAME)) # ------------------------------------------------------------------------- @@ -145,14 +146,15 @@ if sys.version_info.major < 3: # ------------------------------------------------------------------------- def initialize_logger(name, log_to_file=False, - default_log_level=_logging.NOTSET): + default_log_level=_logging.NOTSET, + propogate=False): """Start a azpy logger""" _logger = _logging.getLogger(name) - _logger.propagate = False + _logger.propagate = propogate if not _logger.handlers: _log_level = int(os.getenv('DCCSI_LOGLEVEL', default_log_level)) - if _G_DEBUG: + if _DCCSI_GDEBUG: _log_level = int(10) # force when debugging print('_log_level: {}'.format(_log_level)) @@ -201,27 +203,21 @@ def initialize_logger(name, return _logger # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -# set up logger with both console and file _logging -if _G_DEBUG: - _LOGGER = initialize_logger(_PACKAGENAME, log_to_file=True) -else: - _LOGGER = initialize_logger(_PACKAGENAME, log_to_file=False) - -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# ------------------------------------------------------------------------- # some simple logger tests # evoke the filehandlers and test writting to the log file -if _G_DEBUG: +if _DCCSI_GDEBUG: _LOGGER.info('Forced Info! for {0}.'.format({_PACKAGENAME})) _LOGGER.error('Forced ERROR! for {0}.'.format({_PACKAGENAME})) # debug breadcrumbs to check this module and used paths _LOGGER.debug('MODULE_PATH: {}'.format(_MODULE_PATH)) -_LOGGER.debug('LY_DEV_PATH: {}'.format(_LY_DEV)) +_LOGGER.debug('O3DE_DEV_PATH: {}'.format(_O3DE_DEV)) _LOGGER.debug('DCCSI_PATH: {}'.format(_DCCSIG_PATH)) -_LOGGER.debug('LY_PROJECT_TAG: {}'.format(_LY_PROJECT_NAME)) +_LOGGER.debug('O3DE_PROJECT_TAG: {}'.format(_O3DE_PROJECT)) _LOGGER.debug('DCCSI_LOG_PATH: {}'.format(_DCCSI_LOG_PATH)) +# ------------------------------------------------------------------------- # ------------------------------------------------------------------------- @@ -258,9 +254,9 @@ del _LOGGER # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True - if _G_DEBUG: + if _DCCSI_GDEBUG: print(_DCCSIG_PATH) test_imports() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py index 2df85cbfaa..f6b71a7d97 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py @@ -18,14 +18,31 @@ import logging as _logging # -------------------------------------------------------------------------- -_PACKAGENAME = 'azpy.config_utils' +# note: this module is called in other root modules +# must avoid cyclical imports +# global scope +# normally would pull the constant envar string +# but avoiding cyclical imports here FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" -_logging.basicConfig(level=_logging.INFO, - format=FRMT_LOG_LONG, - datefmt='%m-%d %H:%M') -_LOGGER = _logging.getLogger(_PACKAGENAME) -_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) +from azpy.env_bool import env_bool +_DCCSI_GDEBUG = env_bool('DCCSI_GDEBUG', False) +_DCCSI_LOGLEVEL = env_bool('DCCSI_LOGLEVEL', False) +_DCCSI_LOGLEVEL = int(env_bool('DCCSI_LOGLEVEL', int(20))) +if _DCCSI_GDEBUG: + _DCCSI_LOGLEVEL = int(10) + +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'azpy.config_utils' + +# set up module logging +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) +#_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER.propagate = False +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) __all__ = ['get_os', 'return_stub', 'get_stub_check_path', 'get_dccsi_config', 'get_current_project'] @@ -34,13 +51,15 @@ __all__ = ['get_os', 'return_stub', 'get_stub_check_path', # ------------------------------------------------------------------------- # just a quick check to ensure what paths have code access -_G_DEBUG = False # enable for debug prints -if _G_DEBUG: +if _DCCSI_GDEBUG: known_paths = list() for p in sys.path: known_paths.append(p) _LOGGER.debug(known_paths) +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- # this import can fail in Maya 2020 (and earlier) stuck on py2.7 # wrapped in a try, to trap and providing messaging to help user correct try: @@ -76,6 +95,15 @@ def get_os(): # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +from azpy.core import get_datadir +# there was a method here refactored out to add py2.7 support for Maya 2020 +#"DccScriptingInterface\azpy\core\py2\utils.py get_datadir()" +#"DccScriptingInterface\azpy\core\py3\utils.py get_datadir()" +# Warning: planning to deprecate py2 support +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- def return_stub_dir(stub_file='dccsi_stub'): _dir_to_last_file = None @@ -126,6 +154,30 @@ def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'): # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def get_o3de_engine_root(check_stub='engine.json'): + # get the O3DE engine root folder + # if we are running within O3DE we can ensure which engine is running + _O3DE_DEV = None + try: + import azlmbr # this file will fail outside of O3DE + except ImportError as e: + # if that fails, we can search up + # search up to get \dev + _O3DE_DEV = get_stub_check_path(check_stub='engine.json') + # To Do: What if engine.json doesn't exist? + else: + # execute if no exception + # allow for external ENVAR override + from azpy.constants import ENVAR_O3DE_DEV + _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, azlmbr.paths.engroot)) + finally: + # note: can't use fstrings as this module gets called with py2.7 in maya + _LOGGER.info('O3DE engine root: {}'.format(_O3DE_DEV.resolve())) + return _O3DE_DEV +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # settings.setenv() # doing this will add the additional DYNACONF_ envars def get_dccsi_config(dccsi_dirpath=return_stub_dir()): @@ -176,46 +228,75 @@ def get_current_project_cfg(dev_folder=get_stub_check_path()): # ------------------------------------------------------------------------- -def get_current_project(): +def get_check_global_project(): """Gets o3de project via .o3de data in user directory""" from azpy.constants import PATH_USER_O3DE_BOOTSTRAP from collections import OrderedDict from box import Box + from azpy.core import get_datadir bootstrap_box = None - - try: - bootstrap_box = Box.from_json(filename=str(Path(PATH_USER_O3DE_BOOTSTRAP).resolve()), - encoding="utf-8", - errors="strict", - object_pairs_hook=OrderedDict) - except Exception as e: - # this file runs in py2.7 for Maya 2020, FileExistsError is not defined - _LOGGER.error('FileExistsError: {}'.format(PATH_USER_O3DE_BOOTSTRAP)) - _LOGGER.error('exception is: {}'.format(e)) - + json_file_path = Path(PATH_USER_O3DE_BOOTSTRAP) + if json_file_path.exists(): + try: + bootstrap_box = Box.from_json(filename=str(json_file_path.resolve()), + encoding="utf-8", + errors="strict", + object_pairs_hook=OrderedDict) + except IOError as e: + # this file runs in py2.7 for Maya 2020, FileExistsError is not defined + _LOGGER.error('Bad file interaction: {}'.format(json_file_path.resolve())) + _LOGGER.error('Exception is: {}'.format(e)) + pass if bootstrap_box: # this seems fairly hard coded - what if the data changes? project_path=Path(bootstrap_box.Amazon.AzCore.Bootstrap.project_path) - return project_path.resolve() + return project_path else: return None # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def get_o3de_project_path(): + """figures out the o3de project path + if not found defaults to the engine folder""" + _O3DE_PROJECT_PATH = None + try: + import azlmbr # this file will fail outside of O3DE + except ImportError as e: + # (fallback 1) this checks if a global project is set + # This check user home for .o3de data + _O3DE_PROJECT_PATH = get_check_global_project() + else: + # execute if no exception, this would indicate we are in O3DE land + # allow for external ENVAR override + from azpy.constants import ENVAR_O3DE_PROJECT_PATH + _O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, azlmbr.paths.projectroot)) + finally: + # (fallback 2) if None, fallback to engine folder + if not _O3DE_PROJECT_PATH: + _O3DE_PROJECT_PATH = get_o3de_engine_root() + # note: can't use fstrings as this module gets called with py2.7 in maya + _LOGGER.info('O3DE project root: {}'.format(_O3DE_PROJECT_PATH.resolve())) + return _O3DE_PROJECT_PATH +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- def bootstrap_dccsi_py_libs(dccsi_dirpath=return_stub_dir()): """Builds and adds local site dir libs based on py version""" from azpy.constants import STR_DCCSI_PYTHON_LIB_PATH # a path string constructor - _DCCSI_PYTHON_LIB_PATH = STR_DCCSI_PYTHON_LIB_PATH.format(dccsi_dirpath, - sys.version_info[0], - sys.version_info[1]) - - if os.path.exists(_DCCSI_PYTHON_LIB_PATH): - _LOGGER.debug('Performed site.addsitedir({})'.format(_DCCSI_PYTHON_LIB_PATH)) - site.addsitedir(_DCCSI_PYTHON_LIB_PATH) # PYTHONPATH + _DCCSI_PYTHON_LIB_PATH = Path(STR_DCCSI_PYTHON_LIB_PATH.format(dccsi_dirpath, + sys.version_info[0], + sys.version_info[1])) + + if _DCCSI_PYTHON_LIB_PATH.exists(): + site.addsitedir(_DCCSI_PYTHON_LIB_PATH.resolve()) # PYTHONPATH + _LOGGER.debug('Performed site.addsitedir({})' + ''.format(_DCCSI_PYTHON_LIB_PATH.resolve())) return _DCCSI_PYTHON_LIB_PATH else: message = "Doesn't exist: {}".format(_DCCSI_PYTHON_LIB_PATH) @@ -243,13 +324,10 @@ if __name__ == '__main__': _config = get_dccsi_config() _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(_config)) - _LOGGER.info('LY_DEV: {}'.format(get_stub_check_path('engine.json'))) - - # this will be deprecated and shouldn't work soon (returns None) - _LOGGER.info('LY_PROJECT: {}'.format(get_current_project_cfg(get_stub_check_path('bootstrap.cfg')))) + _LOGGER.info('O3DE_DEV: {}'.format(get_o3de_engine_root(check_stub='engine.json'))) # new o3de version - _LOGGER.info('LY_PROJECT: {}'.format(get_current_project())) + _LOGGER.info('O3DE_PROJECT: {}'.format(get_check_global_project())) _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(bootstrap_dccsi_py_libs(return_stub_dir('dccsi_stub')))) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py index b9619fa584..d23601a33d 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py @@ -25,7 +25,16 @@ import sys import site from os.path import expanduser import logging as _logging +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# global scope +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'azpy.constants' +os.environ['PYTHONINSPECT'] = 'True' # for this module to perform standalone # we need to set up basic access to the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? @@ -33,10 +42,10 @@ _DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) _DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) site.addsitedir(_DCCSIG_PATH) -# azpy module -#import azpy.constants as cnst +# now we have azpy api access +import azpy +from azpy.env_bool import env_bool from azpy.config_utils import return_stub_dir -import azpy.env_bool as env_bool # ------------------------------------------------------------------------- @@ -49,24 +58,26 @@ ENVAR_DCCSI_LOGLEVEL = str('DCCSI_LOGLEVEL') # Log formating FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" FRMT_LOG_SHRT = "[%(asctime)s][%(name)s][%(levelname)s] >> %(message)s" +# ------------------------------------------------------------------------- -# global space -_G_DEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) +# ------------------------------------------------------------------------- +# global debug stuff +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) +if _DCCSI_GDEBUG: + _DCCSI_LOGLEVEL = int(10) +# ------------------------------------------------------------------------- -_PACKAGENAME = 'azpy.constants' -_LOG_LEVEL = int(20) -if _G_DEBUG: - _LOG_LEVEL = int(10) -_logging.basicConfig(level=_LOG_LEVEL, - format=FRMT_LOG_LONG, - datefmt='%m-%d %H:%M') -_LOGGER = _logging.getLogger(_PACKAGENAME) -_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) +# ------------------------------------------------------------------------- +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) +_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -80,24 +91,25 @@ STR_CROSSBAR_RL = str('{0}\r'.format(STR_CROSSBAR)) STR_CROSSBAR_NL = str('{0}\n'.format(STR_CROSSBAR)) # some common str tags -TAG_DEFAULT_COMPANY = str('Amazon.Lumberyard') +TAG_DEFAULT_COMPANY = str('Amazon.O3DE') TAG_DEFAULT_PROJECT = str('DccScriptingInterface') +TAG_DCCSI_NICKNAME = str('DCCsi') TAG_MOCK_PROJECT = str('MockProject') -TAG_DIR_LY_DEV = str('dev') +TAG_DIR_O3DE_DEV = str('dev') TAG_DIR_DCCSI_AZPY = str('azpy') -TAG_DIR_DCCSI_SDK = str('SDK') -TAG_DIR_LY_BUILD = str('build') +TAG_DIR_DCCSI_TOOLS = str('Tools') +TAG_DIR_O3DE_BUILD_FOLDER = str('build') TAG_QT_PLUGIN_PATH = str('QT_PLUGIN_PATH') TAG_O3DE_FOLDER = str('.o3de') TAG_O3DE_BOOTSTRAP = str('bootstrap.setreg') +TAG_DCCSI_CONFIG = str('dccsiconfiguration.setreg') # filesystem markers, stub file names. -STUB_LY_DEV = str('engine.json') -STUB_LY_ROOT_PROJECT = str('ly_project_stub') -STUB_LY_ROOT_DCCSI = str('dccsi_stub') -STUB_LY_DCCSI_AZPY = str('dccsi_azpy_stub') -STUB_LY_DCCSI_SDK = str('dccsi_sdk_stub') +STUB_O3DE_DEV = str('engine.json') +STUB_O3DE_ROOT_DCCSI = str('dccsi_stub') +STUB_O3DE_DCCSI_AZPY = str('dccsi_azpy_stub') +STUB_O3DE_DCCSI_TOOLS = str('dccsi_tools_stub') # config string consts, Meta Qualifiers QUALIFIER_COMMENT = str('_meta_COMMENT') @@ -135,18 +147,18 @@ PATH_PROGRAMFILES_X64 = str(os.environ['PROGRAMFILES']) # base env var key as str ENVAR_COMPANY = str('COMPANY') -ENVAR_LY_PROJECT = str('LY_PROJECT') -ENVAR_LY_PROJECT_PATH = str('LY_PROJECT_PATH') -ENVAR_LY_DEV = str('LY_DEV') +ENVAR_O3DE_PROJECT = str('O3DE_PROJECT') +ENVAR_O3DE_PROJECT_PATH = str('O3DE_PROJECT_PATH') +ENVAR_O3DE_DEV = str('O3DE_DEV') ENVAR_DCCSIG_PATH = str('DCCSIG_PATH') ENVAR_DCCSI_AZPY_PATH = str('DCCSI_AZPY_PATH') -ENVAR_DCCSI_SDK_PATH = str('DCCSI_SDK_PATH') -ENVAR_LY_BUILD_DIR_NAME = str('LY_BUILD_DIR_NAME') +ENVAR_DCCSI_TOOLS_PATH = str('DCCSI_TOOLS_PATH') +ENVAR_O3DE_BUILD_DIR_NAME = str('O3DE_BUILD_DIR_NAME') -ENVAR_LY_BUILD_PATH = str('LY_BUILD_PATH') +ENVAR_O3DE_BUILD_PATH = str('O3DE_BUILD_PATH') ENVAR_QT_PLUGIN_PATH = TAG_QT_PLUGIN_PATH ENVAR_QTFORPYTHON_PATH = str('QTFORPYTHON_PATH') -ENVAR_LY_BIN_PATH = str('LY_BIN_PATH') +ENVAR_O3DE_BIN_PATH = str('O3DE_BIN_PATH') ENVAR_DCCSI_LOG_PATH = str('DCCSI_LOG_PATH') ENVAR_DCCSI_LAUNCHERS_PATH = str('DCCSI_LAUNCHERS_PATH') @@ -155,7 +167,7 @@ ENVAR_DCCSI_PY_VERSION_MAJOR = str('DCCSI_PY_VERSION_MAJOR') ENVAR_DCCSI_PY_VERSION_MINOR = str('DCCSI_PY_VERSION_MINOR') ENVAR_DCCSI_PYTHON_PATH = str('DCCSI_PYTHON_PATH') ENVAR_DCCSI_PYTHON_LIB_PATH = str('DCCSI_PYTHON_LIB_PATH') -ENVAR_DCCSI_PYTHON_INSTALL = str('DCCSI_PYTHON_INSTALL') +ENVAR_O3DE_PYTHON_INSTALL = str('O3DE_PYTHON_INSTALL') ENVAR_WINGHOME = str('WINGHOME') ENVAR_DCCSI_WING_VERSION_MAJOR = str('DCCSI_WING_VERSION_MAJOR') @@ -169,7 +181,7 @@ ENVAR_DCCSI_PY_DEFAULT = str('DCCSI_PY_DEFAULT') ENVAR_DCCSI_MAYA_VERSION = str('DCCSI_MAYA_VERSION') ENVAR_MAYA_LOCATION = str('MAYA_LOCATION') -ENVAR_DCCSI_SDK_MAYA_PATH = str('DCCSI_SDK_MAYA_PATH') +ENVAR_DCCSI_TOOLS_MAYA_PATH = str('DCCSI_TOOLS_MAYA_PATH') ENVAR_MAYA_MODULE_PATH = str('MAYA_MODULE_PATH') ENVAR_MAYA_BIN_PATH = str('MAYA_BIN_PATH') @@ -188,33 +200,33 @@ ENVAR_MAYA_SCRIPT_PATH = str('MAYA_SCRIPT_PATH') ENVAR_DCCSI_MAYA_SET_CALLBACKS = str('DCCSI_MAYA_SET_CALLBACKS') -TAG_LY_DCC_MAYA_MEL = 'dccsi_setup.mel' +TAG_O3DE_DCC_MAYA_MEL = 'dccsi_setup.mel' TAG_MAYA_WORKSPACE = 'workspace.mel' # dcc scripting interface common and default paths -PATH_LY_DEV = str(return_stub_dir(STUB_LY_DEV)) -PATH_DCCSIG_PATH = str(return_stub_dir(STUB_LY_ROOT_DCCSI)) -PATH_DCCSI_AZPY_PATH = str(return_stub_dir(STUB_LY_DCCSI_AZPY)) -PATH_DCCSI_SDK_PATH = str('{0}\\{1}'.format(PATH_DCCSIG_PATH, TAG_DIR_DCCSI_SDK)) +PATH_O3DE_DEV = str(return_stub_dir(STUB_O3DE_DEV)) +PATH_DCCSIG_PATH = str(return_stub_dir(STUB_O3DE_ROOT_DCCSI)) +PATH_DCCSI_AZPY_PATH = str(return_stub_dir(STUB_O3DE_DCCSI_AZPY)) +PATH_DCCSI_TOOLS_PATH = str('{0}\\{1}'.format(PATH_DCCSIG_PATH, TAG_DIR_DCCSI_TOOLS)) # logging into the cache -PATH_DCCSI_LOG_PATH = str('{LY_DEV}\\Cache\\{LY_PROJECT}\\pc\\user\\log\\logs') +PATH_DCCSI_LOG_PATH = str('{O3DE_PROJECT_PATH}\\user\\log\{TAG_DCCSI_NICKNAME}') # dev \ \ -STR_CONSTRUCT_LY_BUILD_PATH = str('{0}\\{1}') -PATH_LY_BUILD_PATH = str(STR_CONSTRUCT_LY_BUILD_PATH.format(PATH_LY_DEV, - TAG_DIR_LY_BUILD)) +STR_CONSTRUCT_O3DE_BUILD_PATH = str('{0}\\{1}') +PATH_O3DE_BUILD_PATH = str(STR_CONSTRUCT_O3DE_BUILD_PATH.format(PATH_O3DE_DEV, + TAG_DIR_O3DE_BUILD_FOLDER)) # ENVAR_QT_PLUGIN_PATH = TAG_QT_PLUGIN_PATH STR_QTPLUGIN_DIR = str('{0}\\bin\\profile\\EditorPlugins') STR_QTFORPYTHON_PATH = str('{0}\\Gems\\QtForPython\\3rdParty\\pyside2\\windows\\release') -STR_LY_BIN_PATH = str('{0}\\bin\\profile') +STR_O3DE_BIN_PATH = str('{0}\\bin\\profile') -PATH_LY_BUILD_PATH = str('{0}\\{1}'.format(PATH_LY_DEV, TAG_DIR_LY_BUILD)) -PATH_QTFORPYTHON_PATH = str(STR_QTFORPYTHON_PATH.format(PATH_LY_DEV)) -PATH_QT_PLUGIN_PATH = str(STR_QTPLUGIN_DIR).format(PATH_LY_BUILD_PATH) -PATH_LY_BIN_PATH = str(STR_LY_BIN_PATH).format(PATH_LY_BUILD_PATH) +PATH_O3DE_BUILD_PATH = str('{0}\\{1}'.format(PATH_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER)) +PATH_QTFORPYTHON_PATH = str(STR_QTFORPYTHON_PATH.format(PATH_O3DE_DEV)) +PATH_QT_PLUGIN_PATH = str(STR_QTPLUGIN_DIR).format(PATH_O3DE_BUILD_PATH) +PATH_O3DE_BIN_PATH = str(STR_O3DE_BIN_PATH).format(PATH_O3DE_BUILD_PATH) # py path string, parts, etc. TAG_DEFAULT_PY = str('Launch_pyBASE.bat') @@ -233,12 +245,19 @@ parts = os.path.split(PATH_USER_HOME) if str(parts[1].lower()) == 'documents': PATH_USER_HOME = parts[0] _LOGGER.debug('user home CORRECTED: {}'.format(PATH_USER_HOME)) + +STR_USER_O3DE_PATH = str('{home}\\{o3de}') -PATH_USER_O3DE = str('{home}\\{o3de}').format(home=PATH_USER_HOME, +PATH_USER_O3DE = str(STR_USER_O3DE_PATH).format(home=PATH_USER_HOME, o3de=TAG_O3DE_FOLDER) -PATH_USER_O3DE_REGISTRY = str('{0}\\Registry').format(PATH_USER_O3DE) -PATH_USER_O3DE_BOOTSTRAP = str('{reg}\\{file}').format(reg=PATH_USER_O3DE_REGISTRY, - file=TAG_O3DE_BOOTSTRAP) + +TAG_DIR_REGISTRY = str('Registry') +STR_USER_O3DE_REGISTRY_PATH = str('{0}\\{1}') +PATH_USER_O3DE_REGISTRY = str(STR_USER_O3DE_REGISTRY_PATH).format(PATH_USER_O3DE, TAG_DIR_REGISTRY) + +STR_USER_O3DE_BOOTSTRAP_PATH = str('{reg}\\{file}') +PATH_USER_O3DE_BOOTSTRAP = str(STR_USER_O3DE_BOOTSTRAP_PATH).format(reg=PATH_USER_O3DE_REGISTRY, + file=TAG_O3DE_BOOTSTRAP) #python and site-dir TAG_DCCSI_PY_VERSION_MAJOR = str(3) @@ -247,8 +266,8 @@ TAG_DCCSI_PY_VERSION_RELEASE = str(10) TAG_PYTHON_EXE = str('python.exe') TAG_TOOLS_DIR = str('Tools\\Python') TAG_PLATFORM = str('windows') -STR_CONSTRUCT_DCCSI_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') -PATH_DCCSI_PYTHON_PATH = str(STR_CONSTRUCT_DCCSI_PYTHON_INSTALL.format(PATH_LY_DEV, +STR_CONSTRUCT_O3DE_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') +PATH_DCCSI_PYTHON_PATH = str(STR_CONSTRUCT_O3DE_PYTHON_INSTALL.format(PATH_O3DE_DEV, TAG_TOOLS_DIR, TAG_DCCSI_PY_VERSION_MAJOR, TAG_DCCSI_PY_VERSION_MINOR, @@ -290,19 +309,12 @@ PATH_SAT_INSTALL_PATH = str('{0}\\{1}\\{2}\\{3}\\{4}' # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - # there are not really tests to run here due to this being a list of - # constants for shared use. - _G_DEBUG = True - _DCCSI_DEV_MODE = True - _LOGGER.setLevel(_logging.DEBUG) # force debugging - - # this is a top level module and to reduce cyclical azpy imports - # it only has a basic logger configured, add log to console - _handler = _logging.StreamHandler(sys.stdout) - _handler.setLevel(_logging.DEBUG) - _formatter = _logging.Formatter(FRMT_LOG_LONG) - _handler.setFormatter(_formatter) - _LOGGER.addHandler(_handler) + """Run this file as a standalone script""" + + # overide logger for standalone to be more verbose and lof to file + _LOGGER = azpy.initialize_logger(_MODULENAME, + log_to_file=_DCCSI_GDEBUG, + default_log_level=_DCCSI_LOGLEVEL) # happy print _LOGGER.info(STR_CROSSBAR) @@ -321,15 +333,15 @@ if __name__ == '__main__': from pathlib import Path _stash_dict = {} - _stash_dict['LY_DEV'] = Path(PATH_LY_DEV) + _stash_dict['O3DE_DEV'] = Path(PATH_O3DE_DEV) _stash_dict['DCCSIG_PATH'] = Path(PATH_DCCSIG_PATH) _stash_dict['DCCSI_AZPY_PATH'] = Path(PATH_DCCSI_AZPY_PATH) - _stash_dict['DCCSI_SDK_PATH'] = Path(PATH_DCCSI_SDK_PATH) + _stash_dict['DCCSI_TOOLS_PATH'] = Path(PATH_DCCSI_TOOLS_PATH) _stash_dict['DCCSI_PYTHON_PATH'] = Path(PATH_DCCSI_PYTHON_PATH) _stash_dict['DCCSI_PY_BASE'] = Path(PATH_DCCSI_PY_BASE) _stash_dict['DCCSI_PYTHON_LIB_PATH'] = Path(PATH_DCCSI_PYTHON_LIB_PATH) - _stash_dict['LY_BUILD_PATH'] = Path(PATH_LY_BUILD_PATH) - _stash_dict['LY_BIN_PATH'] = Path(PATH_LY_BIN_PATH) + _stash_dict['O3DE_BUILD_PATH'] = Path(PATH_O3DE_BUILD_PATH) + _stash_dict['O3DE_BIN_PATH'] = Path(PATH_O3DE_BIN_PATH) _stash_dict['QTFORPYTHON_PATH'] = Path(PATH_QTFORPYTHON_PATH) _stash_dict['QT_PLUGIN_PATH'] = Path(PATH_QT_PLUGIN_PATH) _stash_dict['SAT_INSTALL_PATH'] = Path(PATH_SAT_INSTALL_PATH) @@ -339,7 +351,7 @@ if __name__ == '__main__': # py 2 and 3 compatible iter def get_items(dict_object): for key in dict_object: - yield key, dict_object[key] + yield key, dict_object[key] for key, value in get_items(_stash_dict): # check if path exists diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/__init__.py new file mode 100644 index 0000000000..9269739f96 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/__init__.py @@ -0,0 +1,42 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +__copyright__ = "Copyright 2021, Amazon" +# ------------------------------------------------------------------------- +import sys +import logging as _logging +# ------------------------------------------------------------------------- + +#pulling from azpy.constants causes cyclical imports :( +FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" +_DCCSI_GDEBUG = False +_DCCSI_LOGLEVEL = int(20) +if _DCCSI_GDEBUG: + _DCCSI_LOGLEVEL = int(10) + +_PACKAGENAME = 'azpy.core' +_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + +__all__ = [] + +if sys.version_info >= (3, 6): + from azpy.core.py3.utils import get_datadir +elif sys.version_info >= (2, 6) and sys.version_info < (3, 6): + _LOGGER.warning('Python vesion < 3 will be deprecated in the future') + from azpy.core.py2.utils import get_datadir +else: + _LOGGER.warning('Python vesion < 2.6 not recommended') + from azpy.core.py2.utils import get_datadir + +__all__ = ['get_datadir'] # you should hope it works + +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/__init__.py new file mode 100644 index 0000000000..35727ddda6 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/__init__.py @@ -0,0 +1,20 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +__copyright__ = "Copyright 2021, Amazon" +# ------------------------------------------------------------------------- +import logging as _logging +# ------------------------------------------------------------------------- +_PACKAGENAME = 'azpy.core.py2' +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + +__all__ = [] +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/utils.py new file mode 100644 index 0000000000..3a79b1bccf --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py2/utils.py @@ -0,0 +1,59 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +"""DCCsi.azpy.core.py2.utils +This module contain versions of utils speciufic to py3 snyntax""" +import sys +import logging as _logging + +try: + import pathlib +except: + import pathlib2 as pathlib + +__all__ = ['get_datadir'] + +_MODULENAME = 'azpy.core.py2.utils' +_LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) + +# ------------------------------------------------------------------------- +def get_datadir(): + """ + persistent application data. + # linux: ~/.local/share + # macOS: ~/Library/Application Support + # windows: C:/Users//AppData/Roaming + """ + + home = pathlib.Path.home() + + if sys.platform.startswith('win'): + datadir = pathlib.Path(home, "AppData/Roaming") + return datadir + elif sys.platform == "linux": + datadir = pathlib.Path(home, ".local/share") + return datadir + elif sys.platform == "darwin": + datadir = pathlib.Path(home, "Library/Application Support") + return datadir + else: # unknown + return None +# ------------------------------------------------------------------------- + + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """module testing""" + + user_data_dir = get_datadir() + _LOGGER.info(user_data_dir.resolve()) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/__init__.py new file mode 100644 index 0000000000..f5d26c9ebe --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/__init__.py @@ -0,0 +1,20 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +__copyright__ = "Copyright 2021, Amazon" +# ------------------------------------------------------------------------- +import logging as _logging +# ------------------------------------------------------------------------- +_PACKAGENAME = 'azpy.core.py3' +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + +__all__ = [] +# ------------------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/utils.py new file mode 100644 index 0000000000..cca07eb7dc --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/core/py3/utils.py @@ -0,0 +1,52 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- +"""DCCsi.azpy.core.py3.utils +This module contain versions of utils speciufic to py3 snyntax""" +import sys +import pathlib +import logging as _logging + +__all__ = ['get_datadir'] + +_MODULENAME = 'azpy.core.py3.utils' +_LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) + +# ------------------------------------------------------------------------- +def get_datadir() -> pathlib.Path: + """ + persistent application data. + # linux: ~/.local/share + # macOS: ~/Library/Application Support + # windows: C:/Users//AppData/Roaming + """ + + home = pathlib.Path.home() + + if sys.platform.startswith('win'): + return home / "AppData/Roaming" + elif sys.platform == "linux": + return home / ".local/share" + elif sys.platform == "darwin": + return home / "Library/Application Support" + else: # unknown + return None +# ------------------------------------------------------------------------- + + +########################################################################### +# Main Code Block, runs this script as main (testing) +# ------------------------------------------------------------------------- +if __name__ == '__main__': + """module testing""" + + user_data_dir = get_datadir() + _LOGGER.info(user_data_dir.resolve()) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/3dsmax/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/3dsmax/__init__.py old mode 100755 new mode 100644 similarity index 71% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/3dsmax/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/3dsmax/__init__.py index 017730d63c..a98de89ad7 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/3dsmax/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/3dsmax/__init__.py @@ -12,38 +12,33 @@ # importing all of the modules """azpy.3dsmax.__init__""" -import os -from azpy.env_bool import env_bool +import logging as _logging + +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.3dsmax' + _PACKAGENAME = 'azpy.dcc.3dsmax' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] - -# ------------------------------------------------------------------------- - -# ------------------------------------------------------------------------- -if _DCCSI_DEV_MODE: - # If in dev mode this will test imports of __all__ - from azpy import test_imports - _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) - test_imports(__all__, - _pkg=_PACKAGENAME, - _logger=_LOGGER) +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -53,14 +48,26 @@ def init(): then it should be initialized and added here so general imports don't fail""" - # __all__.append() - # Make sure we can import the native apis import pymxs import MaxPlus + + # extend all with submodules + #__all__.append('foo', 'bar') # Importing local packages/modules pass # ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +if _DCCSI_DEV_MODE: + # If in dev mode this will test imports of __all__ + from azpy import test_imports + _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) + test_imports(__all__, + _pkg=_PACKAGENAME, + _logger=_LOGGER) +# ------------------------------------------------------------------------- + del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/__init__.py new file mode 100644 index 0000000000..7f2b402c95 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/__init__.py @@ -0,0 +1,53 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -- This line is 75 characters ------------------------------------------- + +"""azpy.shared.__init__""" + +import logging as _logging + +import azpy.env_bool as env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG + +# global space +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) + +_PACKAGENAME = __name__ +if _PACKAGENAME is '__main__': + _PACKAGENAME = 'azpy.dcc' + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + +# ------------------------------------------------------------------------- +# These are explicit imports for now +__all__ = [] +# To Do: procedurally discover dcc access and extend __all__ +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +if _DCCSI_DEV_MODE: + # If in dev mode this will test imports of __all__ + from azpy import test_imports + _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) + test_imports(__all__, + _pkg=_PACKAGENAME, + _logger=_LOGGER) +# ------------------------------------------------------------------------- + +del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/blender/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/blender/__init__.py old mode 100755 new mode 100644 similarity index 71% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/blender/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/blender/__init__.py index 903b76e3c4..b46c7146c2 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/blender/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/blender/__init__.py @@ -12,39 +12,32 @@ # importing all of the modules """azpy.blender.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.blender' - -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -#_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) + _PACKAGENAME = 'azpy.dcc.blender' -# ------------------------------------------------------------------------- - -__all__ = [] +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -if _DCCSI_DEV_MODE: - # If in dev mode this will test imports of __all__ - from azpy import test_imports - _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) - test_imports(__all__, - _pkg=_PACKAGENAME, - _logger=_LOGGER) +# These are explicit imports for now +__all__ = [] +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -53,14 +46,26 @@ def init(): """If the blender bpy api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis import bpy + + # extend all with submodules + #__all__.append('foo', 'bar') # Importing local packages/modules pass # ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +if _DCCSI_DEV_MODE: + # If in dev mode this will test imports of __all__ + from azpy import test_imports + _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) + test_imports(__all__, + _pkg=_PACKAGENAME, + _logger=_LOGGER) +# ------------------------------------------------------------------------- + del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/houdini/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/houdini/__init__.py old mode 100755 new mode 100644 similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/houdini/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/houdini/__init__.py index c0b1ced437..0c16872073 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/houdini/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/houdini/__init__.py @@ -12,28 +12,32 @@ # importing all of the modules """azpy.houdini.__init__""" -import os +import logging as _logging -from azpy import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.houdini' + _PACKAGENAME = 'azpy.dcc.houdini' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -#_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] - +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -53,12 +57,13 @@ def init(): """If the houdini api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis import hou - + + # extend all with submodules + #__all__.append('foo', 'bar') + # Importing local packages/modules pass # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/marmoset/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/marmoset/__init__.py old mode 100755 new mode 100644 similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/marmoset/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/marmoset/__init__.py index 35a081dcbf..7e95b5f19e --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/marmoset/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/marmoset/__init__.py @@ -12,28 +12,32 @@ # importing all of the modules """azpy.houdini.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.marmoset' + _PACKAGENAME = 'azpy.dcc.marmoset' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] - +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -53,12 +57,13 @@ def init(): """If the marmoset api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis import mset - + + # extend all with submodules + #__all__.append('foo', 'bar') + # Importing local packages/modules pass # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/__init__.py old mode 100755 new mode 100644 similarity index 64% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/__init__.py index e66ee63739..870ace6166 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/__init__.py @@ -10,40 +10,32 @@ # -- This line is 75 characters ------------------------------------------- # The __init__.py files help guide import statements without automatically # importing all of the modules -"""azpy.maya.__init__""" +"""azpy.dcc.maya.__init__""" -from azpy.env_bool import env_bool +import logging as _logging + +import azpy.env_bool as env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya' - -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) + _PACKAGENAME = 'azpy.dcc.maya' -# ------------------------------------------------------------------------- +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) __all__ = [] -# ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -if _DCCSI_DEV_MODE: - # If in dev mode this will test imports of __all__ - from azpy import test_imports - _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) - test_imports(__all__, - _pkg=_PACKAGENAME, - _logger=_LOGGER) -# ------------------------------------------------------------------------- - - # ------------------------------------------------------------------------- def init(): """If the maya api is required for a package/module to import, diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/__init__.py old mode 100755 new mode 100644 similarity index 64% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/__init__.py index 3f36bb0fba..7de93fe2bb --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/__init__.py @@ -12,23 +12,26 @@ # importing all of the modules """azpy.maya.callbacks.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.maya.callbacks' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) __all__ = ['event_callback_handler', 'node_message_callback_handler', diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/event_callback_handler.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/event_callback_handler.py old mode 100755 new mode 100644 similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/event_callback_handler.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/event_callback_handler.py index 7603e969e3..d2ca596d3c --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/event_callback_handler.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/event_callback_handler.py @@ -73,12 +73,12 @@ import maya.api.OpenMaya as openmaya #-------------------------------------------------------------------------- # -- Misc Global Space Definitions -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.callbacks.event_callback_handler' + _PACKAGENAME = 'azpy.dcc.maya.callbacks.event_callback_handler' _LOGGER = azpy.initialize_logger(_PACKAGENAME, default_log_level=int(20)) _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/node_message_callback_handler.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/node_message_callback_handler.py old mode 100755 new mode 100644 similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/node_message_callback_handler.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/node_message_callback_handler.py index cfb883be18..e41c9dbbc7 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/node_message_callback_handler.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/node_message_callback_handler.py @@ -80,12 +80,12 @@ import maya.cmds as mc # ------------------------------------------------------------------------- # -- Misc Global Space Definitions -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.callbacks.event_callback_handler' + _PACKAGENAME = 'azpy.dcc.maya.callbacks.event_callback_handler' _LOGGER = azpy.initialize_logger(_PACKAGENAME, default_log_level=int(20)) _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/on_shader_rename.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/on_shader_rename.py old mode 100755 new mode 100644 similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/on_shader_rename.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/on_shader_rename.py index 84e2426c2b..834505f076 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/callbacks/on_shader_rename.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/callbacks/on_shader_rename.py @@ -85,12 +85,12 @@ import maya.cmds as mc # -------------------------------------------------------------------------- # -- Misc Global Space Definitions -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.callbacks.on_shader_rename' + _PACKAGENAME = 'azpy.dcc.maya.callbacks.on_shader_rename' _LOGGER = azpy.initialize_logger(_PACKAGENAME, default_log_level=int(20)) _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/__init__.py old mode 100755 new mode 100644 similarity index 55% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/__init__.py index 7dab357d22..ecb164c1f7 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/__init__.py @@ -10,25 +10,28 @@ # -- This line is 75 characters ------------------------------------------- # The __init__.py files help guide import statements without automatically # importing all of the modules -"""azpy.maya.helpers.__init__""" +"""azpy.dcc.maya.helpers.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.callbacks' + _PACKAGENAME = 'azpy.dcc.maya.callbacks' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) __all__ = ['undo_context', 'utils'] diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/undo_context.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/undo_context.py old mode 100755 new mode 100644 similarity index 97% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/undo_context.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/undo_context.py index 90c12af2c9..7a6de2224b --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/undo_context.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/undo_context.py @@ -42,12 +42,12 @@ import maya.cmds as mc # ------------------------------------------------------------------------- # -- Misc Global Space Definitions -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.helpers.undo_context' + _PACKAGENAME = 'azpy.dcc.maya.helpers.undo_context' _LOGGER = initialize_logger(_PACKAGENAME, default_log_level=int(20)) _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/utils.py old mode 100755 new mode 100644 similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/utils.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/utils.py index 5fe6cd5876..5f1522e6e1 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/helpers/utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/helpers/utils.py @@ -10,7 +10,7 @@ # -- This line is 75 characters ------------------------------------------- """ -azpy.maya utility module +azpy.dcc.maya utility module """ # ------------------------------------------------------------------------- # built in's @@ -32,12 +32,12 @@ import maya.cmds as cmds # ------------------------------------------------------------------------- # -- Misc Global Space Definitions -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.helpers.undo_context' + _PACKAGENAME = 'azpy.dcc.maya.helpers.undo_context' _LOGGER = initialize_logger(_PACKAGENAME, default_log_level=int(20)) _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) @@ -46,7 +46,7 @@ _LOGGER.debug('Invoking:: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- # Initiate the Wing IDE debug connection. -if _G_DEBUG: +if _DCCSI_GDEBUG: #import azpy.dev.connectDebugger as lyDevConnnect # lyDevConnnect() pass diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/__init__.py new file mode 100644 index 0000000000..41f177bcf0 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/__init__.py @@ -0,0 +1,38 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# -------------------------------------------------------------------------- +"""azpy.dcc.maya.toolbits.__init__""" + +import logging as _logging + +import azpy.env_bool as env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG + +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) + +_PACKAGENAME = __name__ +if _PACKAGENAME is '__main__': + _PACKAGENAME = 'azpy.dcc.maya.toolbits' + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + +__all__ = ['detach'] + +del _LOGGER +#-------------------------------------------------------------------------- + diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/detach.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/detach.py old mode 100755 new mode 100644 similarity index 94% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/detach.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/detach.py index 1afcbfa9f6..51d3bb9b66 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/detach.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/toolbits/detach.py @@ -44,12 +44,12 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.toolbits.detatch' + _PACKAGENAME = 'azpy.dcc.maya.toolbits.detatch' import azpy _LOGGER = azpy.initialize_logger(_PACKAGENAME) @@ -65,13 +65,13 @@ def clean_detach(detachType=0, args=None, name=None, or duplicating those faces without harming the orignal ''' - sel = azpy.maya.helpers.utils.Selection() + sel = azpy.dcc.maya.helpers.utils.Selection() for obj in sel.selection.keys(): print("~ cleanDetach:: Working on: {0}".format(obj)) # set up / open the maya undo context - with azpy.maya.helpers.UndoContext(): + with azpy.dcc.maya.helpers.UndoContext(): if deletHistoyIn: mc.delete( obj, constructionHistory = True) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/__init__.py similarity index 100% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/__init__.py diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/execute_wing_code.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/execute_wing_code.py similarity index 95% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/execute_wing_code.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/execute_wing_code.py index 34aaa2cbb7..3c8e7a75a3 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/execute_wing_code.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/execute_wing_code.py @@ -43,13 +43,13 @@ def get_stub_check_path(in_path=__file__, check_stub='engineroot.txt'): # ------------------------------------------------------------------------- # -- Global Definitions -- -_MODULENAME = 'azpy.maya.utils.execute_wing_code' +_MODULENAME = 'azpy.dcc.maya.utils.execute_wing_code' _LOGGER = _logging.getLogger(_MODULENAME) -_LY_DEV = get_stub_check_path() -_LOGGER.info('_LY_DEV: {}'.format(_LY_DEV)) +_O3DE_DEV = get_stub_check_path() +_LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV)) -_PROJ_CACHE = os.path.join(_LY_DEV, 'cache', 'DCCsi', 'wing') +_PROJ_CACHE = os.path.join(_O3DE_DEV, 'cache', 'DCCsi', 'wing') _LOGGER.info('_PROJ_CACHE: {}'.format(_PROJ_CACHE)) _LOCAL_HOST = socket.gethostbyname(socket.gethostname()) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/simple_command_port.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/simple_command_port.py similarity index 98% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/simple_command_port.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/simple_command_port.py index 659cae985d..3a130cd85f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/simple_command_port.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/simple_command_port.py @@ -24,7 +24,7 @@ import logging as _logging # -------------------------------------------------------------------------- # -- Global Definitions -- -_MODULENAME = 'azpy.maya.utils.simple_command_port' +_MODULENAME = 'azpy.dcc.maya.utils.simple_command_port' _LOGGER = _logging.getLogger(_MODULENAME) _LOCAL_HOST = socket.gethostbyname(socket.gethostname()) @@ -205,7 +205,7 @@ class SimpleCommandPort: # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True _LOGGER.setLevel(_logging.DEBUG) # force debugging diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/wing_to_maya.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/wing_to_maya.py similarity index 99% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/wing_to_maya.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/wing_to_maya.py index f170090823..0c06b912d9 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/utils/wing_to_maya.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/maya/utils/wing_to_maya.py @@ -24,7 +24,7 @@ from simple_command_port import SimpleCommandPort # -------------------------------------------------------------------------- # -- Global Definitions -- -_MODULENAME = 'azpy.maya.utils.wing_to_maya' +_MODULENAME = 'azpy.dcc.maya.utils.wing_to_maya' _LOGGER = _logging.getLogger(_MODULENAME) _LOCAL_HOST = socket.gethostbyname(socket.gethostname()) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/lumberyard/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/__init__.py old mode 100755 new mode 100644 similarity index 68% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/lumberyard/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/__init__.py index 9da4e8975a..95aa781557 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/lumberyard/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/__init__.py @@ -11,31 +11,51 @@ # The __init__.py files help guide import statements without automatically # importing all of the modules """azpy.lumberyard.__init__ -All Lumberyard render related packages/modules should live here.""" +All O3DE related extension packages/modules should live here.""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.lumberyard' + _PACKAGENAME = 'azpy.dcc.o3de' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] +# To Do: procedurally discover dcc access and extend __all__ +# ------------------------------------------------------------------------- + # ------------------------------------------------------------------------- +def init(): + """If the lumberyard azlmbr api is required for a package/module to + import, then it should be initialized and added here so general imports + don't fail""" + + import azlmbr + + # extend all with submodules + __all__.append('atom') + + # Importing local packages/modules + pass +# ------------------------------------------------------------------------- # ------------------------------------------------------------------------- @@ -49,19 +69,4 @@ if _DCCSI_DEV_MODE: # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -def init(): - """If the lumberyard azlmbr api is required for a package/module to - import, then it should be initialized and added here so general imports - don't fail""" - - # __all__.append() - - # Make sure we can import the native apis - #import - - # Importing local packages/modules - pass -# ------------------------------------------------------------------------- - del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/render/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/atom/__init__.py old mode 100755 new mode 100644 similarity index 72% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/render/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/atom/__init__.py index a6eb9ea373..ecd1db3ef0 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/render/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/o3de/atom/__init__.py @@ -14,28 +14,33 @@ This package generically uses 'render' to refer to Atom (which is a code name.) All Atom render related packages/modules should live here.""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) + _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.render' - + _PACKAGENAME = 'azpy.dcc.o3de.atom' -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] - +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -55,12 +60,13 @@ def init(): """If the atom render api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis # import - + + # extend all with submodules + #__all__.append('foo', 'bar') + # Importing local packages/modules pass # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/substance/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/substance/__init__.py old mode 100755 new mode 100644 similarity index 71% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/substance/__init__.py rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/substance/__init__.py index 8f9d542906..1e5ee058cc --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/substance/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dcc/substance/__init__.py @@ -12,39 +12,32 @@ # importing all of the modules """azpy.substance.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.substance' + _PACKAGENAME = 'azpy.dcc.substance' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- - +# These are explicit imports for now __all__ = [] - -# ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -if _DCCSI_DEV_MODE: - # If in dev mode this will test imports of __all__ - from azpy import test_imports - _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) - test_imports(__all__, - _pkg=_PACKAGENAME, - _logger=_LOGGER) +# To Do: procedurally discover dcc access and extend __all__ # ------------------------------------------------------------------------- @@ -53,15 +46,26 @@ def init(): """If the substance api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis # import - + + # extend all with submodules + #__all__.append('foo', 'bar') + # Importing local packages/modules pass +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +if _DCCSI_DEV_MODE: + # If in dev mode this will test imports of __all__ + from azpy import test_imports + _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) + test_imports(__all__, + _pkg=_PACKAGENAME, + _logger=_LOGGER) # ------------------------------------------------------------------------- del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/__init__.py index cbd58ba5e8..0db99ff838 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/__init__.py @@ -15,7 +15,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = 'azpy.dev.ide' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/hot_keys.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/hot_keys.py index 2c91398b70..1e179003fe 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/hot_keys.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/hot_keys.py @@ -119,10 +119,10 @@ def get_stub_check_path(in_path=__file__, check_stub='engineroot.txt'): # ------------------------------------------------------------------------- # globals -_LY_DEV = get_stub_check_path() -_LOGGER.info('_LY_DEV: {}'.format(_LY_DEV)) +_O3DE_DEV = get_stub_check_path() +_LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV)) -_PROJ_CACHE = os.path.join(_LY_DEV, 'cache', 'DCCsi', 'wing') +_PROJ_CACHE = os.path.join(_O3DE_DEV, 'cache', 'DCCsi', 'wing') _LOGGER.info('_PROJ_CACHE: {}'.format(_PROJ_CACHE)) if not os.path.exists(_PROJ_CACHE): @@ -339,7 +339,7 @@ mel_selection_to_maya.contexts = [ if __name__ == '__main__': # there are not really tests to run here due to this being a list of # constants for shared use. - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True _LOGGER.setLevel(_logging.DEBUG) # force debugging diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/test.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/test.py index dbf5025f88..838e890184 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/test.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/ide/wing/test.py @@ -73,7 +73,7 @@ dccsi_test_script.contexts = [ if __name__ == '__main__': # there are not really tests to run here due to this being a list of # constants for shared use. - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True _LOGGER.setLevel(_logging.DEBUG) # force debugging diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/maya_app.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/maya_app.py index 76dc3d9b2a..3e4344aecc 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/maya_app.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/maya_app.py @@ -25,10 +25,10 @@ from azpy.constants import ENVAR_DCCSI_DEV_MODE # -------------------------------------------------------------------------- # -- Global Definitions -- -_DCCSI_DCC_APP = None +_DCCSI_G_DCC_APP = None # set up global space, logging etc. -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULENAME = 'azpy.dev.utils.check.maya_app' @@ -43,14 +43,14 @@ _LOGGER = _logging.getLogger(_MODULENAME) def set_dcc_app(dcc_app='maya'): """ azpy.dev.utils.check.maya.set_dcc_app() - this will set global _DCCSI_DCC_APP = 'maya' - and os.environ["DCCSI_DCC_APP"] = 'maya' + this will set global _DCCSI_G_DCC_APP = 'maya' + and os.environ["DCCSI_G_DCC_APP"] = 'maya' """ - _DCCSI_DCC_APP = dcc_app + _DCCSI_G_DCC_APP = dcc_app - _LOGGER.info('Setting DCCSI_DCC_APP to: {0}'.format(dcc_app)) + _LOGGER.info('Setting DCCSI_G_DCC_APP to: {0}'.format(dcc_app)) - return _DCCSI_DCC_APP + return _DCCSI_G_DCC_APP # ------------------------------------------------------------------------- @@ -58,44 +58,44 @@ def set_dcc_app(dcc_app='maya'): def clear_dcc_app(dcc_app=False): """ azpy.dev.utils.check.maya.set_dcc_app() - this will set global _DCCSI_DCC_APP = False - and os.environ["DCCSI_DCC_APP"] = False + this will set global _DCCSI_G_DCC_APP = False + and os.environ["DCCSI_G_DCC_APP"] = False """ - _DCCSI_DCC_APP = dcc_app + _DCCSI_G_DCC_APP = dcc_app - _LOGGER.info('Setting DCCSI_DCC_APP to: {0}'.format(dcc_app)) + _LOGGER.info('Setting DCCSI_G_DCC_APP to: {0}'.format(dcc_app)) - return _DCCSI_DCC_APP + return _DCCSI_G_DCC_APP # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -def validate_state(DCCSI_DCC_APP=_DCCSI_DCC_APP): +def validate_state(DCCSI_G_DCC_APP=_DCCSI_G_DCC_APP): ''' This will detect if we are running in Maya or not, then will call either, set_dcc_app('maya') or clear_dcc_app(dcc_app=False) ''' - if _G_DEBUG: + if _DCCSI_GDEBUG: _LOGGER.debug(autolog()) try: import maya.cmds as cmds - DCCSI_DCC_APP = set_dcc_app('maya') + DCCSI_G_DCC_APP = set_dcc_app('maya') except ImportError as e: _LOGGER.warning('Can not perform: import maya.cmds as cmds') - DCCSI_DCC_APP = clear_dcc_app() + DCCSI_G_DCC_APP = clear_dcc_app() else: try: if cmds.about(batch=True): - DCCSI_DCC_APP = set_dcc_app('maya') + DCCSI_G_DCC_APP = set_dcc_app('maya') except AttributeError as e: _LOGGER.warning("maya.cmds module isn't fully loaded/populated, " "(cmds populates only in batch, maya.standalone, or maya GUI)") # NO Maya - DCCSI_DCC_APP=clear_dcc_app() + DCCSI_G_DCC_APP=clear_dcc_app() - return DCCSI_DCC_APP + return DCCSI_G_DCC_APP # ------------------------------------------------------------------------- @@ -120,7 +120,7 @@ def autolog(): # ------------------------------------------------------------------------- # run the check on import -_DCCSI_DCC_APP = validate_state() +_DCCSI_G_DCC_APP = validate_state() # ------------------------------------------------------------------------- @@ -130,7 +130,7 @@ _DCCSI_DCC_APP = validate_state() if __name__ == '__main__': # there are not really tests to run here due to this being a list of # constants for shared use. - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True _LOGGER.setLevel(_logging.DEBUG) # force debugging @@ -150,5 +150,5 @@ if __name__ == '__main__': _LOGGER.info('{} ... Running script as __main__'.format(_MODULENAME)) _LOGGER.info(STR_CROSSBAR) - _DCCSI_DCC_APP = validate_state() - _LOGGER.info('Is Maya Running? _DCCSI_DCC_APP = {}'.format(_DCCSI_DCC_APP)) + _DCCSI_G_DCC_APP = validate_state() + _LOGGER.info('Is Maya Running? _DCCSI_G_DCC_APP = {}'.format(_DCCSI_G_DCC_APP)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/running_state.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/running_state.py index 301d49a0ea..e5304cf34c 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/running_state.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/dev/utils/check/running_state.py @@ -21,10 +21,11 @@ import logging as _logging # -------------------------------------------------------------------------- # -- Global Definitions -- -_DCCSI_DCC_APP = None +_DCCSI_G_DCC_APP = None _MODULENAME = 'azpy.dev.utils.check.running_state' _LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -36,7 +37,7 @@ class CheckRunningState(object): """ # Class Variables - DCCSI_DCC_APP = None + DCCSI_G_DCC_APP = None def __init__(self, *args, **kwargs): ''' @@ -82,32 +83,35 @@ class CheckRunningState(object): def check_known(self): # -- init -- # first let's check if any of these DCC apps are running + + # To Do?: Add O3DE checks, treat as a DCC app? + # 0 - maya first - CheckRunningState.DCCSI_DCC_APP = self.maya_running() + CheckRunningState.DCCSI_G_DCC_APP = self.maya_running() # 1 - then max - if not CheckRunningState.DCCSI_DCC_APP: - CheckRunningState.DCCSI_DCC_APP = self.max_running() + if not CheckRunningState.DCCSI_G_DCC_APP: + CheckRunningState.DCCSI_G_DCC_APP = self.max_running() else: - _LOGGER.warning('DCCSI_DCC_APP is already set: {}'.format(CheckRunningState.DCCSI_DCC_APP)) + _LOGGER.warning('DCCSI_G_DCC_APP is already set: {}'.format(CheckRunningState.DCCSI_G_DCC_APP)) # 2 - then blender - if not CheckRunningState.DCCSI_DCC_APP: - CheckRunningState.DCCSI_DCC_APP = self.blender_running() + if not CheckRunningState.DCCSI_G_DCC_APP: + CheckRunningState.DCCSI_G_DCC_APP = self.blender_running() else: - _LOGGER.warning('DCCSI_DCC_APP is already set: {}'.format(CheckRunningState.DCCSI_DCC_APP)) + _LOGGER.warning('DCCSI_G_DCC_APP is already set: {}'.format(CheckRunningState.DCCSI_G_DCC_APP)) # store checks for DCC info - if CheckRunningState.DCCSI_DCC_APP: + if CheckRunningState.DCCSI_G_DCC_APP: self.dcc_py = True # store check for is maya running headless - if CheckRunningState.DCCSI_DCC_APP == 'maya': + if CheckRunningState.DCCSI_G_DCC_APP == 'maya': self.maya_headless = self.is_maya_headless() # set a envar other modules can easily check - if CheckRunningState.DCCSI_DCC_APP: - os.environ['DCCSI_DCC_APP'] = CheckRunningState.DCCSI_DCC_APP + if CheckRunningState.DCCSI_G_DCC_APP: + os.environ['DCCSI_G_DCC_APP'] = CheckRunningState.DCCSI_G_DCC_APP # --------------------------------------------------------------------- @@ -164,13 +168,13 @@ class CheckRunningState(object): """< To Do: Need to document >""" try: import azpy.dev.utils.check.maya_app as check_dcc - DCCSI_DCC_APP = check_dcc.validate_state() + DCCSI_G_DCC_APP = check_dcc.validate_state() except ImportError as e: _LOGGER.info('Not Implemented: azpy.dev.utils.check.maya_app') - if DCCSI_DCC_APP: - CheckRunningState.DCCSI_DCC_APP = check_dcc.validate_state() - os.environ["DCCSI_DCC_APP"] = str(DCCSI_DCC_APP) - return CheckRunningState.DCCSI_DCC_APP + if DCCSI_G_DCC_APP: + CheckRunningState.DCCSI_G_DCC_APP = check_dcc.validate_state() + os.environ["DCCSI_G_DCC_APP"] = str(DCCSI_G_DCC_APP) + return CheckRunningState.DCCSI_G_DCC_APP #---------------------------------------------------------------------- # --method------------------------------------------------------------- @@ -200,13 +204,13 @@ class CheckRunningState(object): """ try: import azpy.dev.utils.check.max_app as check_dcc - CheckRunningState.DCCSI_DCC_APP = check_dcc.validate_state() + CheckRunningState.DCCSI_G_DCC_APP = check_dcc.validate_state() except ImportError as e: _LOGGER.info('Not Implemented: azpy.dev.utils.check.max') - if CheckRunningState.DCCSI_DCC_APP: - CheckRunningState.DCCSI_DCC_APP = check_dcc.validate_state() - os.environ["DCCSI_DCC_APP"] = str(CheckRunningState.DCCSI_DCC_APP) - return CheckRunningState.DCCSI_DCC_APP + if CheckRunningState.DCCSI_G_DCC_APP: + CheckRunningState.DCCSI_G_DCC_APP = check_dcc.validate_state() + os.environ["DCCSI_G_DCC_APP"] = str(CheckRunningState.DCCSI_G_DCC_APP) + return CheckRunningState.DCCSI_G_DCC_APP #---------------------------------------------------------------------- @@ -217,13 +221,13 @@ class CheckRunningState(object): """ try: import azpy.dev.utils.check.blender_app as check_dcc - CheckRunningState.DCCSI_DCC_APP = check_dcc.validate_state() + CheckRunningState.DCCSI_G_DCC_APP = check_dcc.validate_state() except ImportError as e: _LOGGER.info('Not Implemented: azpy.dev.utils.check.blender') - if CheckRunningState.DCCSI_DCC_APP: - CheckRunningState.DCCSI_DCC_APP = check_dcc.validate_state() - os.environ["DCCSI_DCC_APP"] = str(CheckRunningState.DCCSI_DCC_APP) - return CheckRunningState.DCCSI_DCC_APP + if CheckRunningState.DCCSI_G_DCC_APP: + CheckRunningState.DCCSI_G_DCC_APP = check_dcc.validate_state() + os.environ["DCCSI_G_DCC_APP"] = str(CheckRunningState.DCCSI_G_DCC_APP) + return CheckRunningState.DCCSI_G_DCC_APP #---------------------------------------------------------------------- @@ -231,7 +235,7 @@ class CheckRunningState(object): # Class Test #========================================================================== if __name__ == '__main__': - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True _LOGGER.setLevel(_logging.DEBUG) # force debugging @@ -251,4 +255,4 @@ if __name__ == '__main__': _LOGGER.info(STR_CROSSBAR) foo = CheckRunningState() - _LOGGER.info('DCCSI_DCC_APP: {}'.format(foo.DCCSI_DCC_APP)) + _LOGGER.info('DCCSI_G_DCC_APP: {}'.format(foo.DCCSI_G_DCC_APP)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py index dd28c98927..cdcf99d762 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py @@ -10,7 +10,7 @@ # -- This line is 75 characters ------------------------------------------- from __future__ import unicode_literals ''' -Module: \azpy\shared\common\base_env.py +Module: \\azpy\\shared\\common\\base_env.py This module packs the most basic set of environment variables. @@ -57,7 +57,7 @@ _LOGGER = _logging.getLogger(_PACKAGENAME) _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) # set up base totally non-functional defauls (denoted with $) @@ -65,15 +65,15 @@ _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _BASE_ENVVAR_DICT = OrderedDict() # project tag -_BASE_ENVVAR_DICT[ENVAR_LY_PROJECT] = '${0}'.format(ENVAR_LY_PROJECT) +_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT] = '${0}'.format(ENVAR_O3DE_PROJECT) # paths -_BASE_ENVVAR_DICT[ENVAR_LY_DEV] = Path('${0}'.format(ENVAR_LY_DEV)) -_BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH] = Path('${0}'.format(ENVAR_LY_PROJECT_PATH)) +_BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] = Path('${0}'.format(ENVAR_O3DE_DEV)) +_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] = Path('${0}'.format(ENVAR_O3DE_PROJECT_PATH)) _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] = Path('${0}'.format(ENVAR_DCCSIG_PATH)) _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] = Path('${0}'.format(ENVAR_DCCSI_LOG_PATH)) _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] = Path('${0}'.format(ENVAR_DCCSI_AZPY_PATH)) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_SDK_PATH] = Path('${0}'.format(ENVAR_DCCSI_SDK_PATH)) +_BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH] = Path('${0}'.format(ENVAR_DCCSI_TOOLS_PATH)) # dev env flags _BASE_ENVVAR_DICT[ENVAR_DCCSI_GDEBUG] = '${0}'.format(ENVAR_DCCSI_GDEBUG) @@ -110,16 +110,16 @@ if __name__ == '__main__': # print(setEnvarDefaults(), '\r') #<-- not necissary, already called # print(BASE_ENVVAR_VALUES, '\r') _LOGGER.info('Pretty print: _BASE_ENVVAR_DICT') - print(json.dumps(_BASE_ENVVAR_DICT, - indent=4, sort_keys=False, - ensure_ascii=False), '\r') + _LOGGER.debug(json.dumps(_BASE_ENVVAR_DICT, + indent=4, sort_keys=False, + ensure_ascii=False), '\r') # retreive a Path type key from the Box - foo = _BASE_ENVVAR_DICT[ENVAR_LY_DEV] + foo = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] _LOGGER.info('~ foo is: {0}'.format(type(foo), foo)) # simple tests - _ENV_TAG = 'LY_DEV' + _ENV_TAG = 'O3DE_DEV' foo = get_envar_default(_ENV_TAG) _LOGGER.info("~ Results of getVar on tag, '{0}':'{1}'\r".format(_ENV_TAG, foo)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/__init__.py deleted file mode 100755 index be62dedcbe..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/maya/toolbits/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding:utf-8 -#!/usr/bin/python -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# -# -- This line is 75 characters ------------------------------------------- -# The __init__.py files help guide import statements without automatically -# importing all of the modules -"""azpy.maya.toolbits.__init__""" - -mport os - -from azpy.env_bool import env_bool -from azpy.constants import ENVAR_DCCSI_GDEBUG -from azpy.constants import ENVAR_DCCSI_DEV_MODE - -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) - -_PACKAGENAME = __name__ -if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.maya.toolbits' - -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) - -__all__ = ['detach'] - -del _LOGGER -#-------------------------------------------------------------------------- - diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/return_stub.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/return_stub.py index a5a4d40aad..478d3c355e 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/return_stub.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/return_stub.py @@ -19,7 +19,7 @@ import logging as _logging # ------------------------------------------------------------------------- # global space debug flag, no fancy stuff here we use in bootstrap -_G_DEBUG = False # manually enable to debug this file +_DCCSI_GDEBUG = False # manually enable to debug this file _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': @@ -44,7 +44,7 @@ def return_stub(stub): break if (len(tail) == 0): path = "" - if _G_DEBUG: + if _DCCSI_GDEBUG: _LOGGER.debug('~ Debug Message: I was not able to find the ' 'path to that file (stub) in a walk-up ' 'from currnet path') diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/__init__.py index 7c109f42cb..d6b6bc0d1d 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/__init__.py @@ -11,23 +11,27 @@ """azpy.shared.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.shared' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/boxDumpTest.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/boxDumpTest.json deleted file mode 100644 index 52c556733c..0000000000 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/boxDumpTest.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "ordered_box": true, - "COMPANY": "Amazon.Lumberyard", - "LY_PROJECT": "DccScriptingInterface", - "LY_DEV": "G:\\depot\\JG_PC1_spectrAtom\\dev", - "LY_BUILD_DIR_NAME": "windows_vs2019", - "LY_BUILD_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\windows_vs2019", - "QT_PLUGIN_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\bin\\profile\\EditorPlugins", - "LY_PROJECT_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\Gems\\AtomLyIntegration\\TechnicalArt\\DccScriptingInterface", - "DCCSIG_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\Gems\\AtomLyIntegration\\TechnicalArt\\DccScriptingInterface", - "DCCSI_AZPY_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\Gems\\AtomLyIntegration\\TechnicalArt\\DccScriptingInterface\\azpy", - "DCCSI_SDK_PATH": "G:\\depot\\JG_PC1_spectrAtom\\dev\\Gems\\AtomLyIntegration\\TechnicalArt\\DccScriptingInterface\\SDK", - "DCCSI_WING_VERSION_MAJOR": "7", - "DCCSI_WING_VERSION_MINOR": "1", - "WINGHOME": "C:\\Program Files (x86)\\Wing Pro 7.1", - "DCCSI_PY_DEFAULT": "G:\\depot\\JG_PC1_spectrAtom\\dev\\Tools\\Python\\3.7.5\\windows\\python.exe" -} diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/__init__.py index ab425ef427..1d552e7ea7 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/__init__.py @@ -12,23 +12,27 @@ # importing all of the modules """azpy.shared.common.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG # global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.shared.common' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- # diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/core_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/core_utils.py index 4040620002..629f52bbd7 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/core_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/core_utils.py @@ -48,34 +48,34 @@ import os import sys import site import fnmatch +import logging as _logging # 3rd Party from pathlib import Path # from progress.spinner import Spinner # deprecate use (or refactor) - -# Lumberyard extensions -from azpy.constants import * -from azpy import initialize_logger # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# global space debug flag -from azpy.env_bool import env_bool +# global space +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) -_PACKAGENAME = __name__ -if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.shared.common.core_utils' +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'azpy.shared.common.core_utils' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -421,7 +421,7 @@ def return_stub(stub): if __name__ == "__main__": '''To Do: Document''' # constants for shared use. - _G_DEBUG = True + _DCCSI_GDEBUG = True # happy _LOGGER.info _LOGGER.info("# {0} #".format('-' * 72)) @@ -435,7 +435,7 @@ if __name__ == "__main__": _KNOWN_SITEDIR_PATHS = site._init_pathinfo() # this is just a debug developer convenience _LOGGER.info (for testing acess) - if _G_DEBUG: + if _DCCSI_GDEBUG: import pkgutil _LOGGER.info('Current working dir: {0}'.format(cwd)) search_path = ['.'] # set to None to see all modules importable from sys.path diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/envar_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/envar_utils.py index fc99df0f30..fc2db6be0c 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/envar_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/common/envar_utils.py @@ -12,7 +12,7 @@ from __future__ import unicode_literals # ------------------------------------------------------------------------- ''' -Module: \azpy\shared\common\config_utils.py +Module: \\azpy\\shared\\common\\config_utils.py A set of utility functions @@ -33,28 +33,31 @@ import logging as _logging # 3rd Party from box import Box from unipath import Path - -# Lumberyard extensions -from azpy.constants import * # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -from azpy.env_bool import env_bool +# global space +import azpy.env_bool as env_bool +from azpy.constants import ENVAR_O3DE_DEV +from azpy.constants import ENVAR_O3DE_PROJECT from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) -_PACKAGENAME = __name__ -if _PACKAGENAME is '__main__': - _PACKAGENAME = 'azpy.shared.common.envar_utils' +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'azpy.shared.common.envar_utils' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -65,7 +68,7 @@ def get_envar_default(envar, envar_default=None, envar_set=Box(ordered_box=True) Get from the system environment, or the module dictionary (a Box): like the test one in __main__ below, TEST_ENV_VALUES = Box(ordered_box=True) - TEST_ENV_VALUES[ENVAR_LY_PROJECT] = '${0}'.format(ENVAR_LY_PROJECT) + TEST_ENV_VALUES[ENVAR_O3DE_PROJECT] = '${0}'.format(ENVAR_O3DE_PROJECT) This dictionary provides a simple way to pack a default set into a structure and decouple the getter implementation. @@ -88,7 +91,7 @@ def get_envar_default(envar, envar_default=None, envar_set=Box(ordered_box=True) # -- envar util ---------------------------------------------------------- -def set_envar_defaults(envar_set, env_root=get_envar_default(ENVAR_LY_DEV)): +def set_envar_defaults(envar_set, env_root=get_envar_default(ENVAR_O3DE_DEV)): """ Set each environment variable if not alreay set with value. Must be safe, will not over-write existing. @@ -98,8 +101,8 @@ def set_envar_defaults(envar_set, env_root=get_envar_default(ENVAR_LY_DEV)): env_root = Path(env_root) if env_root.exists(): - os.environ[ENVAR_LY_DEV] = env_root - envar_set[ENVAR_LY_DEV] = env_root + os.environ[ENVAR_O3DE_DEV] = env_root + envar_set[ENVAR_O3DE_DEV] = env_root else: raise ValueError("EnvVar Root is not valid: {0}".format(env_root)) @@ -107,7 +110,7 @@ def set_envar_defaults(envar_set, env_root=get_envar_default(ENVAR_LY_DEV)): envar = str(envar) value = os.getenv(envar) - if _G_DEBUG: + if _DCCSI_GDEBUG: if not value: _LOGGER.debug('~ EnVar value NOT found: {0}\r'.format(envar)) @@ -191,8 +194,8 @@ if __name__ == '__main__': # it should be benign but leaving this comment here in case of funk # tes envars - TEST_ENV_VALUES[ENVAR_LY_PROJECT] = '${0}'.format(ENVAR_LY_PROJECT) - TEST_ENV_VALUES[ENVAR_LY_DEV] = Path('${0}'.format(ENVAR_LY_DEV)) + TEST_ENV_VALUES[ENVAR_O3DE_PROJECT] = '${0}'.format(ENVAR_O3DE_PROJECT) + TEST_ENV_VALUES[ENVAR_O3DE_DEV] = Path('${0}'.format(ENVAR_O3DE_DEV)) # try to fetch and set the base values from the environment # this makes sure all envars set, are resolved on import @@ -204,7 +207,7 @@ if __name__ == '__main__': ensure_ascii=False), '\r') # simple tests - _ENV_TAG = 'LY_DEV' + _ENV_TAG = 'O3DE_DEV' foo = get_envar_default(_ENV_TAG) _LOGGER.info("~ Results of getVar on tag, '{0}':'{1}'\r".format(_ENV_TAG, foo)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/__init__.py index c18cf9d81a..36a354a965 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/__init__.py @@ -13,31 +13,35 @@ SPDX-License-Identifier: Apache-2.0 OR MIT import os from pathlib import Path import logging as _logging +# ------------------------------------------------------------------------- -from azpy.env_bool import env_bool +# ------------------------------------------------------------------------- +# global space +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.shared.noodely' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) -# ------------------------------------------------------------------------- -# +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) + __all__ = ['find_arg', 'helpers', 'node', 'synth', 'synth_arg_kwarg', 'test_foo'] -# # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/find_arg.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/find_arg.py index 681c88b33c..dd939f3973 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/find_arg.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/find_arg.py @@ -74,7 +74,7 @@ if __name__ == "__main__": print ('~ find_arg.py ... Running script as __main__') print ("# ----------------------------------------------------------------------- #\r") - _G_DEBUG = True + _DCCSI_GDEBUG = True from test_foo import Foo @@ -102,7 +102,7 @@ if __name__ == "__main__": self._kwargsDict[key] = value # synthesize(self, '{0}'.format(key), value) <-- I have a method, # which synthesizes properties... with gettr, settr, etc. - if _G_DEBUG: + if _DCCSI_GDEBUG: print("{0}:{1}".format(key, value)) # representation diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/node.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/node.py index ca44b9a6c8..59e25d45e1 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/node.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/node.py @@ -47,13 +47,13 @@ from azpy.constants import ENVAR_DCCSI_DEV_MODE # global space # To Do: update to dynaconf dynamic env and settings? -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULENAME = 'azpy.shared.noodely.node' _log_level = int(20) -if _G_DEBUG: +if _DCCSI_GDEBUG: _log_level = int(10) _LOGGER = azpy.initialize_logger(_MODULENAME, log_to_file=False, @@ -66,7 +66,7 @@ _LOGGER.debug('Starting:: {}.'.format({_MODULENAME})) # quick test code (remove later) from hashids import Hashids hashids = Hashids(min_length=16, salt='DCCsi') -if _G_DEBUG: +if _DCCSI_GDEBUG: print (hashids.encrypt(193487)) # test hash # ------------------------------------------------------------------------- @@ -107,7 +107,7 @@ class Node(object): """Class constructor: makes a node.""" # share the debug state - _DEBUG = _G_DEBUG + _DEBUG = _DCCSI_GDEBUG # logger _LOGGER = _G_LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/pathnode.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/pathnode.py index 5c5402cb7d..401e524060 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/pathnode.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/noodely/pathnode.py @@ -47,13 +47,13 @@ from azpy.constants import ENVAR_DCCSI_DEV_MODE # ------------------------------------------------------------------------- # global space # To Do: update to dynaconf dynamic env and settings? -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULENAME = 'azpy.shared.noodely.pathnode' _log_level = int(20) -if _G_DEBUG: +if _DCCSI_GDEBUG: _log_level = int(10) _LOGGER = azpy.initialize_logger(_MODULENAME, log_to_file=False, @@ -78,7 +78,7 @@ class PathNode(Node): """doc string""" # share the debug state - _DEBUG = _G_DEBUG + _DEBUG = _DCCSI_GDEBUG # class header _message_header = 'noodly, PathNode(): Message' diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/__init__.py index a73ee00d7c..745ec9a7be 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/__init__.py @@ -11,24 +11,26 @@ """azpy.shared.ui.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.shared.ui' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) - +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- # __all__ = [] diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/base_widget.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/base_widget.py index 311ed484ed..493130eb64 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/base_widget.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/base_widget.py @@ -34,7 +34,7 @@ from shiboken2 import wrapInstance # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = settings.DCCSI_GDEBUG +_DCCSI_GDEBUG = settings.DCCSI_GDEBUG # global space debug flag _DCCSI_DEV_MODE = settings.DCCSI_DEV_MODE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/custom_treemodel.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/custom_treemodel.py index d7b096468d..871b050c7a 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/custom_treemodel.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/custom_treemodel.py @@ -30,7 +30,7 @@ import PySide2.QtGui as QtGui # ------------------------------------------------------------------------- # global space # To Do: update to dynaconf dynamic env and settings? -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) _MODULE_PATH = Path(__file__) @@ -38,7 +38,7 @@ _MODULE_PATH = Path(__file__) _MODULENAME = 'azpy.shared.ui.custom_treemodel' _log_level = int(20) -if _G_DEBUG: +if _DCCSI_GDEBUG: _log_level = int(10) _LOGGER = azpy.initialize_logger(_MODULENAME, log_to_file=False, diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/help_menu.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/help_menu.py index f4b53f6b79..7fdeadc4c2 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/help_menu.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/help_menu.py @@ -27,7 +27,7 @@ import PySide2.QtWidgets as QtWidgets # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = os.getenv('DCCSI_GDEBUG', False) +_DCCSI_GDEBUG = os.getenv('DCCSI_GDEBUG', False) # global space developer mode flag _DCCSI_DEV_MODE = os.getenv('DCCSI_DEV_MODE', False) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_qtextedit_stdout.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_qtextedit_stdout.py index 6fd4f359bc..d14d5bcbd6 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_qtextedit_stdout.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_qtextedit_stdout.py @@ -32,7 +32,7 @@ from PySide2.QtCore import QTimer # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = os.getenv('DCCSI_GDEBUG', False) +_DCCSI_GDEBUG = os.getenv('DCCSI_GDEBUG', False) # global space debug flag _DCCSI_DEV_MODE = os.getenv('DCCSI_DEV_MODE', False) @@ -48,7 +48,7 @@ _MODULENAME = __name__ if _MODULENAME is '__main__': _MODULENAME = _TOOL_TAG -if _G_DEBUG: +if _DCCSI_GDEBUG: _LOGGER = initialize_logger(_MODULENAME, log_to_file=True) _LOGGER.debug('Something invoked :: {0}.'.format({_MODULENAME})) else: @@ -130,7 +130,7 @@ if __name__ == '__main__': _TOOL_TAG = 'azpy.shared.ui.pyside2_qtextedit_stdout' _TYPE_TAG = 'test' - if _G_DEBUG: + if _DCCSI_GDEBUG: _LOGGER = initialize_logger('{0}-TEST'.format(_TOOL_TAG), log_to_file=True) _LOGGER.debug('Something invoked :: {0}.'.format({_MODULENAME})) @@ -155,7 +155,7 @@ if __name__ == '__main__': _READER.start('python', ['-u', _TEST_PY_FILE]) # start the process # after that starts, this will show the console - # LY_QSS = Path(_MODULE_PATH.parent, 'resources', 'stylesheets', 'LYstyle.qss') + # O3DE_QSS = Path(_MODULE_PATH.parent, 'resources', 'stylesheets', 'LYstyle.qss') _DARK_STYLE = Path(_MODULE_PATH.parent, 'resources', 'qdarkstyle', 'style.qss') _CONSOLE.qapp.setStyleSheet(_DARK_STYLE.read_file()) _CONSOLE.show() # make the console visible diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_ui_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_ui_utils.py index b996d9baf6..0f229e45b6 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_ui_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/pyside2_ui_utils.py @@ -51,7 +51,7 @@ import azpy.shared.ui.help_menu as help_menu # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = settings.DCCSI_GDEBUG +_DCCSI_GDEBUG = settings.DCCSI_GDEBUG # global space debug flag _DCCSI_DEV_MODE = settings.DCCSI_DEV_MODE @@ -112,7 +112,7 @@ def from_ui_generate_form_and_base_class(filename, return_output=False): ui_file.exists() except FileNotFoundError as error: output += 'File does not exist: {0}/r'.format(error) - if _G_DEBUG: + if _DCCSI_GDEBUG: print(error) if return_output: return False, output diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/qt_settings.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/qt_settings.py index de2bc1aaf4..28f6e23ac2 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/qt_settings.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/qt_settings.py @@ -24,7 +24,7 @@ import azpy.config_utils _config = azpy.config_utils.get_dccsi_config() # ^ this is effectively an import and retreive of \config.py # init lumberyard Qy/PySide2 access -_config.init_ly_pyside(settings.LY_DEV) +_config.init_o3de_pyside(settings.O3DE_DEV) # now we can import lumberyards PySide2 import PySide2.QtCore as QtCore @@ -32,7 +32,7 @@ import PySide2.QtWidgets as QtWidgets # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = settings.DCCSI_GDEBUG +_DCCSI_GDEBUG = settings.DCCSI_GDEBUG # global space debug flag _DCCSI_DEV_MODE = settings.DCCSI_DEV_MODE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/templates.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/templates.py index a3700e8cf4..ec1d00b6d0 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/templates.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/shared/ui/templates.py @@ -47,7 +47,7 @@ import PySide2.QtUiTools as QtUiTools # ------------------------------------------------------------------------- # global space debug flag -_G_DEBUG = settings.DCCSI_GDEBUG +_DCCSI_GDEBUG = settings.DCCSI_GDEBUG # global space debug flag _DCCSI_DEV_MODE = settings.DCCSI_DEV_MODE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py index 71f2682242..33ac6c6814 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py @@ -40,12 +40,11 @@ Configures several useful environment config settings and paths, [key] : [value] # this is the required base environment - LY_PROJECT : name of project (project directory) - LY_DEV : path to Lumberyard \dev root - LY_PROJECT_PATH : path to project dir + O3DE_PROJECT : name of project (project directory) + O3DE_DEV : path to Lumberyard \dev root + O3DE_PROJECT_PATH : path to project dir DCCSIG_PATH : path to the DCCsi Gem root - DCCSI_AZPY_PATH * : path to azpy Python API (code) - DCCSI_SDK_PATH : path to associated (non-api code) DCC SDK + DCCSI_TOOLS_PATH : path to associated (non-api code) DCC SDK # nice to haves in base env to define core support DCCSI_GDEBUG : sets global debug prints @@ -59,7 +58,7 @@ Configures several useful environment config settings and paths, :: Default version py37 has a launcher (activates the env, starts py interpreter) - set DCCSI_PY_BASE=%DCCSI_PYTHON_INSTALL%\python.exe + set DCCSI_PY_BASE=%O3DE_PYTHON_INSTALL%\python.exe :: shared location for 64bit python 3.7 BASE location set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%\Launch_pyBASE.bat @@ -74,7 +73,7 @@ Configures several useful environment config settings and paths, :: shared location for 64bit DCCSI_PY_MAYA python 2.7 DEV location set DCCSI_PY_MAYA=%MAYA_LOCATION%\bin\mayapy.exe :: wingIDE can use more then one defined/managed interpreters - :: allowing you to _G_DEBUG code in multiple runtimes in one session + :: allowing you to _DCCSI_GDEBUG code in multiple runtimes in one session ${DCCSI_PY_MAYA} # related to the WING as the default DCCSI_GDEBUGGER @@ -92,8 +91,9 @@ import os import sys import site import re -#import inspect +import inspect import json +import importlib.util import logging as _logging from collections import OrderedDict @@ -110,35 +110,33 @@ _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? _DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) _DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) site.addsitedir(_DCCSIG_PATH) -print(_DCCSIG_PATH) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# Lumberyard extensions +# O3DE extensions from pathlib import Path # set up global space, logging etc. -import azpy -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) -_PACKAGENAME = 'DCCsi.azpy.sunthetic_env' +_PACKAGENAME = 'DCCsi.azpy.synthetic_env' -_log_level = int(20) -if _G_DEBUG: - _log_level = int(10) -_LOGGER = azpy.initialize_logger(_PACKAGENAME, - log_to_file=True, - default_log_level=_log_level) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) -_LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME})) _LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH)) -_LOGGER.debug('_G_DEBUG: {}'.format(_G_DEBUG)) +_LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) if _DCCSI_DEV_MODE: @@ -170,7 +168,7 @@ if os.path.exists(_DCCSI_PYTHON_LIB_PATH): # ------------------------------------------------------------------------- # post-bootstrap global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) # ------------------------------------------------------------------------- @@ -225,7 +223,7 @@ def return_stub(stub='dccsi_stub'): break if (len(tail) == 0): path = "" - if _G_DEBUG: + if _DCCSI_GDEBUG: _LOGGER.debug('~Not able to find the path to that file ' '(stub) in a walk-up from currnet path.') break @@ -262,7 +260,7 @@ def get_stub_check_path(in_path, check_stub='engineroot.txt'): # ------------------------------------------------------------------------- # TO DO: Move to a util package or module -def resolve_envar_path(envar='LY_DEV', +def resolve_envar_path(envar='O3DE_DEV', start_path=__file__, check_stub='engineroot.txt', dir_name='dev', @@ -276,7 +274,7 @@ def resolve_envar_path(envar='LY_DEV', That is a pretty safe indicator that we found the right '\dev' - Second it checks if the env var 'LY_DEV' is set, use that instead! + Second it checks if the env var 'O3DE_DEV' is set, use that instead! """ @@ -360,14 +358,14 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # \dev Lumberyard ROOT PATH # someone decided to use this as a root stub (for similar reasons in C++?) - # STUB_LY_DEV = str('engineroot.txt') + # STUB_O3DE_DEV = str('engineroot.txt') # I don't own \dev so I didn't want to check in anything new there - _LY_DEV = resolve_envar_path(ENVAR_LY_DEV, # envar + _O3DE_DEV = resolve_envar_path(ENVAR_O3DE_DEV, # envar _THIS_MODULE_PATH, # search path - STUB_LY_DEV, # stub - TAG_DIR_LY_DEV) # dir + STUB_O3DE_DEV, # stub + TAG_DIR_O3DE_DEV) # dir - _SYNTH_ENV_DICT[ENVAR_LY_DEV] = _LY_DEV.as_posix() + _SYNTH_ENV_DICT[ENVAR_O3DE_DEV] = _O3DE_DEV.as_posix() # project name is a string, it should be project dir name # for siloed testing and a purely synthetc env (nothing previously set) @@ -376,17 +374,17 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # for testing overrides of the default synthetic env # we can do two things here, - # first we can try to fetch from the env os.getenv('LY_PROJECT') + # first we can try to fetch from the env os.getenv('O3DE_PROJECT') # If comes back None, allows you to specify a default fallback # changed to just make the fallback what is set in boostrap # so now it's less of a fallnack and more correct if not # explicitly set - _LY_PROJECT = os.getenv(ENVAR_LY_PROJECT) - _SYNTH_ENV_DICT[ENVAR_LY_PROJECT] = _LY_PROJECT + _O3DE_PROJECT = os.getenv(ENVAR_O3DE_PROJECT) + _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT] = _O3DE_PROJECT - _LY_BUILD_DIR_NAME = os.getenv(ENVAR_LY_BUILD_DIR_NAME, - TAG_DIR_LY_BUILD) - _SYNTH_ENV_DICT[ENVAR_LY_BUILD_DIR_NAME] = _LY_BUILD_DIR_NAME + _O3DE_BUILD_DIR_NAME = os.getenv(ENVAR_O3DE_BUILD_DIR_NAME, + TAG_DIR_O3DE_BUILD_FOLDER) + _SYNTH_ENV_DICT[ENVAR_O3DE_BUILD_DIR_NAME] = _O3DE_BUILD_DIR_NAME # pattern for the above is (and will be repeated) # _SOME_ENVAR = resolve_envar_path('ENVAR', @@ -406,31 +404,31 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # so we guess based on how I set up the original dev environment # -- envar -- - _LY_BUILD_PATH = Path(os.getenv(ENVAR_LY_BUILD_PATH, - PATH_LY_BUILD_PATH)) - _SYNTH_ENV_DICT[ENVAR_LY_BUILD_PATH] = _LY_BUILD_PATH.as_posix() + _O3DE_BUILD_PATH = Path(os.getenv(ENVAR_O3DE_BUILD_PATH, + PATH_O3DE_BUILD_PATH)) + _SYNTH_ENV_DICT[ENVAR_O3DE_BUILD_PATH] = _O3DE_BUILD_PATH.as_posix() # -- envar -- - _LY_BIN_PATH = Path(os.getenv(ENVAR_LY_BIN_PATH, - PATH_LY_BIN_PATH)) + _O3DE_BIN_PATH = Path(os.getenv(ENVAR_O3DE_BIN_PATH, + PATH_O3DE_BIN_PATH)) # some of these need hard checks - if not _LY_BIN_PATH.exists(): - raise Exception('LY_BIN_PATH does NOT exist: {0}'.format(_LY_BIN_PATH)) + if not _O3DE_BIN_PATH.exists(): + raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) else: - _SYNTH_ENV_DICT[ENVAR_LY_BIN_PATH] = _LY_BIN_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_O3DE_BIN_PATH] = _O3DE_BIN_PATH.as_posix() # adding to sys.path apparently doesn't work for .dll locations like Qt - os.environ['PATH'] = _LY_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] + os.environ['PATH'] = _O3DE_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] # -- envar -- # if that stub marker doesn't exist assume DCCsi path (fallback 1) - _LY_PROJECT_PATH = Path(os.getenv(ENVAR_LY_PROJECT_PATH, - Path(_LY_DEV, _LY_PROJECT))) - _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH] = _LY_PROJECT_PATH.as_posix() + _O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, + Path(_O3DE_DEV, _O3DE_PROJECT))) + _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] = _O3DE_PROJECT_PATH.as_posix() # -- envar -- _DCCSIG_PATH = resolve_envar_path(ENVAR_DCCSIG_PATH, # envar _THIS_MODULE_PATH, # search path - STUB_LY_ROOT_DCCSI, # stub name + STUB_O3DE_ROOT_DCCSI, # stub name TAG_DEFAULT_PROJECT) # dir _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] = _DCCSIG_PATH.as_posix() @@ -440,9 +438,9 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): _SYNTH_ENV_DICT[ENVAR_DCCSI_AZPY_PATH] = _AZPY_PATH.as_posix() # -- envar -- - _DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, - Path(_DCCSIG_PATH, TAG_DIR_DCCSI_SDK))) - _SYNTH_ENV_DICT[ENVAR_DCCSI_SDK_PATH] = _DCCSI_SDK_PATH.as_posix() + _DCCSI_TOOLS_PATH = Path(os.getenv(ENVAR_DCCSI_TOOLS_PATH, + Path(_DCCSIG_PATH, TAG_DIR_DCCSI_TOOLS))) + _SYNTH_ENV_DICT[ENVAR_DCCSI_TOOLS_PATH] = _DCCSI_TOOLS_PATH.as_posix() # -- envar -- # external dccsi site-packages @@ -497,7 +495,7 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): - QTFORPYTHON_PATH = Path.joinpath(LY_DEV, + QTFORPYTHON_PATH = Path.joinpath(O3DE_DEV, 'Gems', 'QtForPython', '3rdParty', @@ -509,16 +507,16 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): sys.path.insert(1, str(QTFORPYTHON_PATH)) site.addsitedir(str(QTFORPYTHON_PATH)) - LY_BIN_PATH = Path.joinpath(LY_DEV, + O3DE_BIN_PATH = Path.joinpath(O3DE_DEV, 'windows_vs2019', 'bin', 'profile').resolve() - os.environ["DYNACONF_LY_BIN_PATH"] = str(LY_BIN_PATH) - os.environ["LY_BIN_PATH"] = str(LY_BIN_PATH) - site.addsitedir(str(LY_BIN_PATH)) - sys.path.insert(1, str(LY_BIN_PATH)) + os.environ["DYNACONF_O3DE_BIN_PATH"] = str(O3DE_BIN_PATH) + os.environ["O3DE_BIN_PATH"] = str(O3DE_BIN_PATH) + site.addsitedir(str(O3DE_BIN_PATH)) + sys.path.insert(1, str(O3DE_BIN_PATH)) - QT_PLUGIN_PATH = Path.joinpath(LY_BIN_PATH, + QT_PLUGIN_PATH = Path.joinpath(O3DE_BIN_PATH, 'EditorPlugins').resolve() os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) os.environ["QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) @@ -536,7 +534,7 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): if sys.platform.startswith('win'): path = os.environ['PATH'] newPath = '' - newPath += str(LY_BIN_PATH) + os.pathsep + newPath += str(O3DE_BIN_PATH) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, 'shiboken2').resolve()) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, @@ -591,12 +589,12 @@ def set_env(dict_object): def test_Qt(): try: import PySide2 - print('PySide2: {0}'.format(Path(PySide2.__file__).as_posix())) + _LOGGER.info('PySide2: {0}'.format(Path(PySide2.__file__).as_posix())) # builtins.ImportError: DLL load failed: The specified procedure could not be found. from PySide2 import QtCore from PySide2 import QtWidgets except IOError as e: - print('ERROR: {0}'.format(e)) + _LOGGER.error('ERROR: {0}'.format(e)) raise e try: @@ -610,7 +608,7 @@ def test_Qt(): qapp.instance().quit qapp.exit() except Exception as e: - print('ERROR: {0}'.format(e)) + _LOGGER.error('ERROR: {0}'.format(e)) raise e # ------------------------------------------------------------------------- @@ -620,14 +618,14 @@ def main(argv, env_dict_object, debug=False, devmode=False): import getopt try: opts, args = getopt.getopt(argv, "hvt:", ["verbose=", "test="]) - except getopt.GetoptError: + except getopt.GetoptError as e: # not logging, print to cmd line console - print('synthetic_env.py -v -t ') + _LOGGER.error('synthetic_env.py -v -t ') sys.exit(2) for opt, arg in opts: if opt == '-h': - print('synthetic_env.py -v -t ') + _LOGGER.info('synthetic_env.py -v -t ') sys.exit() elif opt in ("-t", "--test"): @@ -639,14 +637,14 @@ def main(argv, env_dict_object, debug=False, devmode=False): try: from box import Box except ImportError as e: - print('ERROR: {0}'.format(e)) + _LOGGER.error('ERROR: {0}'.format(e)) raise e try: env_dict_object = Box(env_dict_object) - print(str(env_dict_object.to_json(sort_keys=False, + _LOGGER.info(str(env_dict_object.to_json(sort_keys=False, indent=4))) except Exception as e: - print('ERROR: {0}'.format(e)) + _LOGGER.error('ERROR: {0}'.format(e)) raise e # ------------------------------------------------------------------------- @@ -656,16 +654,16 @@ def main(argv, env_dict_object, debug=False, devmode=False): # ------------------------------------------------------------------------- if __name__ == '__main__': # run simple tests? - _G_DEBUG = True + _DCCSI_GDEBUG = True _DCCSI_DEV_MODE = True if _DCCSI_DEV_MODE: try: import azpy.test.entry_test - print('SUCCESS: import azpy.test.entry_test') + _LOGGER.info('SUCCESS: import azpy.test.entry_test') azpy.test.entry_test.main(verbose=True, connect_debugger=True) except ImportError as e: - print('ERROR: {0}'.format(e)) + _LOGGER.error('ERROR: {0}'.format(e)) raise e # init, stash and then activate @@ -673,9 +671,9 @@ if __name__ == '__main__': _SYNTH_ENV_DICT = stash_env(_SYNTH_ENV_DICT) _SYNTH_ENV_DICT = set_env(_SYNTH_ENV_DICT) - main(sys.argv[1:], _SYNTH_ENV_DICT, _G_DEBUG, _DCCSI_DEV_MODE) + main(sys.argv[1:], _SYNTH_ENV_DICT, _DCCSI_GDEBUG, _DCCSI_DEV_MODE) - if _G_DEBUG: + if _DCCSI_GDEBUG: tempBoxJsonFilePath = Path(_SYNTH_ENV_DICT['DCCSIG_PATH'], '.temp') tempBoxJsonFilePath = Path(tempBoxJsonFilePath, 'boxDumpTest.json') diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/__init__.py index 20df0e5813..554d320654 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/__init__.py @@ -12,39 +12,28 @@ # importing all of the modules """azpy.test.__init__""" -import os +import logging as _logging -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) _PACKAGENAME = __name__ if _PACKAGENAME is '__main__': _PACKAGENAME = 'azpy.test' -import azpy -_LOGGER = azpy.initialize_logger(_PACKAGENAME) -_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) - -# ------------------------------------------------------------------------- +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_PACKAGENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) __all__ = ['entry_test'] - -# ------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------- -if _DCCSI_DEV_MODE: - # If in dev mode this will test imports of __all__ - from azpy import test_imports - _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) - test_imports(__all__, - _pkg=_PACKAGENAME, - _logger=_LOGGER) # ------------------------------------------------------------------------- @@ -53,15 +42,26 @@ def init(): """If the substance api is required for a package/module to import, then it should be initialized and added here so general imports don't fail""" - - # __all__.append() # Make sure we can import the native apis # import + # __all__.append() + # Importing local packages/modules pass +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- +if _DCCSI_DEV_MODE: + # If in dev mode this will test imports of __all__ + from azpy import test_imports + _LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME)) + test_imports(__all__, + _pkg=_PACKAGENAME, + _logger=_LOGGER) # ------------------------------------------------------------------------- + del _LOGGER diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py index d9d136f96e..aad440d11f 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py @@ -11,9 +11,9 @@ from __future__ import unicode_literals # ------------------------------------------------------------------------- -import sys import os import site +import logging as _logging # note: some modules not available in py2.7 unless we boostrap with config.py # See example: @@ -23,34 +23,34 @@ from pathlib import Path # ------------------------------------------------------------------------- _BOOT_CHECK = False # set true to test breakpoint in this module directly -import azpy -from azpy.env_bool import env_bool +import azpy.env_bool as env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import FRMT_LOG_LONG -# global space -# To Do: update to dynaconf dynamic env and settings? -_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) -_MODULENAME = 'azpy.test.entry_test' +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'azpy.test.entry_test' -_log_level = int(20) -if _G_DEBUG: - _log_level = int(10) -_LOGGER = azpy.initialize_logger(_MODULENAME, - log_to_file=False, - default_log_level=_log_level) -_LOGGER.debug('Starting:: {}.'.format({_MODULENAME})) +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) +_LOGGER = _logging.getLogger(_MODULENAME) +_logging.basicConfig(format=FRMT_LOG_LONG) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -def main(verbose=_G_DEBUG, connect_debugger=True): - _LOGGER.info('{}'.format('-' * 74)) - _LOGGER.info('entry_test.main()') - _LOGGER.info('Root test import successful:') - _LOGGER.info('~ {}'.format(__file__)) +def main(verbose=_DCCSI_GDEBUG, connect_debugger=True): + if verbose: + _LOGGER.info('{}'.format('-' * 74)) + _LOGGER.info('entry_test.main()') + _LOGGER.info('Root test import successful:') + _LOGGER.info('~ {}'.format(__file__)) if connect_debugger: status = connect_wing() @@ -67,7 +67,7 @@ def connect_wing(): _WINGHOME = os.environ['WINGHOME'] # test _LOGGER.info('~ WINGHOME: {0}'.format(_WINGHOME)) except Exception as e: - _LOGGER.warning(e) + _LOGGER.info(e) from azpy.constants import PATH_DEFAULT_WINGHOME _WINGHOME = PATH_DEFAULT_WINGHOME os.environ['WINGHOME'] = PATH_DEFAULT_WINGHOME @@ -134,5 +134,5 @@ def connect_wing(): # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - _G_DEBUG = True - main(verbose=_G_DEBUG, connect_debugger=_G_DEBUG) + _DCCSI_GDEBUG = True + main(verbose=_DCCSI_GDEBUG, connect_debugger=_DCCSI_GDEBUG) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py index 0c25d16133..5578bcd577 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py @@ -6,8 +6,11 @@ SPDX-License-Identifier: Apache-2.0 OR MIT """ # ------------------------------------------------------------------------- -"""Extend the .env using dynaconf (dynamic configuration and settings) -This config.py module assumes a minimal enviornment is defined in the .env +""".config +Generate dynamic and synethetic environment contest and settings +using dynaconf (dynamic configuration and settings) +This config.py synthetic env can be overriden or extended with a local .env +See: example.env.tmp (copy and rename to .env) To do: ensure that we can stack/layer the dynamic env to work with O3DE projects """ @@ -16,60 +19,97 @@ import os import sys import site import re +import logging as _logging # 3rdParty (possibly) py3 ships with pathlib, 2.7 does not # import pathlib # our framework for dcc tools need to run in apps like Maya that may still be # on py27 so we need to import and use after some boostrapping +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +_O3DE_RUNNING=None +try: + import azlmbr + _O3DE_RUNNING=True +except: + _O3DE_RUNNING=False +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +def attach_debugger(): + _DCCSI_GDEBUG = True + os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) + + _DCCSI_DEV_MODE = True + os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE) + + from azpy.test.entry_test import connect_wing + _debugger = connect_wing() + + return _debugger +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# global scope +_MODULENAME = __name__ +if _MODULENAME is '__main__': + _MODULENAME = 'DCCsi.config' -# -------------------------------------------------------------------+------ #os.environ['PYTHONINSPECT'] = 'True' _MODULE_PATH = os.path.abspath(__file__) # we don't have access yet to the DCCsi Lib\site-packages # (1) this will give us import access to azpy (always?) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', +_DCCSI_PATH = os.getenv('DCCSI_PATH', os.path.abspath(os.path.dirname(_MODULE_PATH))) # ^ we assume this config is in the root of the DCCsi -# if it's not, be sure to set envar 'DCCSIG_PATH' to ensure it -site.addsitedir(_DCCSIG_PATH) # PYTHONPATH +# if it's not, be sure to set envar 'DCCSI_PATH' to ensure it +site.addsitedir(_DCCSI_PATH) # must be done for azpy # now we have azpy api access import azpy from azpy.env_bool import env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import ENVAR_DCCSI_LOGLEVEL # set up global space, logging etc. # set these true if you want them set globally for debugging _DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) - -_PACKAGENAME = 'DCCsi.config' - -_LOG_LEVEL = int(20) +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) if _DCCSI_GDEBUG: - _LOG_LEVEL = int(10) -_LOGGER = azpy.initialize_logger(_PACKAGENAME, - log_to_file=False, - default_log_level=_LOG_LEVEL) -_LOGGER.info('Starting up: {}.'.format({_PACKAGENAME})) -_LOGGER.info('site.addsitedir({})'.format(_DCCSIG_PATH)) -_LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) -_LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) + _DCCSI_LOGLEVEL = int(10) # early attach WingIDE debugger (can refactor to include other IDEs later) +# requires externally enabling via ENVAR if _DCCSI_DEV_MODE: - from azpy.test.entry_test import connect_wing - foo = connect_wing() + _debugger = attach_debugger() # to do: ^ this should be replaced with full featured azpy.dev.util # that supports additional debuggers (pycharm, vscode, etc.) + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) + +_LOGGER = azpy.initialize_logger(_MODULENAME, + log_to_file=_DCCSI_GDEBUG, + default_log_level=_DCCSI_LOGLEVEL) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) +_LOGGER.info('site.addsitedir({})'.format(_DCCSI_PATH)) +_LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) +_LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) +_LOGGER.debug('_DCCSI_LOGLEVEL: {}'.format(_DCCSI_LOGLEVEL)) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# (2) this will give us import access to modules we provide -_DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSIG_PATH) +# this will give us import access to additional modules we provide with DCCsi +_DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSI_PATH) # Now we should be able to just carry on with pth lib and dynaconf from dynaconf import Dynaconf @@ -79,82 +119,103 @@ except: import pathlib2 as pathlib from pathlib import Path -_DCCSIG_PATH = Path(_DCCSIG_PATH).resolve() -_DCCSI_PYTHON_LIB_PATH = Path(_DCCSI_PYTHON_LIB_PATH).resolve() +_DCCSI_PATH = Path(_DCCSI_PATH) # pathify +_DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') +_DCCSI_PYTHON_LIB_PATH = Path(_DCCSI_PYTHON_LIB_PATH) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -def init_ly_pyside(LY_DEV=None): - """sets access to lumberyards Qt dlls and PySide""" +# start locally prepping known default values for dyanmic environment settings +_O3DE_DCCSI_PATH = os.environ['PATH'] +os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + +# this will retreive the O3DE engine root +_O3DE_DEV = azpy.config_utils.get_o3de_engine_root() +# set up dynamic config envars +os.environ["DYNACONF_O3DE_DEV"] = str(_O3DE_DEV.resolve()) + +from azpy.constants import TAG_DIR_O3DE_BUILD_FOLDER +_O3DE_BUILD_FOLDER = TAG_DIR_O3DE_BUILD_FOLDER +os.environ["DYNACONF_O3DE_BUILD_FOLDER"] = str(_O3DE_BUILD_FOLDER) +_O3DE_BUILD_PATH = Path(_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER) +os.environ["DYNACONF_O3DE_BUILD_PATH"] = str(_O3DE_BUILD_PATH.resolve()) + +from azpy.constants import STR_O3DE_BIN_PATH +_O3DE_BIN_PATH = Path(STR_O3DE_BIN_PATH.format(_O3DE_BUILD_PATH)) +os.environ["DYNACONF_O3DE_BIN_PATH"] = str(_O3DE_BIN_PATH.resolve()) + +# this in most cases will return the project folder +# if it returns a matching engine folder then we don't know the project folder +_O3DE_PROJECT_PATH = azpy.config_utils.get_o3de_project_path() +os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH.resolve()) + +# special, a home for stashing PYTHONPATHs into managed settings +_O3DE_PYTHONPATH = list() +_O3DE_PYTHONPATH.append(_DCCSI_PATH) +# ------------------------------------------------------------------------- + - LY_DEV = Path(LY_DEV).resolve() - if not LY_DEV.exists(): - raise Exception('LY_DEV does NOT exist: {0}'.format(LY_DEV)) +# ------------------------------------------------------------------------- +def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, + engine_bin=_O3DE_BIN_PATH): + """Initialize the DCCsi Qt/PySide dynamic env and settings + sets access to lumberyards Qt dlls and PySide""" + + _DCCSI_PATH = Path(dccsi_path) + _O3DE_BIN_PATH = Path(engine_bin) + + if not _O3DE_BIN_PATH.exists(): + raise Exception('_O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) else: - # to do: 'windows_vs2019' might change or be different locally - # 'windows_vs2019' is defined as a str tag in constants - # we may not yet have access to azpy.constants :( - from azpy.constants import TAG_DIR_LY_BUILD - from azpy.constants import PATH_LY_BUILD_PATH - from azpy.constants import PATH_LY_BIN_PATH - # to do: pull some of these str and tags from constants - LY_BUILD_PATH = Path.joinpath(LY_DEV, - TAG_DIR_LY_BUILD).resolve() - LY_BIN_PATH = Path.joinpath(LY_BUILD_PATH, - 'bin', - 'profile').resolve() + pass + + # python config + _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') + os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) # # allows to retreive from settings.QTFORPYTHON_PATH # from azpy.constants import STR_QTFORPYTHON_PATH # a path string constructor - # QTFORPYTHON_PATH = Path(STR_QTFORPYTHON_PATH.format(LY_DEV)).resolve() + # QTFORPYTHON_PATH = Path(STR_QTFORPYTHON_PATH.format(O3DE_DEV)).resolve() # os.environ["DYNACONF_QTFORPYTHON_PATH"] = str(QTFORPYTHON_PATH) # site.addsitedir(str(QTFORPYTHON_PATH)) # PYTHONPATH - QT_PLUGIN_PATH = Path.joinpath(LY_BIN_PATH, - 'EditorPlugins').resolve() - os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) + QT_PLUGIN_PATH = Path.joinpath(_O3DE_BIN_PATH,'EditorPlugins') + os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH.resolve()) os.environ['PATH'] = QT_PLUGIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] - QT_QPA_PLATFORM_PLUGIN_PATH = Path.joinpath(QT_PLUGIN_PATH, - 'platforms').resolve() - os.environ["DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH"] = str(QT_QPA_PLATFORM_PLUGIN_PATH) + QT_QPA_PLATFORM_PLUGIN_PATH = Path.joinpath(QT_PLUGIN_PATH, 'platforms') + os.environ["DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH"] = str(QT_QPA_PLATFORM_PLUGIN_PATH.resolve()) # if the line below is removed external standalone apps can't load PySide2 - os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = str(QT_QPA_PLATFORM_PLUGIN_PATH) + os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = str(QT_QPA_PLATFORM_PLUGIN_PATH.resolve()) # ^^ bypass trying to set only with DYNACONF environment os.environ['PATH'] = QT_QPA_PLATFORM_PLUGIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] # ^^ this particular env only works correctly if put on the PATH in this manner # add Qt binaries to the Windows path to handle findings DLL file dependencies if sys.platform.startswith('win'): - # path = os.environ['PATH'] - # newPath = '' - # newPath += str(LY_BIN_PATH) + os.pathsep - # newPath += str(Path.joinpath(QTFORPYTHON_PATH, - # 'shiboken2').resolve()) + os.pathsep - # newPath += str(Path.joinpath(QTFORPYTHON_PATH, - # 'PySide2').resolve()) + os.pathsep - # newPath += path - # os.environ['PATH']=newPath - _LOGGER.debug('PySide2 bootstrapped PATH for Windows.') + _LOGGER.info('~ Qt/PySide2 bootstrapped PATH for Windows.') + else: + _LOGGER.warning('~ Not tested on Non-Windows platforms.') + # To Do: figure out how to test and/or modify to work try: import PySide2 - _LOGGER.debug('DCCsi, config.py: SUCCESS: import PySide2') + _LOGGER.info('~ SUCCESS: import PySide2') _LOGGER.debug(PySide2) status = True except ImportError as e: - _LOGGER.debug('DCCsi, config.py: FAILURE: import PySide2') + _LOGGER.error('~ FAILURE: import PySide2') status = False raise(e) try: import shiboken2 - _LOGGER.debug('DCCsi, config.py: SUCCESS: import shiboken2') + _LOGGER.info('~ SUCCESS: import shiboken2') _LOGGER.debug(shiboken2) status = True except ImportError as e: - _LOGGER.debug('DCCsi, config.py: FAILURE: import shiboken2') + _LOGGER.error('~ FAILURE: import shiboken2') status = False raise(e) @@ -162,19 +223,44 @@ def init_ly_pyside(LY_DEV=None): # to do: move path construction string to constants and build off of SDK # have not done that yet as I really want to get legal approval and # add this to the QtForPython Gem - # please pass this on the current code review - DCCSI_PYSIDE2_TOOLS = Path.joinpath(LY_DEV, - 'Gems', - 'AtomLyIntegration', - 'TechnicalArt', - 'DccScriptingInterface', - '.dev', - 'QtForPython', - 'pyside2-tools-dev') - os.environ["DYNACONF_DCCSI_PYSIDE2_TOOLS"] = str(DCCSI_PYSIDE2_TOOLS.resolve()) - os.environ['PATH'] = DCCSI_PYSIDE2_TOOLS.as_posix() + os.pathsep + os.environ['PATH'] - - return status + # please pass this in current code reviews + _DCCSI_PYSIDE2_TOOLS = Path(_DCCSI_PYTHON_PATH,'pyside2-tools') + if _DCCSI_PYSIDE2_TOOLS.exists(): + os.environ["DYNACONF_DCCSI_PYSIDE2_TOOLS"] = str(_DCCSI_PYSIDE2_TOOLS.resolve()) + os.environ['PATH'] = _DCCSI_PYSIDE2_TOOLS.as_posix() + os.pathsep + os.environ['PATH'] + + site.addsitedir(_DCCSI_PYSIDE2_TOOLS) + _O3DE_PYTHONPATH.append(_DCCSI_PYSIDE2_TOOLS.resolve()) + _LOGGER.info('~ PySide2-Tools bootstrapped PATH for Windows.') + try: + import pyside2uic + _LOGGER.info('~ SUCCESS: import pyside2uic') + _LOGGER.debug(shiboken2) + status = True + except ImportError as e: + _LOGGER.error('~ FAILURE: import pyside2uic') + status = False + raise(e) + else: + _LOGGER.warning('~ No PySide2 Tools: {}'.format(_DCCSI_PYSIDE2_TOOLS.resolve)) + + _O3DE_DCCSI_PATH = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + + try: + _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] + os.environ["DYNACONF_PYTHONPATH"] = _DCCSI_PYTHONPATH + except: + pass + + from dynaconf import settings + + _LOGGER.info('~ config.init_o3de_pyside() ... DONE') + + if status: + return settings + else: + return None # ------------------------------------------------------------------------- @@ -182,90 +268,219 @@ def init_ly_pyside(LY_DEV=None): def test_pyside2(): """Convenience method to test Qt / PySide2 access""" # now test - _LOGGER.info('Testing Qt / PySide2') + _LOGGER.info('~ Testing Qt / PySide2') try: from PySide2.QtWidgets import QApplication, QPushButton app = QApplication(sys.argv) - hello = QPushButton("Hello world!") + hello = QPushButton("~ O3DE DCCsi PySide2 Test!") hello.resize(200, 60) hello.show() except Exception as e: - _LOGGER.error('FAILURE: Qt / PySide2') + _LOGGER.error('~ FAILURE: Qt / PySide2') status = False raise(e) - _LOGGER.info('SUCCESS: .test_pyside2()') + _LOGGER.info('~ SUCCESS: .test_pyside2()') sys.exit(app.exec_()) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# `envvar_prefix` = export envvars with `export DYNACONF_FOO=bar`. -# `settings_files` = Load this files in the order. -# here we are modifying or adding to the dynamic config settings on import -settings = Dynaconf( - envvar_prefix="DYNACONF", - settings_files=['settings.json', '.secrets.json'], -) - -from azpy.constants import PATH_LY_BUILD_PATH -from azpy.constants import PATH_LY_BIN_PATH - -# global settings -os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) -os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE) - -# search up to get \dev -_LY_DEV = azpy.config_utils.get_stub_check_path(in_path=_DCCSIG_PATH, - check_stub='engine.json') -os.environ["DYNACONF_LY_DEV"] = str(_LY_DEV.resolve()) -_LY_PROJECT = azpy.config_utils.get_current_project() -os.environ["DYNACONF_LY_PROJECT"] = str(_LY_PROJECT.resolve()) -_LY_PROJECT_PATH = Path(_LY_DEV, _LY_PROJECT) -os.environ["DYNACONF_LY_PROJECT_PATH"] = str(_LY_PROJECT_PATH) -os.environ["DYNACONF_DCCSIG_PATH"] = str(_DCCSIG_PATH) -_DCCSI_CONFIG_PATH = Path(_MODULE_PATH).resolve() -os.environ["DYNACONF_DCCSI_CONFIG_PATH"] = str(_DCCSI_CONFIG_PATH) -_DCCSIG_SDK_PATH = Path.joinpath(_DCCSIG_PATH, 'SDK').resolve() -os.environ["DYNACONF_DCCSIG_SDK_PATH"] = str(_DCCSIG_SDK_PATH) -os.environ["DYNACONF_DCCSI_PYTHON_LIB_PATH"] = str(_DCCSI_PYTHON_LIB_PATH) -os.environ["DYNACONF_OS_FOLDER"] = azpy.config_utils.get_os() - -# we need to set up the Ly dev build \bin\path (for Qt dll access) -_LY_BUILD_PATH = Path(PATH_LY_BUILD_PATH).resolve() -os.environ["DYNACONF_LY_BUILD_PATH"] = str(_LY_BUILD_PATH) -_LY_BIN_PATH = Path(PATH_LY_BIN_PATH).resolve() -os.environ["DYNACONF_LY_BIN_PATH"] = str(_LY_BIN_PATH) - -# project cache log dir path -from azpy.constants import ENVAR_DCCSI_LOG_PATH -from azpy.constants import PATH_DCCSI_LOG_PATH -_DCCSI_LOG_PATH = Path(os.getenv(ENVAR_DCCSI_LOG_PATH, - Path(PATH_DCCSI_LOG_PATH.format(LY_DEV=_LY_DEV, - LY_PROJECT=_LY_PROJECT)))) -os.environ["DYNACONF_DCCSI_LOG_PATH"] = str(_DCCSI_LOG_PATH) - -# hard checks -if not _LY_BIN_PATH.exists(): - raise Exception('LY_BIN_PATH does NOT exist: {0}'.format(_LY_BIN_PATH)) -else: - # adding to sys.path apparently doesn't work for .dll locations like Qt - os.environ['PATH'] = _LY_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] - -_LOGGER.info('Dynaconf config.py ... DONE') +def init_o3de_core(engine_path=_O3DE_DEV, + build_folder=_O3DE_BUILD_FOLDER, + project_name=None, + project_path=_O3DE_PROJECT_PATH): + """Initialize the DCCsi Core dynamic env and settings""" + # `envvar_prefix` = export envvars with `export DYNACONF_FOO=bar`. + # `settings_files` = Load this files in the order. + # here we are modifying or adding to the dynamic config settings on import + settings = Dynaconf(envvar_prefix='DYNACONF', + settings_files=['settings.json', + 'dev.settings.json', + 'user.settings.json', + '.secrets.json']) + + # global settings + os.environ["DYNACONF_DCCSI_OS_FOLDER"] = azpy.config_utils.get_os() + os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) + os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE) + os.environ['DYNACONF_DCCSI_LOGLEVEL'] = str(_DCCSI_LOGLEVEL) + + os.environ["DYNACONF_DCCSI_PATH"] = str(_DCCSI_PATH.resolve()) + os.environ['PATH'] = _DCCSI_PATH.as_posix() + os.pathsep + os.environ['PATH'] + + # we already defaulted to discovering these two early because of importance + #os.environ["DYNACONF_O3DE_DEV"] = str(_O3DE_DEV.resolve()) + #os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH) + # we also already added them to DYNACONF_ + # this in an explicit pass in + if project_path: + _project_path = Path(project_path) + try: + _project_path.exists() + _O3DE_PROJECT_PATH = _project_path + os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH.resolve()) + except FileExistsError as e: + _LOGGER.error('~ The project path specified does not appear to exist!') + _LOGGER.warning('~ project_path: {}'.format(project_path)) + _LOGGER.warning('~ fallback to engine root: {}'.format()) + project_path = _O3DE_DEV + os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_DEV.resolve()) + + # we can pull the O3DE_PROJECT (name) from the project path + if not project_name: + project_name = Path(_O3DE_PROJECT_PATH).name + os.environ["DYNACONF_O3DE_PROJECT"] = str(project_name) + # To Do: there might be a project namespace in the project.json? + + # -- O3DE build -- set up \bin\path (for Qt dll access) + os.environ["DYNACONF_O3DE_BUILD_FOLDER"] = str(build_folder) + _O3DE_BUILD_PATH = Path(_O3DE_DEV, build_folder) + + os.environ["DYNACONF_O3DE_BUILD_PATH"] = str(_O3DE_BUILD_PATH.resolve()) + + _O3DE_BIN_PATH = Path(STR_O3DE_BIN_PATH.format(_O3DE_BUILD_PATH)) + os.environ["DYNACONF_O3DE_BIN_PATH"] = str(_O3DE_BIN_PATH.resolve()) + + # hard check + if not _O3DE_BIN_PATH.exists(): + raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + else: + # adding to sys.path apparently doesn't work for .dll locations like Qt + os.environ['PATH'] = _O3DE_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] + # -- + + from azpy.constants import TAG_DIR_DCCSI_TOOLS + _DCCSI_TOOLS_PATH = Path(_DCCSI_PATH, TAG_DIR_DCCSI_TOOLS) + os.environ["DYNACONF_DCCSI_TOOLS_PATH"] = str(_DCCSI_TOOLS_PATH.resolve()) + + from azpy.constants import TAG_DCCSI_NICKNAME + from azpy.constants import PATH_DCCSI_LOG_PATH + _DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(O3DE_PROJECT_PATH=project_path, + TAG_DCCSI_NICKNAME=TAG_DCCSI_NICKNAME)) + os.environ["DYNACONF_DCCSI_LOG_PATH"] = str(_DCCSI_LOG_PATH) + + from azpy.constants import TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG + _DCCSI_CONFIG_PATH = Path(project_path, TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG) + os.environ["DYNACONF_DCCSI_CONFIG_PATH"] = str(_DCCSI_CONFIG_PATH.resolve()) + + from azpy.constants import TAG_DIR_DCCSI_TOOLS + _DCCSIG_TOOLS_PATH = Path.joinpath(_DCCSI_PATH, TAG_DIR_DCCSI_TOOLS) + os.environ["DYNACONF_DCCSIG_TOOLS_PATH"] = str(_DCCSIG_TOOLS_PATH.resolve()) + + _O3DE_DCCSI_PATH = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + + from dynaconf import settings + + _LOGGER.info('~ config.init_o3de_core() ... DONE') + + return settings # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# settings.setenv() # doing this will add the additional DYNACONF_ envars -def get_config_settings(setup_ly_pyside=False): - """Convenience method to set and retreive settings directly from module.""" - from dynaconf import settings +def init_o3de_python(engine_path=_O3DE_DEV, + engine_bin=_O3DE_BIN_PATH, + dccsi_path=_DCCSI_PATH): + + # pathify + _O3DE_DEV = Path(engine_path) + _O3DE_BIN_PATH = Path(engine_bin) + _DCCSI_PATH = Path(dccsi_path) + + # python config + _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') + os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) + + _DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSI_PATH) + os.environ["DYNACONF_DCCSI_PYTHON_LIB_PATH"] = str(_DCCSI_PYTHON_LIB_PATH.resolve()) + os.environ['PATH'] = _DCCSI_PYTHON_LIB_PATH.as_posix() + os.pathsep + os.environ['PATH'] + site.addsitedir(_DCCSI_PYTHON_LIB_PATH) + _O3DE_PYTHONPATH.append(_DCCSI_PYTHON_LIB_PATH.resolve()) + + site.addsitedir(_O3DE_BIN_PATH) + _O3DE_PYTHONPATH.append(_O3DE_BIN_PATH.resolve()) + + _O3DE_PY_EXE = Path(sys.executable) + _DCCSI_PY_IDE = Path(_O3DE_PY_EXE) + os.environ["DYNACONF_DCCSI_PY_IDE"] = str(_DCCSI_PY_IDE.resolve()) + + _O3DE_PYTHONHOME = Path(_O3DE_PY_EXE.parents[0]) + os.environ["DYNACONF_O3DE_PYTHONHOME"] = str(_O3DE_PYTHONHOME.resolve()) + os.environ['PATH'] = _O3DE_PYTHONHOME.as_posix() + os.pathsep + os.environ['PATH'] + _LOGGER.info('~ O3DE_PYTHONHOME - is now the folder containing O3DE python executable') + + _O3DE_PYTHON_INSTALL = Path(_O3DE_DEV, 'python') + os.environ["DYNACONF_O3DE_PYTHON_INSTALL"] = str(_O3DE_PYTHON_INSTALL.resolve()) + os.environ['PATH'] = _O3DE_PYTHON_INSTALL.as_posix() + os.pathsep + os.environ['PATH'] + + if sys.platform.startswith('win'): + _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.cmd') + elif sys.platform == "linux": + _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + elif sys.platform == "darwin": + _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + else: + _DCCSI_PY_BASE = None + + if _DCCSI_PY_BASE: + os.environ["DYNACONF_DCCSI_PY_BASE"] = str(_DCCSI_PY_BASE.resolve()) + + _O3DE_DCCSI_PATH = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + + try: + _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] + os.environ["DYNACONF_PYTHONPATH"] = _DCCSI_PYTHONPATH + except: + pass + + from dynaconf import settings + + _LOGGER.info('~ config.init_o3de_python() ... DONE') + + return settings +# ------------------------------------------------------------------------- - if setup_ly_pyside: - init_ly_pyside(settings.LY_DEV) - settings.setenv() +# ------------------------------------------------------------------------- +# settings.setenv() # doing this will add the additional DYNACONF_ envars +def get_config_settings(engine_path=_O3DE_DEV, + build_folder=_O3DE_BUILD_FOLDER, + project_name=None, + project_path=_O3DE_PROJECT_PATH, + enable_o3de_python=None, + enable_o3de_pyside2=None, + set_env=True): + """Convenience method to initialize and retreive settings directly from module.""" + + settings = init_o3de_core(engine_path, + build_folder, + project_name, + project_path) + + if enable_o3de_python: + settings = init_o3de_python(settings.O3DE_DEV, + settings.O3DE_BIN_PATH, + settings.DCCSI_PATH) + + # These should ONLY be set for O3DE and non-DCC environments + # They will most likely cause other Qt/PySide DCC apps to fail + # or hopefully they can be overridden for DCC envionments + # that provide their own Qt dlls and Pyside2 + # _LOGGER.info('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) + # _LOGGER.info('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) + # assume our standalone python tools wants this access? + # it's safe to do this for dev and from ide + if enable_o3de_pyside2: + settings = init_o3de_pyside2(settings.DCCSI_PATH, + settings.O3DE_BIN_PATH) + + # now standalone we can validate the config. env, settings. + from dynaconf import settings + if set_env: + settings.setenv() return settings # --- END ----------------------------------------------------------------- @@ -274,54 +489,216 @@ def get_config_settings(setup_ly_pyside=False): # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - """Run this file as main""" - - _LOG_LEVEL = int(10) # same as _logging.DEBUG - - _LOGGER = azpy.initialize_logger(_PACKAGENAME, - log_to_file=True, - default_log_level=_LOG_LEVEL) - - from dynaconf import settings - + """Run this file as a standalone cli script""" + + _MODULENAME = __name__ + if _MODULENAME is '__main__': + _MODULENAME = 'DCCsi.config' + + from azpy.constants import STR_CROSSBAR + + while 0: # temp internal debug flag + _DCCSI_GDEBUG = True + break + + # overide logger for standalone to be more verbose and log to file + _LOGGER = azpy.initialize_logger(_MODULENAME, + log_to_file=_DCCSI_GDEBUG, + default_log_level=_DCCSI_LOGLEVEL) + + # happy print + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('~ constants.py ... Running script as __main__') + _LOGGER.info(STR_CROSSBAR) + + # go ahead and run the rest of the configuration + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi Dynamic Config (dynaconf)', + epilog="Attempts to determine O3DE project if -pp not set") + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') + parser.add_argument('-ep', '--engine-path', + type=pathlib.Path, + required=False, + help='The path to the o3de engine.') + parser.add_argument('-bf', '--build-folder', + type=str, + required=False, + help='The name (tag) of the o3de build folder, example build or windows_vs2019.') + parser.add_argument('-pp', '--project-path', + type=pathlib.Path, + required=False, + help='The path to the project.') + parser.add_argument('-pn', '--project-name', + type=str, + required=False, + help='The name of the project.') + parser.add_argument('-py', '--enable-python', + type=bool, + required=False, + help='Enables O3DE python access.') + parser.add_argument('-qt', '--enable-qt', + type=bool, + required=False, + help='Enables O3DE Qt\PySide2 access.') + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') + parser.add_argument('-pc', '--project-config', + type=bool, + required=False, + help='Enables reading the projects registry\dccsiconfiguration.setreg.') + parser.add_argument('-es', '--export-settings', + type=pathlib.Path, + required=False, + help='Writes managed settings to specified path.') + parser.add_argument('-ec', '--export-configuration', + type=bool, + required=False, + help='writes settings as a O3DE registry\dccsiconfiguration.setreg.') + parser.add_argument('-tp', '--test-pyside2', + type=bool, + required=False, + help='Runs Qt/PySide2 tests and reports.') + args = parser.parse_args() + + # easy overrides + if args.global_debug: + _DCCSI_GDEBUG = True + os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) + if args.developer_mode: + attach_debugger() # attempts to start debugger + + if args.set_debugger: + _LOGGER.info('Setting and switching debugger type from WingIDE not implemented.') + # To Do: implement debugger plugin pattern + + # need to do a little plumbing + if not args.engine_path: + args.engine_path=_O3DE_DEV + if not args.build_folder: + from azpy.constants import TAG_DIR_O3DE_BUILD_FOLDER + args.build_folder = TAG_DIR_O3DE_BUILD_FOLDER + if not args.project_path: + args.project_path=_O3DE_PROJECT_PATH + + if _DCCSI_GDEBUG: + args.enable_python = True + args.enable_qt = True + + # now standalone we can validate the config. env, settings. + settings = get_config_settings(engine_path=args.engine_path, + build_folder=args.build_folder, + project_name=args.project_name, + project_path=args.project_path, + enable_o3de_python=args.enable_python, + enable_o3de_pyside2=args.enable_qt) + + ## CORE + _LOGGER.info(STR_CROSSBAR) # not using fstrings in this module because it might run in py2.7 (maya) _LOGGER.info('DCCSI_GDEBUG: {}'.format(settings.DCCSI_GDEBUG)) _LOGGER.info('DCCSI_DEV_MODE: {}'.format(settings.DCCSI_DEV_MODE)) _LOGGER.info('DCCSI_LOGLEVEL: {}'.format(settings.DCCSI_LOGLEVEL)) - - _LOGGER.info('OS_FOLDER: {}'.format(settings.OS_FOLDER)) - _LOGGER.info('LY_PROJECT: {}'.format(settings.LY_PROJECT)) - _LOGGER.info('LY_PROJECT_PATH: {}'.format(settings.LY_PROJECT_PATH)) - _LOGGER.info('LY_DEV: {}'.format(settings.LY_DEV)) - _LOGGER.info('LY_BUILD_PATH: {}'.format(settings.LY_BUILD_PATH)) - _LOGGER.info('LY_BIN_PATH: {}'.format(settings.LY_BIN_PATH)) - + _LOGGER.info('DCCSI_OS_FOLDER: {}'.format(settings.DCCSI_OS_FOLDER)) + + _LOGGER.info('O3DE_DEV: {}'.format(settings.O3DE_DEV)) + _LOGGER.info('O3DE_O3DE_BUILD_FOLDER: {}'.format(settings.O3DE_BUILD_PATH)) + _LOGGER.info('O3DE_BUILD_PATH: {}'.format(settings.O3DE_BUILD_PATH)) + _LOGGER.info('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH)) + + _LOGGER.info('O3DE_PROJECT: {}'.format(settings.O3DE_PROJECT)) + _LOGGER.info('O3DE_PROJECT_PATH: {}'.format(settings.O3DE_PROJECT_PATH)) + + _LOGGER.info('DCCSI_PATH: {}'.format(settings.DCCSI_PATH)) _LOGGER.info('DCCSI_LOG_PATH: {}'.format(settings.DCCSI_LOG_PATH)) - _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(settings.DCCSI_CONFIG_PATH)) - _LOGGER.info('DCCSIG_PATH: {}'.format(settings.DCCSIG_PATH)) - _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(settings.DCCSI_PYTHON_LIB_PATH)) - _LOGGER.info('DDCCSI_PY_BASE: {}'.format(settings.DDCCSI_PY_BASE)) - - # To Do: These should ONLY be set for Lumberyard and non-DCC environments - # They will most likely cause Qt/PySide DCC apps to fail - # or hopefully they can be overridden for DCC envionments - # that provide their own Qt dlls and Pyside2 - #_LOGGER.info('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) - #_LOGGER.info('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) - - init_ly_pyside(settings.LY_DEV) # init lumberyard Qt/PySide2 - # from dynaconf import settings # <-- no need to reimport + + if settings.O3DE_DCCSI_ENV_TEST: + _LOGGER.info('O3DE_DCCSI_ENV_TEST: {}'.format(settings.O3DE_DCCSI_ENV_TEST)) + + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('') + + if args.enable_python: + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('DCCSI_PYTHON_PATH'.format(settings.DCCSI_PYTHON_PATH)) + _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(settings.DCCSI_PYTHON_LIB_PATH)) + _LOGGER.info('DCCSI_PY_IDE'.format(settings.DCCSI_PY_IDE)) + _LOGGER.info('O3DE_PYTHONHOME'.format(settings.O3DE_PYTHONHOME)) + _LOGGER.info('O3DE_PYTHON_INSTALL'.format(settings.O3DE_PYTHON_INSTALL)) + _LOGGER.info('DCCSI_PY_BASE: {}'.format(settings.DCCSI_PY_BASE)) + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('') + else: + _LOGGER.info('Tip: add arg --enable-python to extend the environment with O3DE python access') + + if args.enable_qt: + _LOGGER.info(STR_CROSSBAR) + # _LOGGER.info('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) + _LOGGER.info('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) + _LOGGER.info('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) + _LOGGER.info('DCCSI_PYSIDE2_TOOLS: {}'.format(settings.DCCSI_PYSIDE2_TOOLS)) + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('') + else: + _LOGGER.info('Tip: add arg --enable-qt to extend the environment with O3DE Qt/PySide2 support') + settings.setenv() # doing this will add/set the additional DYNACONF_ envars - - #_LOGGER.info('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) - _LOGGER.info('LY_BIN_PATH: {}'.format(settings.LY_BIN_PATH)) - _LOGGER.info('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) - _LOGGER.info('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) - _LOGGER.info('DCCSI_PYSIDE2_TOOLS: {}'.format(settings.DCCSI_PYSIDE2_TOOLS)) - - test_pyside2() # test PySide2 access with a pop-up button + + if _DCCSI_GDEBUG or args.export_settings: + # to do: need to add malformed json validation to \settings.json + # this can cause a bad error that is deep and hard to debug + + # writting settings + from dynaconf import loaders + from dynaconf.utils.boxing import DynaBox + + _settings_dict = settings.as_dict() + + # default temp filename + _settings_file = Path('settings_export.json.tmp') + + # writes to a file, the format is inferred by extension + # can be .yaml, .toml, .ini, .json, .py + #loaders.write(_settings_file, DynaBox(data).to_dict(), merge=False, env='development') + #loaders.write(_settings_file, DynaBox(data).to_dict()) + + # we want to possibly modify or stash our settings into a o3de .setreg + from box import Box + _settings_box = Box(_settings_dict) + + _LOGGER.info('Pretty print, _settings_box: {}'.format(_settings_file)) + _LOGGER.info(str(_settings_box.to_json(sort_keys=True, + indent=4))) + + # writes settings box + _settings_box.to_json(filename=_settings_file.as_posix(), + sort_keys=True, + indent=4) + + if _DCCSI_GDEBUG or args.test_pyside2: + test_pyside2() # test PySide2 access with a pop-up button + try: + import pyside2uic + except ImportError as e: + _LOGGER.warning("Could not import 'pyside2uic'") + _LOGGER.warning("Refer to: '< local DCCsi >\3rdParty\Python\README.txt'") + _LOGGER.error(e) + + # return + sys.exit() +# --- END ----------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/settings.json b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/settings.json index 0967ef424b..718c6110c3 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/settings.json +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/settings.json @@ -1 +1,13 @@ -{} +{ + "LOAD_DOTENV": true, + "COMPANY": "Amazon", + "DCCSI_GDEBUG": "False", + "DCCSI_DEV_MODE": "False", + "DCCSI_GDEBUGGER": "WING", + "DCCSI_LOGLEVEL": 20, + "DEFAULT_SETTINGS_PATHS": [ + "settings.py", + "settings.json", + ".secrets.json" + ] +} \ No newline at end of file diff --git a/python/get_python_path.bat b/python/get_python_path.bat new file mode 100644 index 0000000000..66942efd70 --- /dev/null +++ b/python/get_python_path.bat @@ -0,0 +1,33 @@ +@echo off +REM +REM Copyright (c) Contributors to the Open 3D Engine Project. +REM For complete copyright and license terms please see the LICENSE at the root of this distribution. +REM +REM SPDX-License-Identifier: Apache-2.0 OR MIT +REM +REM + +:: Retreives the path to the O3DE python executable(s) + +:: Skip initialization if already completed +IF "%O3DE_PYTHONHOME_INIT%"=="1" GOTO :END_OF_FILE + +SET CMD_DIR=%~dp0 + +:: Note, many DCC tools (like Maya) include thier own versioned python interpretter. +:: Some apps may not operate correctly if PYTHONHOME is set/propogated. +:: This is definitely the case with Maya, doing so causes Maya to not boot. +FOR /F "tokens=* USEBACKQ" %%F IN (`%CMD_DIR%\python.cmd %CMD_DIR%\get_python_path.py`) DO (SET O3DE_PYTHONHOME=%%F) +echo O3DE_PYTHONHOME - is now the folder containing O3DE python executable +echo O3DE_PYTHONHOME = %O3DE_PYTHONHOME% + +SET PYTHON=%O3DE_PYTHONHOME%\python.exe + +:: Set flag so we don't initialize dccsi environment twice +SET O3DE_PYTHONHOME_INIT=1 +GOTO END_OF_FILE + +:: Return to starting directory +POPD + +:END_OF_FILE diff --git a/python/get_python_path.py b/python/get_python_path.py new file mode 100644 index 0000000000..fc503ae4ab --- /dev/null +++ b/python/get_python_path.py @@ -0,0 +1,16 @@ +# coding:utf-8 +#!/usr/bin/python +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# +# ------------------------------------------------------------------------- +"""retreive the O3DE python path""" +import sys +from pathlib import Path +py_exe = Path(sys.executable) +py_dir = py_exe.parents[0] +print(py_dir.resolve()) \ No newline at end of file