__init__.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # coding:utf-8
  2. #!/usr/bin/python
  3. #
  4. # Copyright (c) Contributors to the Open 3D Engine Project.
  5. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. #
  7. # SPDX-License-Identifier: Apache-2.0 OR MIT
  8. #
  9. #
  10. # -------------------------------------------------------------------------
  11. """Treat IDE tool integrations as a package
  12. < DCCsi >/Tools/IDE/__init__.py
  13. :Status: Prototype
  14. :Version: 0.0.1
  15. """
  16. # -------------------------------------------------------------------------
  17. # standard imports
  18. import os
  19. import site
  20. from pathlib import Path
  21. import logging as _logging
  22. # -------------------------------------------------------------------------
  23. # -------------------------------------------------------------------------
  24. # global scope
  25. from DccScriptingInterface.Tools import _PACKAGENAME
  26. _PACKAGENAME = f'{_PACKAGENAME}.IDE'
  27. __all__ = ['Wing']
  28. # 'PyCharm',
  29. # 'VScode'] # to do: add others when they are set up
  30. _LOGGER = _logging.getLogger(_PACKAGENAME)
  31. _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME}))
  32. _MODULE_PATH = Path(__file__)
  33. _LOGGER.debug(f'_MODULE_PATH: {_MODULE_PATH}')
  34. # -------------------------------------------------------------------------
  35. # -------------------------------------------------------------------------
  36. # set up access to this IDE folder as a pkg
  37. # last two package paths, follow the turtles all the way down
  38. from DccScriptingInterface import add_site_dir
  39. from DccScriptingInterface.Tools import PATH_DCCSIG
  40. from DccScriptingInterface.Tools import PATH_DCCSI_TOOLS
  41. from DccScriptingInterface.globals import *
  42. from DccScriptingInterface.constants import ENVAR_PATH_DCCSI_TOOLS_IDE
  43. # the path to this < dccsi >/Tools/IDE pkg
  44. PATH_DCCSI_TOOLS_IDE = Path(_MODULE_PATH.parent)
  45. PATH_DCCSI_TOOLS_IDE = Path(os.getenv(ENVAR_PATH_DCCSI_TOOLS_IDE,
  46. PATH_DCCSI_TOOLS_IDE.as_posix()))
  47. add_site_dir(PATH_DCCSI_TOOLS_IDE.as_posix())
  48. _LOGGER.debug(f'{ENVAR_PATH_DCCSI_TOOLS_IDE}: {PATH_DCCSI_TOOLS_IDE}')
  49. _LOGGER.debug(STR_CROSSBAR)
  50. # -------------------------------------------------------------------------
  51. # -------------------------------------------------------------------------
  52. # suggestion would be to turn this into a method to reduce boilerplate
  53. # but where to put it that makes sense?
  54. if DCCSI_DEV_MODE:
  55. _LOGGER.debug(f'Testing Imports from {_PACKAGENAME}')
  56. # If in dev mode and test is flagged this will force imports of __all__
  57. # although slower and verbose, this can help detect cyclical import
  58. # failure and other issues
  59. # the DCCSI_TESTS flag needs to be properly added in .bat env
  60. if DCCSI_TESTS:
  61. from DccScriptingInterface.azpy import test_imports
  62. test_imports(_all=__all__,
  63. _pkg=_PACKAGENAME,
  64. _logger=_LOGGER)
  65. # -------------------------------------------------------------------------