__init__.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. # -------------------------------------------------------------------------
  9. """! This is a ui pkg for O3DE, DccScriptingInterface Gem
  10. :file: DccScriptingInterface\\azpy\\shared\\ui\\__init__.py
  11. """
  12. import site
  13. from pathlib import Path
  14. import logging as _logging
  15. from DccScriptingInterface.azpy.shared import _PACKAGENAME
  16. _PACKAGENAME = f'{_PACKAGENAME}.ui'
  17. _LOGGER = _logging.getLogger(_PACKAGENAME)
  18. _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME}))
  19. __all__ = ['utils', 'samples']
  20. from DccScriptingInterface.globals import *
  21. DCCSI_TEST_PYSIDE = False
  22. # turtles all the way down, the paths from there to here
  23. from DccScriptingInterface import PATH_O3DE_TECHART_GEMS
  24. from DccScriptingInterface import PATH_DCCSIG
  25. if DCCSI_TEST_PYSIDE:
  26. import DccScriptingInterface.config as dccsi_core_config
  27. settings_core = dccsi_core_config.get_config_settings(enable_o3de_python=False,
  28. enable_o3de_pyside2=True,
  29. set_env=True)
  30. try:
  31. import PySide2 # this triggers the PySide2 init
  32. from PySide2 import QtWidgets # this requires DLLs to be built
  33. except ImportError as e:
  34. _LOGGER.error(f'Qt exception: {e}')
  35. _LOGGER.warning(f'Something is wrong with Qt/PySide imports')
  36. _LOGGER.warning(f'Make sure the O3DE engine is built')
  37. raise e
  38. from DccScriptingInterface.config import _DCCSI_LOCAL_SETTINGS
  39. # see if the pyside2tools are installed, if so add modules
  40. PYSIDE2_TOOLS = Path(_DCCSI_LOCAL_SETTINGS['PATH_DCCSI_PYTHON_LIB'], 'pyside2tools')
  41. try:
  42. PYSIDE2_TOOLS = PYSIDE2_TOOLS.resolve(strict=True)
  43. site.addsitedir(PYSIDE2_TOOLS.as_posix())
  44. import pyside2tools
  45. _LOGGER.info(f'pyside2tools installed: {pyside2tools}')
  46. _LOGGER.info(f'pyside2tools path: {PYSIDE2_TOOLS.as_posix()}')
  47. except Exception as e:
  48. PYSIDE2_TOOLS = None
  49. _LOGGER.warning(f'pyside2tools not installed.')
  50. if PYSIDE2_TOOLS:
  51. __all__.append('puic_utils')