__init__.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. """An O3DE out-of-box WingIDE integration
  12. < DCCsi >/Tools/IDE/WingIDE/__init__.py
  13. :Status: Prototype
  14. :Version: 0.0.1
  15. :Wing Version: Wing Pro 8.x
  16. This init allows us to treat WingIDE setup as a DCCsi tools python package.
  17. Setting up a consistent development environment can be daunting for an
  18. initiate; hours or days searching through docs and setting up a project,
  19. just to get to the point you are authoring code while able to debug it.
  20. This DCCsi Tool integration performs much of this setup for developers
  21. and contributors working with Python and Wing IDE.
  22. Choice of IDEs like most tools, is a very personal choice and investment.
  23. This integration doesn't mean we have locked O3DE or Technical ARt into a
  24. single solution, it is just one possible tool integration of many (we'd
  25. like to add VScode and PyCharm in a similar manner.) And the community
  26. could likewise set up a multitude of others.
  27. The reason I like Wing IDE as a TA is that getting it working with DCC
  28. tools like Maya is relatively straightforward and well documented.
  29. Also the DCCsi works with many DCC apps, each with their own Python
  30. interpreter, and sometimes these python interpreters are managed, such
  31. as mayapy.exe
  32. This integration allows each DCC py interpreter, to be specified in a
  33. data-driven manner as a dev/launch environment; and since the DCCsi
  34. has portions of API that are shared py3 code, you may want to test the
  35. code against several different interpreters in a similar environment as
  36. the code would operate normally outside of the IDE and within the DCC app.
  37. So for instance,
  38. The Wing IDE launch environment, may specify the following:
  39. :: shared location for 64bit DCCSI_PY_MAYA python location
  40. set "DCCSI_PY_MAYA=%MAYA_BIN_PATH%\mayapy.exe"
  41. Then within Wing IDE, there will be a set of Python Shell environments,
  42. each can start a defined interpreter.
  43. DCCSI_PY_O3DE = ${DCCSI_PY_O3DE}
  44. DCCSI_PY_MAYA = ${DCCSI_PY_MAYA}
  45. ...
  46. And there are times special considerations to be made, for instance
  47. intellisense auto-complete with mayapy.exe doesn't work unless mayapy.exe
  48. is that actual interpreter specified.
  49. In Wing you can switch the interpreter via:
  50. Console (panel) > Python Shell (tab) > Options > Use Environment ...
  51. This integration also hooks into bootstrapping code, which can auto-start
  52. and attach to Wing as the external debugger from other entrypoints and code,
  53. such as a plugin or tool starting within O3DE.
  54. This is a python script driven replacement for files found here:
  55. < DCCsi >\Tools\Dev\Windows\*.bat
  56. Notes:
  57. - The old .bat launchers and some DCCsi code supported py2.7+, but we are
  58. deprecating support because of end-of-life
  59. - The old .bat launchers supported Wing 7.x, however that version of Wing
  60. also shipped with py2.7 as it's own managed interpreter, so we do not
  61. intend to implement support for older versions of wing < 8. However, wing
  62. can support py3 interpreters and debugging so it's possible it will
  63. continue to work.
  64. - I am a paid developer, so I am using Wing Pro. I need a fully featured IDE
  65. to develop with. This increment of work does not intend to support Wing
  66. Community edition, I consider that future work.
  67. - The old .bat files are a great fallback to avoid a catch22; I am using
  68. Wing to develop the framework for a managed environment, launching and
  69. bootstrapping of tools like Wing. So the .bat files will be updated to
  70. Wing 8.x support and stick around to start Wing on windows if and when the
  71. framework is broken and inoperable.
  72. """
  73. # -------------------------------------------------------------------------
  74. # standard imports
  75. import sys
  76. import os
  77. from pathlib import Path
  78. import logging as _logging
  79. # -------------------------------------------------------------------------
  80. # -------------------------------------------------------------------------
  81. # global scope
  82. from DccScriptingInterface.Tools.IDE import _PACKAGENAME
  83. _PACKAGENAME = f'{_PACKAGENAME}.Wing'
  84. __all__ = ['globals',
  85. 'config',
  86. 'constants'
  87. 'discovery',
  88. 'start']
  89. #'Foo',
  90. _LOGGER = _logging.getLogger(_PACKAGENAME)
  91. _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME}))
  92. # -------------------------------------------------------------------------
  93. # -------------------------------------------------------------------------
  94. # set up access to this IDE/Wing folder as a pkg
  95. _MODULE_PATH = Path(__file__)
  96. _LOGGER.debug(f'_MODULE_PATH: {_MODULE_PATH}')
  97. from DccScriptingInterface import add_site_dir
  98. from DccScriptingInterface import SETTINGS_FILE_SLUG
  99. from DccScriptingInterface import LOCAL_SETTINGS_FILE_SLUG
  100. # these are here to support debugging with wing now during development
  101. from DccScriptingInterface import SLUG_DCCSI_WING_TYPE
  102. from DccScriptingInterface import SLUG_DCCSI_WING_VERSION_MAJOR
  103. from DccScriptingInterface import PATH_WINGHOME
  104. from DccScriptingInterface import PATH_WING_APPDATA
  105. from DccScriptingInterface.constants import PATH_PROGRAMFILES_X86
  106. from DccScriptingInterface.constants import USER_HOME
  107. from DccScriptingInterface.constants import ENVAR_PATH_DCCSI_TOOLS_IDE_WING
  108. # last two parents
  109. from DccScriptingInterface.Tools.IDE import PATH_DCCSI_TOOLS
  110. from DccScriptingInterface.Tools.IDE import PATH_DCCSI_TOOLS_IDE
  111. from DccScriptingInterface.globals import *
  112. # set up access to this Wing IDE folder as a pkg
  113. _DCCSI_TOOLS_IDE_WING = Path(_MODULE_PATH.parent)
  114. add_site_dir(_DCCSI_TOOLS_IDE_WING.as_posix())
  115. # the path to this < dccsi >/Tools/IDE pkg
  116. PATH_DCCSI_TOOLS_IDE_WING = Path(_MODULE_PATH.parent)
  117. PATH_DCCSI_TOOLS_IDE_WING = Path(os.getenv(ENVAR_PATH_DCCSI_TOOLS_IDE_WING,
  118. PATH_DCCSI_TOOLS_IDE_WING.as_posix()))
  119. add_site_dir(PATH_DCCSI_TOOLS_IDE_WING.as_posix())
  120. _LOGGER.debug(f'{ENVAR_PATH_DCCSI_TOOLS_IDE_WING}: {PATH_DCCSI_TOOLS_IDE_WING}')
  121. _LOGGER.debug(STR_CROSSBAR)
  122. # from dynaconf import LazySettings
  123. PATH_DCCSI_TOOLS_IDE_WING_SETTINGS = PATH_DCCSI_TOOLS_IDE_WING.joinpath(SETTINGS_FILE_SLUG).resolve()
  124. PATH_DCCSI_TOOLS_IDE_WING_LOCAL_SETTINGS = PATH_DCCSI_TOOLS_IDE_WING.joinpath(LOCAL_SETTINGS_FILE_SLUG).resolve()
  125. # settings = LazySettings(
  126. # SETTINGS_FILE_FOR_DYNACONF=PATH_DCCSI_TOOLS_IDE_WING.as_posix(),
  127. # INCLUDES_FOR_DYNACONF=[PATH_DCCSI_TOOLS_IDE_WING_LOCAL_SETTINGS.as_posix()]
  128. # )
  129. #
  130. # settings.setenv()
  131. # -------------------------------------------------------------------------