diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp index af58ac4b6b..15bdfa9bf2 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp @@ -1281,6 +1281,8 @@ void OutlinerWidget::OnSearchTextChanged(const QString& activeTextFilter) m_listModel->SearchStringChanged(filterString); m_proxyModel->UpdateFilter(); + + m_gui->m_objectTree->expandAll(); } void OutlinerWidget::OnFilterChanged(const AzQtComponents::SearchTypeFilterList& activeTypeFilters) diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp index e28a289c9e..81ede7a5d3 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp @@ -105,6 +105,8 @@ void ScriptContextDebug::ConnectHook() void ScriptContextDebug::DisconnectHook() { lua_sethook(m_context.NativeContext(), nullptr, 0, 0); + m_currentStackLevel = -1; + m_stepStackLevel = -1; } //========================================================================= @@ -651,6 +653,11 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar) context->PopCallstack(); } context->m_currentStackLevel--; + + if (context->m_currentStackLevel == -1) + { + context->m_stepStackLevel = -1; + } } else if (ar->event == LUA_HOOKLINE) { @@ -731,7 +738,7 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar) //} } - if (doBreak) + if (doBreak && bp->m_lineNumber > 0) { context->m_luaDebug = ar; context->m_breakCallback(context, bp); diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp index a5e0908ac4..f8e254d32d 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp @@ -62,6 +62,7 @@ namespace AZ TimeSystem::TimeSystem() { m_lastInvokedTimeUs = static_cast(AZStd::GetTimeNowMicroSecond()); + m_realLastInvokedTimeUs = static_cast(AZStd::GetTimeNowMicroSecond()); AZ::Interface::Register(this); ITimeRequestBus::Handler::BusConnect(); } @@ -101,7 +102,11 @@ namespace AZ TimeUs TimeSystem::GetRealElapsedTimeUs() const { - return static_cast(AZStd::GetTimeNowMicroSecond()); + const TimeUs currentTime = static_cast(AZStd::GetTimeNowMicroSecond()); + m_realAccumulatedTimeUs += currentTime - m_realLastInvokedTimeUs; + m_realLastInvokedTimeUs = currentTime; + + return m_realAccumulatedTimeUs; } TimeUs TimeSystem::GetSimulationTickDeltaTimeUs() const diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h index ded70c9be5..9d5f2a6d7c 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h @@ -64,6 +64,14 @@ namespace AZ //! Mutable to allow GetElapsedTimeMs/TimeUs() to be a const functions. mutable TimeUs m_accumulatedTimeUs = AZ::Time::ZeroTimeUs; + //! Used to calculate the delta time between calls to GetRealElapsedTimeMs/TimeUs(). + //! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions. + mutable TimeUs m_realLastInvokedTimeUs = AZ::Time::ZeroTimeUs; + + //! Accumulates the delta time of GetRealElapsedTimeMs/TimeUs() calls. + //! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions. + mutable TimeUs m_realAccumulatedTimeUs = AZ::Time::ZeroTimeUs; + //! The current game tick delta time. //! Can be affected by time system cvars. //! Updated in AdvanceTickDeltaTimes(). diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index a3782ae081..2e2014df10 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -14,7 +14,7 @@ #include -AZ_CVAR(bool, ap_tether_lifetime, false, nullptr, AZ::ConsoleFunctorFlags::Null, +AZ_CVAR(bool, ap_tether_lifetime, true, nullptr, AZ::ConsoleFunctorFlags::Null, "If enabled, a parent process that launches the AP will terminate the AP on exit"); namespace AzFramework::AssetSystem::Platform diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 1f056729d7..55961aa703 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -35,9 +37,8 @@ #include #include -#include - #include +#include namespace AzToolsFramework { @@ -662,7 +663,6 @@ namespace AzToolsFramework return; } - // Prevent this from parenting to its own child. Check if this entity is in the new parent's hierarchy. auto potentialParentTransformComponent = GetTransformComponent(parentId); if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) @@ -931,14 +931,27 @@ namespace AzToolsFramework { return AZ::Failure(AZStd::string("You cannot set an entity's parent to itself!")); } - else + + // Don't allow the change if it will result in a cycle hierarchy + auto potentialParentTransformComponent = GetTransformComponent(actualValue); + if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) { - // Don't allow the change if it will result in a cycle hierarchy - auto potentialParentTransformComponent = GetTransformComponent(actualValue); - if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) - { - return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!")); - } + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!")); + } + + // Don't allow read-only entities to be re-parented at all. + // Also don't allow entities to be parented under read-only entities. + if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()) || readOnlyEntityPublicInterface->IsReadOnly(actualValue)) + { + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a read-only entity!")); + } + + // Don't allow entities to be parented under closed containers. + if (auto containerEntityInterface = AZ::Interface::Get(); + !containerEntityInterface->IsContainerOpen(actualValue)) + { + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a closed container!")); } return AZ::Success(); @@ -1245,6 +1258,15 @@ namespace AzToolsFramework void TransformComponent::AddContextMenuActions(QMenu* menu) { + bool parentEntityIsReadOnly = false; + + // If the parent entity is marked as read-only, don't allow actions on this transform. + if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + readOnlyEntityPublicInterface->IsReadOnly(GetEntityId())) + { + parentEntityIsReadOnly = true; + } + if (menu) { if (!menu->actions().empty()) @@ -1266,10 +1288,10 @@ namespace AzToolsFramework AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_Values); }); - resetAction->setEnabled(!m_editorTransform.m_locked); + resetAction->setEnabled(!m_editorTransform.m_locked && !parentEntityIsReadOnly); QString lockString = m_editorTransform.m_locked ? "Unlock transform values" : "Lock transform values"; - menu->addAction(lockString, [this, lockString]() + QAction* lockAction = menu->addAction(lockString, [this, lockString]() { { AzToolsFramework::ScopedUndoBatch undo(lockString.toUtf8().data()); @@ -1278,6 +1300,7 @@ namespace AzToolsFramework } AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues); }); + lockAction->setEnabled(!parentEntityIsReadOnly); } } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp index 1ae406c6fd..0e9681f38b 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp @@ -620,6 +620,7 @@ namespace ImageProcessingAtom { PresetName emptyPreset; + //get file mask of this image file AZStd::string fileMask = GetFileMask(imageFilePath); @@ -636,8 +637,17 @@ namespace ImageProcessingAtom } if (outPreset == emptyPreset) - { - outPreset = m_defaultPreset; + { + auto image = IImageObjectPtr(LoadImageFromFile(imageFilePath)); + if (image->GetAlphaContent() == EAlphaContent::eAlphaContent_Absent + || image->GetAlphaContent() == EAlphaContent::eAlphaContent_OnlyWhite) + { + outPreset = m_defaultPreset; + } + else + { + outPreset = m_defaultPresetAlpha; + } } return outPreset; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp index c44cb39452..5e021a3fdd 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp @@ -74,7 +74,7 @@ namespace ImageProcessingAtom builderDescriptor.m_busId = azrtti_typeid(); builderDescriptor.m_createJobFunction = AZStd::bind(&ImageBuilderWorker::CreateJobs, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); builderDescriptor.m_processJobFunction = AZStd::bind(&ImageBuilderWorker::ProcessJob, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); - builderDescriptor.m_version = 26; // [ATOM-15086] + builderDescriptor.m_version = 27; // [ATOM-16958] builderDescriptor.m_analysisFingerprint = ImageProcessingAtom::BuilderSettingManager::Instance()->GetAnalysisFingerprint(); m_imageBuilder.BusConnect(builderDescriptor.m_busId); AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBusTraits::RegisterBuilderInformation, builderDescriptor); @@ -284,6 +284,10 @@ namespace ImageProcessingAtom return; } + // Full path of the image file + AZStd::string fullPath; + AzFramework::StringFunc::Path::Join(request.m_watchFolder.data(), request.m_sourceFile.data(), fullPath, true, true); + // Get the extension of the file AZStd::string ext; AzFramework::StringFunc::Path::GetExtension(request.m_sourceFile.c_str(), ext, false); @@ -306,13 +310,11 @@ namespace ImageProcessingAtom // add source dependency for .assetinfo file AssetBuilderSDK::SourceFileDependency sourceFileDependency; sourceFileDependency.m_sourceDependencyType = AssetBuilderSDK::SourceFileDependency::SourceFileDependencyType::Absolute; - sourceFileDependency.m_sourceFileDependencyPath = request.m_sourceFile + TextureSettings::ExtensionName; + sourceFileDependency.m_sourceFileDependencyPath = fullPath + TextureSettings::ExtensionName; response.m_sourceFileDependencyList.push_back(sourceFileDependency); // add source dependencies for .preset files - // Get the preset for this file - AZ::IO::FixedMaxPath fullPath(request.m_watchFolder); - fullPath /= request.m_sourceFile; + // Get the preset for this file auto presetName = GetImagePreset(fullPath.c_str()); HandlePresetDependency(presetName, response.m_sourceFileDependencyList); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp index defca690a3..058daf7ca4 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -193,7 +193,7 @@ namespace ImageProcessingAtom } m_image->Get()->Swizzle(swizzle.c_str()); - if (!m_input->m_presetSetting.m_discardAlpha) + if (m_input->m_presetSetting.m_discardAlpha) { m_alphaContent = EAlphaContent::eAlphaContent_Absent; } diff --git a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass index 69c5f48c9c..825a8bad2a 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass @@ -25,7 +25,12 @@ { "Name": "DepthStencilInput", "SlotType": "Input", - "ScopeAttachmentUsage": "DepthStencil" + "ScopeAttachmentUsage": "DepthStencil", + "ImageViewDesc": { + "AspectFlags": [ + "Depth" + ] + } }, { "Name": "Output", diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py index 24fcd08f02..3a6356f4c9 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py @@ -81,10 +81,10 @@ def start(): try: _TAG_LY_BUILD_PATH = os.getenv('TAG_LY_BUILD_PATH', 'build') _DEFAULT_BIN_PATH = Path(str(_O3DE_DEV), _TAG_LY_BUILD_PATH, 'bin', 'profile') - _O3DE_BIN_PATH = Path(os.getenv('O3DE_BIN_PATH', _DEFAULT_BIN_PATH)) - os.environ['O3DE_BIN_PATH'] = _O3DE_BIN_PATH.as_posix() - _LOGGER.debug(f'O3DE_BIN_PATH is: {_O3DE_BIN_PATH}') - site.addsitedir(_O3DE_BIN_PATH.resolve()) + _PATH_O3DE_BIN = Path(os.getenv('PATH_O3DE_BIN', _DEFAULT_BIN_PATH)) + os.environ['PATH_O3DE_BIN'] = _PATH_O3DE_BIN.as_posix() + _LOGGER.debug(f'PATH_O3DE_BIN is: {_PATH_O3DE_BIN}') + site.addsitedir(_PATH_O3DE_BIN.resolve()) except EnvironmentError as e: _LOGGER.error('O3DE bin folder not set or found') raise e @@ -94,10 +94,10 @@ def start(): os.environ['O3DE_DEV'] = _O3DE_DEV.as_posix() _LOGGER.debug(_O3DE_DEV) - _O3DE_BIN_PATH = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) + _PATH_O3DE_BIN = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) - _O3DE_BIN = Path(os.getenv('O3DE_BIN', _O3DE_BIN_PATH.resolve())) - os.environ['O3DE_BIN'] = _O3DE_BIN_PATH.as_posix() + _O3DE_BIN = Path(os.getenv('O3DE_BIN', _PATH_O3DE_BIN.resolve())) + os.environ['O3DE_BIN'] = _PATH_O3DE_BIN.as_posix() _LOGGER.debug(_O3DE_BIN) diff --git a/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp b/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp index 58c2136e2f..ec5220aeeb 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp @@ -56,7 +56,6 @@ namespace AZ { return true; } - AZ_PROFILE_FUNCTION(RHI); ValidateViewContext context; context.m_scopeName = m_scope->GetId().GetCStr(); context.m_srgName = shaderResourceGroup.GetName().GetCStr(); diff --git a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp index 3209a30f1a..5d1da487ab 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -248,8 +248,6 @@ namespace AZ void ShaderResourceGroupPool::CompileGroupsForInterval(Interval interval) { - AZ_PROFILE_SCOPE(RHI, "CompileGroupsForInterval"); - AZ_Assert(m_isCompiling, "You must call CompileGroupsBegin() first!"); AZ_Assert( interval.m_max >= interval.m_min && @@ -259,6 +257,8 @@ namespace AZ for (uint32_t i = interval.m_min; i < interval.m_max; ++i) { ShaderResourceGroup* group = m_groupsToCompile[i]; + AZ_PROFILE_SCOPE(RHI, "CompileGroupsForInterval %s", group->GetName().GetCStr()); + CompileGroupInternal(*group, group->GetData()); group->m_isQueuedForCompile = false; } diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h index 1472cdc80e..da71d669b4 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h @@ -390,7 +390,6 @@ namespace AZ } const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout(); - const RHI::PipelineLayoutDescriptor& pipelineLayoutDescriptor = pipelineLayout.GetPipelineLayoutDescriptor(); // Pull from slot bindings dictated by the pipeline layout. Re-bind anything that has changed // at the flat index level. @@ -499,12 +498,15 @@ namespace AZ } } +#if defined (AZ_RHI_ENABLE_VALIDATION) if (updatePipelineState || updateSRG) { + const RHI::PipelineLayoutDescriptor& pipelineLayoutDescriptor = pipelineLayout.GetPipelineLayoutDescriptor(); m_validator.ValidateShaderResourceGroup( *shaderResourceGroup, pipelineLayoutDescriptor.GetShaderResourceGroupBindingInfo(srgIndex)); } +#endif } return true; } diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h index d27f2403a1..961febf0f4 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h @@ -53,14 +53,12 @@ namespace AtomToolsFramework const AZ::RPI::MaterialTypeSourceData::PropertyDefinition& propertyDefinition, AZ::RPI::MaterialPropertyValue& propertyValue); - //! Generate a file path from the exported file to the external reference. - //! This function returns a relative path from the export file to the reference file. - //! If the relative path is too different or distant from the export path then we return the asset folder relative path. + //! Generate a file path that is relative to either the source asset root or the export path //! @param exportPath absolute path of the file being saved //! @param referencePath absolute path of a file that will be treated as an external reference - //! @param maxPathDepth the maximum relative depth or number of parent or child folders between the export path and the reference path + //! @param relativeToExportPath specifies if the path is relative to the source asset root or the export path AZStd::string GetExteralReferencePath( - const AZStd::string& exportPath, const AZStd::string& referencePath, const uint32_t maxPathDepth = 2); + const AZStd::string& exportPath, const AZStd::string& referencePath, const bool relativeToExportPath = false); //! Traverse up the instance data node hierarchy to find the containing dynamic property object const AtomToolsFramework::DynamicProperty* FindDynamicPropertyForInstanceDataNode(const AzToolsFramework::InstanceDataNode* pNode); diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp index 3a392c1413..3b27c9cd0f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp @@ -24,6 +24,7 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin #include #include #include +#include AZ_POP_DISABLE_WARNING namespace AtomToolsFramework @@ -121,7 +122,6 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::Deactivate() { - AZ::TickBus::Handler::BusDisconnect(); AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); AtomToolsDocumentSystemRequestBus::Handler::BusDisconnect(); m_documentMap.clear(); @@ -160,25 +160,30 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::OnDocumentExternallyModified(const AZ::Uuid& documentId) { m_documentIdsWithExternalChanges.insert(documentId); - if (!AZ::TickBus::Handler::BusIsConnected()) - { - AZ::TickBus::Handler::BusConnect(); - } + QueueReopenDocuments(); } void AtomToolsDocumentSystemComponent::OnDocumentDependencyModified(const AZ::Uuid& documentId) { m_documentIdsWithDependencyChanges.insert(documentId); - if (!AZ::TickBus::Handler::BusIsConnected()) + QueueReopenDocuments(); + } + + void AtomToolsDocumentSystemComponent::QueueReopenDocuments() + { + if (!m_queueReopenDocuments) { - AZ::TickBus::Handler::BusConnect(); + m_queueReopenDocuments = true; + QTimer::singleShot(0, [this] { ReopenDocuments(); }); } } - void AtomToolsDocumentSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + void AtomToolsDocumentSystemComponent::ReopenDocuments() { for (const AZ::Uuid& documentId : m_documentIdsWithExternalChanges) { + m_documentIdsWithDependencyChanges.erase(documentId); + AZStd::string documentPath; AtomToolsDocumentRequestBus::EventResult(documentPath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); @@ -191,8 +196,6 @@ namespace AtomToolsFramework continue; } - m_documentIdsWithDependencyChanges.erase(documentId); - AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); bool openResult = false; @@ -235,7 +238,7 @@ namespace AtomToolsFramework m_documentIdsWithDependencyChanges.clear(); m_documentIdsWithExternalChanges.clear(); - AZ::TickBus::Handler::BusDisconnect(); + m_queueReopenDocuments = false; } AZ::Uuid AtomToolsDocumentSystemComponent::OpenDocument(AZStd::string_view sourcePath) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h index a0f5eb085d..532271974c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h @@ -9,7 +9,6 @@ #pragma once #include -#include #include #include @@ -28,7 +27,6 @@ namespace AtomToolsFramework //! AtomToolsDocumentSystemComponent is the central component of the Material Editor Core gem class AtomToolsDocumentSystemComponent : public AZ::Component - , private AZ::TickBus::Handler , private AtomToolsDocumentNotificationBus::Handler , private AtomToolsDocumentSystemRequestBus::Handler { @@ -59,10 +57,8 @@ namespace AtomToolsFramework void OnDocumentExternallyModified(const AZ::Uuid& documentId) override; ////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// - // AZ::TickBus::Handler overrides... - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - //////////////////////////////////////////////////////////////////////// + void QueueReopenDocuments(); + void ReopenDocuments(); //////////////////////////////////////////////////////////////////////// // AtomToolsDocumentSystemRequestBus::Handler overrides... @@ -87,6 +83,7 @@ namespace AtomToolsFramework AZStd::unordered_map> m_documentMap; AZStd::unordered_set m_documentIdsWithExternalChanges; AZStd::unordered_set m_documentIdsWithDependencyChanges; + bool m_queueReopenDocuments = false; const size_t m_maxMessageBoxLineCount = 15; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp index 3ffd8efa6e..ab72214881 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp @@ -222,31 +222,15 @@ namespace AtomToolsFramework return true; } - AZStd::string GetExteralReferencePath(const AZStd::string& exportPath, const AZStd::string& referencePath, const uint32_t maxPathDepth) + AZStd::string GetExteralReferencePath( + const AZStd::string& exportPath, const AZStd::string& referencePath, const bool relativeToExportPath) { if (referencePath.empty()) { return {}; } - AZ::IO::BasicPath exportFolder(exportPath); - exportFolder.RemoveFilename(); - - const AZStd::string relativePath = AZ::IO::PathView(referencePath).LexicallyRelative(exportFolder).StringAsPosix(); - - // Count the difference in depth between the export file path and the referenced file path. - uint32_t parentFolderCount = 0; - AZStd::string::size_type pos = 0; - const AZStd::string parentFolderToken = ".."; - while ((pos = relativePath.find(parentFolderToken, pos)) != AZStd::string::npos) - { - parentFolderCount++; - pos += parentFolderToken.length(); - } - - // If the difference in depth is too great then revert to using the asset folder relative path. - // We could change this to only use relative paths for references in subfolders. - if (parentFolderCount > maxPathDepth) + if (!relativeToExportPath) { AZStd::string watchFolder; AZ::Data::AssetInfo assetInfo; @@ -260,7 +244,9 @@ namespace AtomToolsFramework } } - return relativePath; + AZ::IO::BasicPath exportFolder(exportPath); + exportFolder.RemoveFilename(); + return AZ::IO::PathView(referencePath).LexicallyRelative(exportFolder).StringAsPosix(); } const AtomToolsFramework::DynamicProperty* FindDynamicPropertyForInstanceDataNode(const AzToolsFramework::InstanceDataNode* pNode) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp index cd50c10e23..b45ff3c12f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp @@ -62,6 +62,8 @@ namespace AtomToolsFramework const QFileInfo initialFileInfo(initialPath); const QString initialExt(initialFileInfo.completeSuffix()); + // Instead of just passing in the absolute file path, we pass in the absolute folder path and the base name to prevent the file + // dialog from displaying multiple extensions when the extension contains a "." const QFileInfo selectedFileInfo(AzQtComponents::FileDialog::GetSaveFileName( QApplication::activeWindow(), "Save File", @@ -82,7 +84,9 @@ namespace AtomToolsFramework return QFileInfo(); } - return selectedFileInfo; + // Reconstructing the file info from the absolute path and expected extension to compensate for an issue with the save file + // dialog adding the extension multiple times if it contains "." like *.lightingpreset.azasset + return QFileInfo(selectedFileInfo.absolutePath() + AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING + selectedFileInfo.baseName() + "." + initialExt); } QFileInfo GetOpenFileInfo(const AZStd::vector& assetTypes) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp index 3124372bd2..bdd166192f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp @@ -66,15 +66,15 @@ namespace UnitTest TEST_F(AtomToolsFrameworkTest, GetExteralReferencePath_Succeeds) { - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/condor.material", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", 2), "../textures/gold.png"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", 0), "textures/gold.png"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 3), "../../../materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 2), "materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 1), "materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 0), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("", "", true), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/condor.material", "", true), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "", false), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", true), "../textures/gold.png"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", false), "textures/gold.png"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", true), "../../../materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); } AZ_UNIT_TEST_HOOK(new AtomToolsFrameworkTestEnvironment); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp index 2d7768feec..97d8d5e354 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp @@ -555,7 +555,7 @@ namespace MaterialEditor void MaterialDocument::SourceFileChanged(AZStd::string relativePath, AZStd::string scanFolder, [[maybe_unused]] AZ::Uuid sourceUUID) { - auto sourcePath = AZ::RPI::AssetUtils::ResolvePathReference(scanFolder, relativePath); + const auto sourcePath = AZ::RPI::AssetUtils::ResolvePathReference(scanFolder, relativePath); if (m_absolutePath == sourcePath) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp index fd20716570..31ca873c48 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp @@ -6,25 +6,21 @@ * */ -#include - -#include -#include - -#include - -#include - +#include #include #include #include - -#include +#include +#include +#include +#include +#include +#include namespace MaterialEditor { CreateMaterialDialog::CreateMaterialDialog(QWidget* parent) - : CreateMaterialDialog(QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials", parent) + : CreateMaterialDialog(QString(AZ::Utils::GetProjectPath().c_str()) + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets", parent) { } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp index d73737a2dc..435d1f6f12 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -106,8 +107,8 @@ namespace MaterialEditor menu->addAction("Create Material...", [entry]() { const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); @@ -182,8 +183,8 @@ namespace MaterialEditor menu->addAction("Create Child Material...", [entry]() { const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp index 5721dfcc72..613762c10a 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp @@ -6,10 +6,11 @@ * */ +#include #include #include #include -#include +#include #include #include #include @@ -346,13 +347,10 @@ namespace MaterialEditor AZStd::string ViewportSettingsInspector::GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const { - AZStd::string savePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@"); - savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR; - savePath += "Materials"; - savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR; - savePath += baseName; - savePath = AtomToolsFramework::GetUniqueFileInfo(savePath.c_str()).absoluteFilePath().toUtf8().constData(); - return savePath; + return AtomToolsFramework::GetUniqueFileInfo( + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + + AZ_CORRECT_FILESYSTEM_SEPARATOR + baseName.c_str()).absoluteFilePath().toUtf8().constData(); } AZ::Crc32 ViewportSettingsInspector::GetGroupSaveStateKey(const AZStd::string& groupName) const diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp index ef6ff4681a..5e4afb68c7 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp @@ -326,6 +326,9 @@ namespace EMStudio Camera::Configuration cameraConfig; cameraConfig.m_fovRadians = AZ::DegToRad(m_renderOptions->GetFOV()); cameraConfig.m_nearClipDistance = m_renderOptions->GetNearClipPlaneDistance(); + cameraConfig.m_farClipDistance = m_renderOptions->GetFarClipPlaneDistance(); + cameraConfig.m_frustumWidth = DefaultFrustumDimension; + cameraConfig.m_frustumHeight = DefaultFrustumDimension; preset->ApplyLightingPreset( iblFeatureProcessor, m_skyboxFeatureProcessor, exposureControlSettingInterface, m_directionalLightFeatureProcessor, diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h index 27e62bb130..10745c6c26 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h @@ -89,6 +89,7 @@ namespace EMStudio AZStd::vector m_actorEntities; const RenderOptions* m_renderOptions; + const float DefaultFrustumDimension = 128.0f; AZStd::vector m_lightHandles; }; } diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp index 0cf6dd70b3..962c9417b7 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp @@ -162,6 +162,7 @@ namespace EMStudio const bool isChecked = settings.value("CameraFollowUp", false).toBool(); m_followCharacterAction->setChecked(isChecked); + AnimViewportRequestBus::Broadcast(&AnimViewportRequestBus::Events::SetFollowCharacter, isChecked); } void AnimViewportToolBar::SaveSettings() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example index 29c1739992..9f881ac3d3 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example @@ -10,12 +10,12 @@ export DYNACONF_COMPANY=Amazon # 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}\..\..\..\.. +export DYNACONF_PATH_O3DE_PROJECT=`pwd` +export DYNACONF_O3DE_DEV=${PATH_O3DE_PROJECT}\..\..\..\.. # LY build folder -export DYNACONF_O3DE_BUILD_PATH=${O3DE_DEV}\build -export DYNACONF_O3DE_BIN_PATH=${O3DE_BUILD_PATH}\bin\profile +export DYNACONF_PATH_O3DE_BUILD=${O3DE_DEV}\build +export DYNACONF_PATH_O3DE_BIN=${PATH_O3DE_BUILD}\bin\profile # default IDE and debug settings #export DYNACONF_DCCSI_GDEBUG=false @@ -24,7 +24,7 @@ export DYNACONF_DCCSI_GDEBUGGER=WING export DYNACONF_DCCSI_LOGLEVEL=20 # defaults for DccScriptingInterface (DCCsi) -export DYNACONF_DCCSIG_PATH=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +export DYNACONF_PATH_DCCSIG=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface # set up default python interpreter (O3DE) # we may want to entirely remove these and rely on config.py to dynamically set up @@ -33,20 +33,20 @@ export DYNACONF_DCCSI_PY_VERSION_MAJOR=3 export DYNACONF_DCCSI_PY_VERSION_MINOR=7 export DYNACONF_DCCSI_PY_VERSION_RELEASE=11 # To Do: probably move the folder below into the /SDK folder? -export DYNACONF_DCCSI_PYTHON_PATH=${DCCSIG_PATH}\3rdParty\Python +export DYNACONF_PATH_DCCSI_PYTHON=${PATH_DCCSIG}\3rdParty\Python # add access to a Lib location that matches the py version (3.7.x) # switch this for other python version like (2.7.x) for Maya -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 +export DYNACONF_PATH_DCCSI_PYTHON_LIB=${PATH_DCCSI_PYTHON}\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_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python -export DYNACONF_DCCSI_PY_BASE=${O3DE_PYTHON_INSTALL}\python.cmd +export DYNACONF_PATH_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python +export DYNACONF_DCCSI_PY_BASE=${PATH_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=${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 +#export DYNACONF_QT_PLUGIN_PATH=${PATH_O3DE_BUILD}\bin\profile\EditorPlugins +#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${PATH_O3DE_BUILD}\bin\profile\EditorPlugins\platforms diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt index 7f5a72fb1c..8146fc0020 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt @@ -33,4 +33,11 @@ pyside2-tools instructions: 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 +See: "< local DCCsi >\config.py" + +Substance Automation Toolkit (SAT) Instructions: +Substance has a licensed python API for automating material data workflows. By default, their instructions cover installing it to a python 'system interpreter', however if we want to install it for use within the DCCsi (for custom tools) or even potentially to build inter-op and integrations with O3DE editors, we want to install it in a way that is accessible. + +Install Substance Automation Toolkit 3rd party library to DCCsi 3rdParty sandbox: + +> C:\Depot\o3de\python> pip install "c:\< path to >\SubstanceAutomationToolkit\Python API\Pysbs-2021.2.2-py2.py3-none-win_amd64.whl" --target="C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\3.x\3.7.x\site-packages" \ 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 406e2b04ff..6a4dbb2906 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py @@ -14,74 +14,88 @@ 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: SPEC-2581""" + +# test bootstrap execution time +import time +_START = time.process_time() # start tracking + # standard imports import sys import os import site -import importlib.util from pathlib import Path import logging as _logging # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -_O3DE_RUNNING=None -try: - import azlmbr - _O3DE_RUNNING=True -except: - _O3DE_RUNNING=False -# ------------------------------------------------------------------------- +_MODULENAME = 'O3DE.DCCsi.bootstrap' - -# ------------------------------------------------------------------------- # we don't use dynaconf setting here as we might not yet have access -# to that site-dir. - -_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? -_DCCSI_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..')) -_DCCSI_PATH = os.getenv('DCCSI_PATH', _DCCSI_PATH) -site.addsitedir(_DCCSI_PATH) +_PATH_DCCSIG = Path(os.path.join(_MODULE_PATH, '../../..')) +site.addsitedir(_PATH_DCCSIG) +# set envar so DCCsi synthetic env bootstraps with it (config.py) +from azpy.constants import ENVAR_PATH_DCCSIG +os.environ[ENVAR_PATH_DCCSIG] = str(_PATH_DCCSIG.resolve()) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- # 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 ENVAR_DCCSI_GDEBUGGER from azpy.constants import FRMT_LOG_LONG -# set up global space, logging etc. -# set these true if you want them set globally for debugging +from azpy.env_bool import env_bool _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))) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') + +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + +# set up module logging +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') -_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +_LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def attach_debugger(): + from azpy.test.entry_test import connect_wing + _debugger = connect_wing() + return _debugger +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # _settings.setenv() # doing this will add the additional DYNACONF_ envars -def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH): +import importlib.util +def get_dccsi_config(PATH_DCCSIG=_PATH_DCCSIG): """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(DCCSI_PATH, + Path(PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -89,114 +103,205 @@ def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH): return _dccsi_config # ------------------------------------------------------------------------- -# set and retreive the base env context/_settings on import -_config = get_dccsi_config() -_settings = _config.get_config_settings() +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_Editor(test_config=_DCCSI_GDEBUG, + test_pyside2=_DCCSI_GDEBUG): + '''Put boostrapping code here to execute in O3DE Editor.exe''' + + _settings = None + + if test_config: + # set and retreive the base env context/_settings on import + _config = get_dccsi_config() + _settings = _config.get_config_settings(enable_o3de_python=True, + enable_o3de_pyside2=True) + # note: this can impact start up times so currently we are only + # running it to test. + # To Do: slim down start up times so we can init _settings + + if test_pyside2: + _config.test_pyside2() + + return _settings +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_MaterialEditor(): + '''Put boostrapping code here to execute in O3DE MaterialEdito.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_AssetProcessor(): + '''Put boostrapping code here to execute in O3DE AssetProcessor.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_AssetBuilder(): + '''Put boostrapping code here to execute in O3DE AssetBuilder.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- if _DCCSI_DEV_MODE: - _config.attach_debugger() # attempts to start debugger -# done with basic setup -# --- END ----------------------------------------------------------------- + foo = attach_debugger() # attempts to start debugger + +# set and retreive the *basic* env context/_settings on import +# What application is executing the bootstrap? +# Python is being run from: +# editor.exe +# materialeditor.exe +# assetprocessor.exe +# assetbuilder.exe, or the Python executable. +# Exclude the .exe so it works on other platforms + +_O3DE_Editor = Path(sys.executable) +_LOGGER.debug(f'The sys.executable is: {_O3DE_Editor}') + +if _O3DE_Editor.stem.lower() == "editor": + # if _DCCSI_GDEBUG then run the pyside2 test + _settings = bootstrap_Editor(_DCCSI_GDEBUG) + +elif _O3DE_Editor.stem.lower() == "materialeditor": + _settings = bootstrap_MaterialEditor() + +elif _O3DE_Editor.stem.lower() == "assetprocessor": + _settings = bootstrap_AssetProcessor() + +elif _O3DE_Editor.stem.lower() == "assetbuilder": + _settings= bootstrap_AssetBuilder() + +elif _O3DE_Editor.stem.lower() == "python": + # in this case, we can re-use the editor settings + # which will init python and pyside2 access externally + _settings= bootstrap_Editor(_DCCSI_GDEBUG) + +else: + _LOGGER.warning('No bootstrapping code for: {_O3DE_Editor}') +# ------------------------------------------------------------------------- ########################################################################### # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - """Run this file as main""" + """Run this file as main (external commandline for testing)""" + # --------------------------------------------------------------------- + # force enable debug settings manually + _DCCSI_GDEBUG = False # enable here to force temporarily + _DCCSI_DEV_MODE = False + if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + # --------------------------------------------------------------------- + - # ------------------------------------------------------------------------- + # --------------------------------------------------------------------- _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 - - # 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(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 + # --------------------------------------------------------------------- + + + # --------------------------------------------------------------------- + # this is a simple commandline interface for running and testing externally + if not _O3DE_RUNNING: # external tool or commandline + + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi Boostrap (Test)', + epilog="Will externally test the DCCsi boostrap") + + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') - 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'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}') + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') - _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 _DCCSI_GDEBUG or args.test_pyside2: - try: - import PySide2 - except: - # set up Qt/PySide2 access and test - _settings = _config.get_config_settings(enable_o3de_pyside2=True) - import PySide2 - - _LOGGER.info(f'PySide2: {PySide2}') - _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}') + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') - _config.test_pyside2() - - if not _O3DE_RUNNING: - # return - sys.exit() + 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 + _DCCSI_LOGLEVEL = _logging.DEBUG + _LOGGER.setLevel(_DCCSI_LOGLEVEL) + + if args.set_debugger: + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') + # To Do: implement debugger plugin pattern + + if args.developer_mode or _DCCSI_DEV_MODE: + _DCCSI_DEV_MODE = True + foo = attach_debugger() # attempts to start debugger + + # happy print + from azpy.constants import STR_CROSSBAR + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('~ DCCsi: bootstrap.py ... Running script as __main__') + _LOGGER.info(STR_CROSSBAR) + + _TEST_PYSIDE2 = False + if args.test_pyside2: + _TEST_PYSIDE2 = True + + _settings= bootstrap_Editor(_DCCSI_GDEBUG, _TEST_PYSIDE2) + + if _DCCSI_GDEBUG: + _LOGGER.info(f'PATH_DCCSIG: {_settings.PATH_DCCSIG}') + _LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}') + _LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}') + + _LOGGER.info(f'DCCSI_OS_FOLDER: {_settings.DCCSI_OS_FOLDER}') + _LOGGER.info(f'O3DE_PROJECT: {_settings.O3DE_PROJECT}') + _LOGGER.info(f'PATH_O3DE_PROJECT: {_settings.PATH_O3DE_PROJECT}') + _LOGGER.info(f'O3DE_DEV: {_settings.O3DE_DEV}') + _LOGGER.info(f'PATH_O3DE_BUILD: {_settings.PATH_O3DE_BUILD}') + _LOGGER.info(f'PATH_O3DE_BIN: {_settings.PATH_O3DE_BIN}') + + _LOGGER.info(f'PATH_DCCSIG: {_settings.PATH_DCCSIG}') + _LOGGER.info(f'PATH_DCCSI_PYTHON_LIB: {_settings.PATH_DCCSI_PYTHON_LIB}') + _LOGGER.info(f'DCCSI_PY_BASE: {_settings.DCCSI_PY_BASE}') + + if args.test_pyside2: + _LOGGER.info(f'PySide2: {PySide2}') + _LOGGER.info(f'PATH_O3DE_BIN: {_settings.PATH_O3DE_BIN}') + _LOGGER.info(f'QT_PLUGIN_PATH: {_settings.QT_PLUGIN_PATH}') + _LOGGER.info(f'QT_QPA_PLATFORM_PLUGIN_PATH: {_settings.QT_QPA_PLATFORM_PLUGIN_PATH}') + # --------------------------------------------------------------------- + + # custom prompt + sys.ps1 = "[azpy]>>" + +_LOGGER.debug('~ DCCsi: bootstrap.py took: {} sec'.format(time.process_time() - _START)) # --- END ----------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py index 3ed4040550..cff4ba0b33 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py @@ -118,7 +118,7 @@ def clicked_launch_sub_builder(): print(debug_msg) _LOGGER.debug(debug_msg) - _SUB_BUILDER_PATH = Path(settings.DCCSIG_PATH, + _SUB_BUILDER_PATH = Path(settings.PATH_DCCSIG, 'SDK', 'Substance', 'builder') 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 d0e9759208..198dcdb5af 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 @@ -34,7 +34,7 @@ print(_config) # this is an alternative to "from dynaconf import settings" with Qt settings = _config.get_config_settings(setup_ly_pyside=True) -# app_path = Path.joinpath(settings.DCCSIG_PATH, < relative path to current script dir >).resolve() +# app_path = Path.joinpath(settings.PATH_DCCSIG, < relative path to current script dir >).resolve() # 3rd Party (we may or do provide) from box import Box @@ -507,7 +507,7 @@ class FBXConverter(QtWidgets.QDialog): _LOGGER.debug('get_material_definition, os.getcwd() is: {}'.format(os.getcwd())) # build a resolved absolute path because cwd may be unknown and change running externally - material_file = Path(settings.DCCSIG_PATH, + material_file = Path(settings.PATH_DCCSIG, 'SDK', 'Maya', 'Scripts', 'Python', 'kitbash_converter', material_file).resolve() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py index b940a0eac8..5db297755a 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py @@ -18,14 +18,14 @@ import site _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) +_PATH_DCCSIG = os.path.join(_MODULE_PATH, _DCCSIG_REL_PATH) +_PATH_DCCSIG = os.path.normpath(_PATH_DCCSIG) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', - os.path.abspath(_DCCSIG_PATH)) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', + os.path.abspath(_PATH_DCCSIG)) # we don't have access yet to the DCCsi Lib\site-packages -site.addsitedir(_DCCSIG_PATH) # PYTHONPATH +site.addsitedir(_PATH_DCCSIG) # PYTHONPATH # azpy bootstrapping and extensions import azpy.config_utils diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py index 04eb027142..ad8bc9f1a6 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py @@ -135,14 +135,14 @@ if _DCCSI_DEV_MODE: # ------------------------------------------------------------------------- # 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 +from azpy.constants import PATH_DCCSI_PYTHON_LIB 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)) + os.path.exists(PATH_DCCSI_PYTHON_LIB) + site.addsitedir(PATH_DCCSI_PYTHON_LIB) + _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB)) except Exception as e: - _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB_PATH)) + _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB)) raise e # 3rdparty @@ -175,15 +175,15 @@ try: except Exception as e: _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_SDK_PATH])) -_O3DE_PROJECT_PATH = None +_PATH_O3DE_PROJECT = None try: - _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT])) # 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_PATH_DCCSIG = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] _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 - #_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] - _project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE) + #_PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] + _project_workspace = os.path.join(_PATH_O3DE_PROJECT, TAG_MAYA_WORKSPACE) if os.path.isfile(_project_workspace): try: # load workspace - maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, openWorkspace=True) _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) - maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, update=True) except Exception as e: _LOGGER.error(e) else: - _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.warning('Workspace file not found: {1}'.format(_PATH_O3DE_PROJECT)) # Set up Lumberyard, maya default setting from set_defaults import set_defaults diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py index f3e91b59ce..2b735c3630 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py @@ -19,10 +19,10 @@ import importlib.util # if running in py2.7 we won't have access to pathlib yet until we boostrap # 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) -# print(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../../../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) +# print(_PATH_DCCSIG) # Lumberyard DCCsi site extensions from pathlib import Path @@ -46,7 +46,7 @@ _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('_PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('_G_DEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) @@ -59,7 +59,7 @@ if _DCCSI_DEV_MODE: # 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, + Path(_PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -96,16 +96,16 @@ from azpy.constants import ENVAR_O3DE_DEV _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, settings.O3DE_DEV)).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_PATH_O3DE_PROJECT +_PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, + settings.PATH_O3DE_PROJECT)).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(_O3DE_PROJECT_PATH, 'Assets').resolve() +_PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, 'Assets').resolve() _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() # ------------------------------------------------------------------------- @@ -117,7 +117,7 @@ if __name__ == "__main__": """Run this file as main""" _LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV)) - _LOGGER.info('_O3DE_PROJECT_PATH: {}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.info('_PATH_O3DE_PROJECT: {}'.format(_PATH_O3DE_PROJECT)) _LOGGER.info('_DCCSI_SDK_PATH: {}'.format(_DCCSI_SDK_PATH)) _LOGGER.info('_PYSBS_DIR_PATH: {}'.format(_PYSBS_DIR_PATH)) 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 9408b94919..688fd65e9e 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 @@ -76,7 +76,7 @@ settings.setenv() # for standalone # log debug info about Qt/PySide2 _LOGGER.debug('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) -_LOGGER.debug('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH)) +_LOGGER.debug('PATH_O3DE_BIN: {}'.format(settings.PATH_O3DE_BIN)) _LOGGER.debug('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) _LOGGER.debug('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) # ------------------------------------------------------------------------- @@ -129,15 +129,15 @@ _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, None)).resolve() from azpy.constants import ENVAR_O3DE_PROJECT _O3DE_PROJECT = os.getenv(ENVAR_O3DE_PROJECT, None) -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_PATH_O3DE_PROJECT +_PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, 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(_O3DE_PROJECT_PATH).resolve() -_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Materials').resolve() +_PROJECT_ASSET_PATH = Path(_PATH_O3DE_PROJECT).resolve() +_PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, 'Materials').resolve() # To Do: figure out a proper way to deal with Lumberyard game projects _GEM_MATPLAY_PATH = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve() @@ -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(_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() +_TEX_RNDR_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() +_MAT_OUTPUT_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() +_SBSAR_COOK_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() # ------------------------------------------------------------------------- @@ -171,12 +171,12 @@ 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(_O3DE_PROJECT_PATH) + self.project_path = str(_PATH_O3DE_PROJECT) else: self.project_path = Path(project_path) if default_material_path is None: - self._default_material_path = Path(_DCCSIG_PATH, + self._default_material_path = Path(_PATH_DCCSIG, 'sdk', 'substance', 'resources', @@ -672,7 +672,7 @@ 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 - #_O3DE_PROJECT_PATH + #_PATH_O3DE_PROJECT texture_output_path = Path(self.texRenderPathComboBox.currentText()).resolve() rel_tex_path = None @@ -928,7 +928,7 @@ def substance_builder_launcher(): _LOGGER.info('file: {}'.format(__file__)) # *might* come back relative # we should ensure we know the abs path - qss_filepath = Path(_DCCSIG_PATH).resolve().absolute() + qss_filepath = Path(_PATH_DCCSIG).resolve().absolute() qss_filepath = Path(qss_filepath, 'SDK', 'substance', 'builder', 'ui', 'stylesheets', 'LYstyle.qss').resolve().absolute() window.setStyleSheet(qss_filepath.read_text()) 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 441110b8d4..e091849d23 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 @@ -67,11 +67,11 @@ from collections import OrderedDict _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] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, '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 9652b8990a..be1dbbe165 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py @@ -87,11 +87,11 @@ from collections import OrderedDict _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] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, '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 6285ea0335..a19343dc99 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py @@ -65,11 +65,11 @@ from collections import OrderedDict _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] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, '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 8ffdf30e35..bfcc65b676 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py @@ -189,16 +189,16 @@ if __name__ == "__main__": from azpy import synthetic_env _SYNTH_ENV_DICT = synthetic_env.stash_env() - from azpy.constants import ENVAR_DCCSIG_PATH - from azpy.constants import ENVAR_O3DE_PROJECT_PATH + from azpy.constants import ENVAR_PATH_DCCSIG + from azpy.constants import ENVAR_PATH_O3DE_PROJECT # grab a specific path from the base_env - _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] + _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] # use DCCsi as the project path for this test - _O3DE_PROJECT_PATH = _PATH_DCCSI + _PATH_O3DE_PROJECT = _PATH_DCCSI - _PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve() + _PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, '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 0407a1db08..cea6522e83 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py @@ -66,11 +66,11 @@ from collections import OrderedDict _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] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, '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 35c970e711..51beb48f3b 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py @@ -17,9 +17,9 @@ import time # ------------------------------------------------------------------------- # we don't have access yet to the DCCsi Lib\site-packages # (1) this will give us import access to dccsi and azpy import -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', os.getcwd()) # always?, doubtful +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', os.getcwd()) # always?, doubtful # ^^ this assume that the \DccScriptingInterface is the cwd!!! (launch there) -site.addsitedir(_DCCSIG_PATH) +site.addsitedir(_PATH_DCCSIG) # Lumberyard extensions from azpy.env_bool import env_bool @@ -72,7 +72,7 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) _O3DE_DEV = _SYNTH_ENV_DICT[ENVAR_O3DE_DEV] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # ------------------------------------------------------------------------- @@ -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(_O3DE_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm() + self.outputRenderPath = Path(_PATH_O3DE_PROJECT, '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/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py index c68eb8d256..b08e79df2e 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py @@ -137,14 +137,14 @@ if _DCCSI_DEV_MODE: # ------------------------------------------------------------------------- # 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 +from azpy.constants import PATH_DCCSI_PYTHON_LIB 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)) + os.path.exists(PATH_DCCSI_PYTHON_LIB) + site.addsitedir(PATH_DCCSI_PYTHON_LIB) + _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB)) except Exception as e: - _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB_PATH)) + _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB)) raise e # 3rdparty @@ -171,22 +171,22 @@ _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 +_PATH_DCCSI_TOOLS = None # To Do: needs to be updated to use dynaconf and config.py try: - _DCCSI_TOOLS_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH] + _PATH_DCCSI_TOOLS = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS])) -_O3DE_PROJECT_PATH = None +_PATH_O3DE_PROJECT = None try: - _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT])) # 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_PATH_DCCSIG = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] _O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] _O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] # ------------------------------------------------------------------------- @@ -216,8 +216,8 @@ def startup(): # get known paths _KNOWN_PATHS = site._init_pathinfo() - if os.path.isdir(_DCCSI_TOOLS_PATH): - site.addsitedir(_DCCSI_TOOLS_PATH, _KNOWN_PATHS) + if os.path.isdir(_PATH_DCCSI_TOOLS): + site.addsitedir(_PATH_DCCSI_TOOLS, _KNOWN_PATHS) try: import azpy.test _LOGGER.info('SUCCESS, import azpy.test') @@ -273,18 +273,18 @@ def post_startup(): 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) + #_PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] + _project_workspace = os.path.join(_PATH_O3DE_PROJECT, TAG_MAYA_WORKSPACE) if os.path.isfile(_project_workspace): try: # load workspace - maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, openWorkspace=True) _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) - maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, update=True) except Exception as e: _LOGGER.error(e) else: - _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.warning('Workspace file not found: {1}'.format(_PATH_O3DE_PROJECT)) # Set up Lumberyard, maya default setting from set_defaults import set_defaults diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat similarity index 91% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat index ee2ea5bf1f..230962a4e4 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat @@ -14,15 +14,18 @@ PUSHD %~dp0 SETLOCAL ENABLEDELAYEDEXPANSION +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Default Maya and Python version set MAYA_VERSION=2020 set DCCSI_PY_VERSION_MAJOR=2 set DCCSI_PY_VERSION_MINOR=7 set DCCSI_PY_VERSION_RELEASE=11 -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -32,9 +35,6 @@ set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%Launch_mayaPy_2020.bat echo DCCSI_PY_DCCSI = %DCCSI_PY_DCCSI% -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - echo. echo _____________________________________________________________________ echo. @@ -50,7 +50,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: 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/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat new file mode 100644 index 0000000000..2ab189fb87 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat @@ -0,0 +1,73 @@ +@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 + +:: Store current dir +%~d0 +cd %~dp0 +PUSHD %~dp0 + +SETLOCAL ENABLEDELAYEDEXPANSION + +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Default Maya and Python version +set MAYA_VERSION=2022 +set DCCSI_PY_VERSION_MAJOR=3 +set DCCSI_PY_VERSION_MINOR=7 +set DCCSI_PY_VERSION_RELEASE=7 + +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat + +:: ide and debugger plug +set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% + +:: Default BASE DCCsi python 3.7 location +:: Can be overridden (example, Launch_mayaPy_%MAYA_VERSION%.bat :: MayaPy.exe) +set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%Launch_mayaPy_%MAYA_VERSION%.bat +echo DCCSI_PY_DCCSI = %DCCSI_PY_DCCSI% + +echo. +echo _____________________________________________________________________ +echo. +echo Launching Maya %MAYA_VERSION% for O3DE DCCsi... +echo _____________________________________________________________________ +echo. + +echo MAYA_VERSION = %MAYA_VERSION% +echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% +echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% +echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% +echo MAYA_LOCATION = %MAYA_LOCATION% +echo MAYA_BIN_PATH = %MAYA_BIN_PATH% + +:: Change to root dir +CD /D %PATH_O3DE_PROJECT% + +:: Default to the right version of Maya if we can detect it... and launch +IF EXIST "%MAYA_BIN_PATH%\maya.exe" ( + start "" "%MAYA_BIN_PATH%\maya.exe" %* +) ELSE ( + Where maya.exe 2> NUL + IF ERRORLEVEL 1 ( + echo Maya.exe could not be found + pause + ) ELSE ( + start "" Maya.exe %* + ) +) + +::ENDLOCAL + +:: Restore previous directory +POPD + +:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat similarity index 87% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat index 33b8bc6392..cb947a9b6c 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat @@ -17,18 +17,18 @@ COLOR 8E cd %~dp0 PUSHD %~dp0 +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Default Maya and Python version set MAYA_VERSION=2020 set DCCSI_PY_VERSION_MAJOR=2 set DCCSI_PY_VERSION_MINOR=7 set DCCSI_PY_VERSION_RELEASE=11 -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Maya.bat - -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -48,7 +48,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% SETLOCAL ENABLEDELAYEDEXPANSION @@ -58,10 +58,10 @@ IF EXIST "%DCCSI_PY_MAYA%" ( ) ELSE ( Where maya.exe 2> NUL IF ERRORLEVEL 1 ( - echo Maya.exe could not be found + echo MayaPy.exe could not be found pause ) ELSE ( - start "" Maya.exe %* + start "" MayaPy.exe %* ) ) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat new file mode 100644 index 0000000000..91b1750a3c --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat @@ -0,0 +1,73 @@ +@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 window +TITLE O3DE DCCsi Launch MayaPy +:: Use obvious color to prevent confusion (Grey with Yellow Text) +COLOR 8E + +:: Store current directory and change to environment directory so script works in any path. +%~d0 +cd %~dp0 +PUSHD %~dp0 + +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Default Maya and Python version +set MAYA_VERSION=2022 +set DCCSI_PY_VERSION_MAJOR=3 +set DCCSI_PY_VERSION_MINOR=7 +set DCCSI_PY_VERSION_RELEASE=7 + +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat + +:: ide and debugger plug +set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% + +echo. +echo _____________________________________________________________________ +echo. +echo ~ Launching O3DE DCCsi MayaPy (%MAYA_VERSION%) ... +echo ________________________________________________________________ +echo. + +echo MAYA_VERSION = %MAYA_VERSION% +echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% +echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% +echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% +echo MAYA_LOCATION = %MAYA_LOCATION% +echo MAYA_BIN_PATH = %MAYA_BIN_PATH% + +:: Change to root dir +CD /D %PATH_O3DE_PROJECT% + +SETLOCAL ENABLEDELAYEDEXPANSION + +:: Default to the right version of Maya if we can detect it... and launch +IF EXIST "%DCCSI_PY_MAYA%" ( + start "" "%DCCSI_PY_MAYA%" %* +) ELSE ( + Where maya.exe 2> NUL + IF ERRORLEVEL 1 ( + echo MayaPy.exe could not be found + pause + ) ELSE ( + start "" MayaPy.exe %* + ) +) + +ENDLOCAL + +:: Return to starting directory +POPD + +:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat index b37170d605..a124c100b0 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat @@ -74,8 +74,8 @@ echo O3DE_PROJECT = %O3DE_PROJECT% :: if not set we also use the DCCsi path as stand-in 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 "%PATH_O3DE_PROJECT%"=="" (set PATH_O3DE_PROJECT=%CD%) +echo PATH_O3DE_PROJECT = %PATH_O3DE_PROJECT% IF "%ABS_PATH%"=="" (set ABS_PATH=%CD%) echo ABS_PATH = %ABS_PATH% @@ -84,7 +84,7 @@ echo ABS_PATH = %ABS_PATH% pushd %ABS_PATH% :: Change to root Lumberyard dev dir -CD /d %O3DE_PROJECT_PATH%\%O3DE_REL_PATH% +CD /d %PATH_O3DE_PROJECT%\%O3DE_REL_PATH% IF "%O3DE_DEV%"=="" (set O3DE_DEV=%CD%) echo O3DE_DEV = %O3DE_DEV% :: Restore original directory @@ -92,32 +92,32 @@ popd :: dcc scripting interface gem path :: currently know relative path to this gem -set DCCSIG_PATH=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface -echo DCCSIG_PATH = %DCCSIG_PATH% +set PATH_DCCSIG=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +echo PATH_DCCSIG = %PATH_DCCSIG% :: Change to DCCsi root dir -CD /D %DCCSIG_PATH% +CD /D %PATH_DCCSIG% :: per-dcc sdk path -set DCCSI_TOOLS_PATH=%DCCSIG_PATH%\Tools -echo DCCSI_TOOLS_PATH = %DCCSI_TOOLS_PATH% +set PATH_DCCSI_TOOLS=%PATH_DCCSIG%\Tools +echo PATH_DCCSI_TOOLS = %PATH_DCCSI_TOOLS% :: temp log location specific to this gem -set DCCSI_LOG_PATH=%O3DE_PROJECT_PATH%\.temp\logs +set DCCSI_LOG_PATH=%PATH_O3DE_PROJECT%\.temp\logs echo DCCSI_LOG_PATH = %DCCSI_LOG_PATH% :: O3DE 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 "%PATH_O3DE_BUILD%"=="" (set PATH_O3DE_BUILD=%O3DE_DEV%\%O3DE_BUILD_FOLDER%) +echo PATH_O3DE_BUILD = %PATH_O3DE_BUILD% -IF "%O3DE_BIN_PATH%"=="" (set O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile) -echo O3DE_BIN_PATH = %O3DE_BIN_PATH% +IF "%PATH_O3DE_BIN%"=="" (set PATH_O3DE_BIN=%PATH_O3DE_BUILD%\bin\profile) +echo PATH_O3DE_BIN = %PATH_O3DE_BIN% :: add to the PATH -SET PATH=%O3DE_BIN_PATH%;%DCCSIG_PATH%;%PATH% +SET PATH=%PATH_O3DE_BIN%;%PATH_DCCSIG%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example new file mode 100644 index 0000000000..ad1e429967 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example @@ -0,0 +1,20 @@ +@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 DCCSI_CUSTOM=Foo +echo DCCSI_CUSTOM = %DCCSI_CUSTOM% + +set O3DE_BUILD_FOLDER=custom_build +echo O3DE_BUILD_FOLDER = %O3DE_BUILD_FOLDER% + +set DCCSI_GDEBUG=True +set DCCSI_DEV_MODE=True +set DCCSI_GDEBUGGER=WING +set DCCSI_LOGLEVEL=10 \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat index 0ed46e9400..9bed3b301b 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat @@ -22,12 +22,13 @@ IF "%DCCSI_ENV_MAYA_INIT%"=="1" GOTO :END_OF_FILE cd %~dp0 PUSHD %~dp0 -IF "%DCCSI_PY_VERSION_MAJOR%"=="" (set DCCSI_PY_VERSION_MAJOR=2) +:: Maya 2022: 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] +IF "%DCCSI_PY_VERSION_MAJOR%"=="" (set DCCSI_PY_VERSION_MAJOR=3) IF "%DCCSI_PY_VERSION_MINOR%"=="" (set DCCSI_PY_VERSION_MINOR=7) -IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=11) +IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=7) :: Default Maya Version -IF "%DCCSI_MAYA_VERSION%"=="" (set DCCSI_MAYA_VERSION=2020) +IF "%MAYA_VERSION%"=="" (set MAYA_VERSION=2022) :: Initialize env CALL %~dp0\Env_Core.bat @@ -43,14 +44,14 @@ echo. echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% -echo DCCSI_MAYA_VERSION = %DCCSI_MAYA_VERSION% +echo MAYA_VERSION = %MAYA_VERSION% :::: Set Maya native project acess to this project -IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%O3DE_PROJECT_PATH%) +IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%PATH_O3DE_PROJECT%) echo MAYA_PROJECT = %MAYA_PROJECT% :: maya sdk path -set DCCSI_TOOLS_MAYA_PATH=%DCCSI_TOOLS_PATH%\DCC\Maya +set DCCSI_TOOLS_MAYA_PATH=%PATH_DCCSI_TOOLS%\DCC\Maya echo DCCSI_TOOLS_MAYA_PATH = %DCCSI_TOOLS_MAYA_PATH% set MAYA_MODULE_PATH=%DCCSI_TOOLS_MAYA_PATH%;%MAYA_MODULE_PATH% @@ -59,7 +60,7 @@ echo MAYA_MODULE_PATH = %MAYA_MODULE_PATH% :: Maya File Paths, etc :: https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html :::: Set Maya native project acess to this project -IF "%MAYA_LOCATION%"=="" (set MAYA_LOCATION=%ProgramFiles%\Autodesk\Maya%DCCSI_MAYA_VERSION%) +IF "%MAYA_LOCATION%"=="" (set MAYA_LOCATION=%ProgramFiles%\Autodesk\Maya%MAYA_VERSION%) echo MAYA_LOCATION = %MAYA_LOCATION% IF "%MAYA_BIN_PATH%"=="" (set MAYA_BIN_PATH=%MAYA_LOCATION%\bin) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat index 7be9154e6d..fbcc59d5d0 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat @@ -17,30 +17,32 @@ IF "%DCCSI_ENV_PYCHARM_INIT%"=="1" GOTO :END_OF_FILE cd %~dp0 PUSHD %~dp0 +:: version Year +IF "%PYCHARM_VERSION_YEAR%"=="" (set PYCHARM_VERSION_YEAR=2020) :: version Major -SET PYCHARM_VERSION_YEAR=2020 -:: version Major -SET PYCHARM_VERSION_MAJOR=2 +IF "%PYCHARM_VERSION_MAJOR%"=="" (set PYCHARM_VERSION_MAJOR=3) +:: version Minor +IF "%PYCHARM_VERSION_MINOR%"=="" (set PYCHARM_VERSION_MINOR=2) + +:: PyCharm install paths look something like the following and has changed from release to release ::"C:\Program Files\JetBrains\PyCharm 2019.1.3\bin" +::"C:\Program Files\JetBrains\PyCharm 2020.3.2\bin" <-- this is mine @HogJonnyAMZN ::"C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.5\bin\pycharm64.exe" +:: The version of PyCharm can be updated without altering the install path +:: You can set the envar to your local install path in the Env_Dev.bat file to override +:: C:< o3de install location >\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Tools\Dev\Windows\Env_Dev.bat" + :: put project env variables/paths here -set PYCHARM_HOME=%PROGRAMFILES%\JetBrains\PyCharm %PYCHARM_VERSION_YEAR%.%PYCHARM_VERSION_MAJOR% +IF "%PYCHARM_HOME%"=="" (set PYCHARM_HOME=%PROGRAMFILES%\JetBrains\PyCharm %PYCHARM_VERSION_YEAR%.%PYCHARM_VERSION_MAJOR%.%PYCHARM_VERSION_MINOR%) :: Initialize env 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 = %O3DE_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 - -SET PYCHARM_PROJ=%DCCSIG_PATH%\Solutions +IF "%PYCHARM_PROJ%"=="" (SET PYCHARM_PROJ=%PATH_DCCSIG%\Tools\Dev\Windows\Solutions) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat index 388ab531df..92030f9d61 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat @@ -42,39 +42,39 @@ echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% :: shared location for 64bit python 3.7 DEV location :: this defines a DCCsi sandbox for lib site-packages by version :: \Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib -set DCCSI_PYTHON_PATH=%DCCSIG_PATH%\3rdParty\Python -echo DCCSI_PYTHON_PATH = %DCCSI_PYTHON_PATH% +set PATH_DCCSI_PYTHON=%PATH_DCCSIG%\3rdParty\Python +echo PATH_DCCSI_PYTHON = %PATH_DCCSI_PYTHON% :: add access to a Lib location that matches the py version (example: 3.7.x) :: switch this for other python versions like maya (2.7.x) -IF "%DCCSI_PYTHON_LIB_PATH%"=="" (set DCCSI_PYTHON_LIB_PATH=%DCCSI_PYTHON_PATH%\Lib\%DCCSI_PY_VERSION_MAJOR%.x\%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.x\site-packages) -echo DCCSI_PYTHON_LIB_PATH = %DCCSI_PYTHON_LIB_PATH% +IF "%PATH_DCCSI_PYTHON_LIB%"=="" (set PATH_DCCSI_PYTHON_LIB=%PATH_DCCSI_PYTHON%\Lib\%DCCSI_PY_VERSION_MAJOR%.x\%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.x\site-packages) +echo PATH_DCCSI_PYTHON_LIB = %PATH_DCCSI_PYTHON_LIB% :: add to the PATH -SET PATH=%DCCSI_PYTHON_LIB_PATH%;%PATH% +SET PATH=%PATH_DCCSI_PYTHON_LIB%;%PATH% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% :: location for O3DE python 3.7 location :: 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 +set DCCSI_PY_BASE=%PATH_O3DE_PYTHON_INSTALL%\python.cmd echo DCCSI_PY_BASE = %DCCSI_PY_BASE% -CALL %O3DE_PYTHON_INSTALL%\get_python_path.bat +CALL %PATH_O3DE_PYTHON_INSTALL%\get_python_path.bat :: 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% :: add to the PATH -SET PATH=%O3DE_PYTHON_INSTALL%;%O3DE_PYTHONHOME%;%DCCSI_PY_IDE%;%PATH% +SET PATH=%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%;%O3DE_BUILD_PATH%;%PYTHONPATH% +set PYTHONPATH=%PATH_DCCSIG%;%PATH_DCCSI_PYTHON_LIB%;%PATH_O3DE_BUILD%;%PYTHONPATH% echo PYTHONPATH = %PYTHONPATH% :: Set flag so we don't initialize dccsi environment twice diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat index 6202ead2f2..dff775efda 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat @@ -41,16 +41,16 @@ echo QTFORPYTHON_PATH = %QTFORPYTHON_PATH% SET PATH=%QTFORPYTHON_PATH%;%PATH% SET PYTHONPATH=%QTFORPYTHON_PATH%;%PYTHONPATH% -set QT_PLUGIN_PATH=%O3DE_BUILD_PATH%\bin\profile\EditorPlugins +set QT_PLUGIN_PATH=%PATH_O3DE_BUILD%\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 O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile -echo O3DE_BIN_PATH = %O3DE_BIN_PATH% -SET PATH=%O3DE_BIN_PATH%;%PATH% +set PATH_O3DE_BIN=%PATH_O3DE_BUILD%\bin\profile +echo PATH_O3DE_BIN = %PATH_O3DE_BIN% +SET PATH=%PATH_O3DE_BIN%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat index d44ed985da..200c8c6435 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat @@ -31,16 +31,16 @@ echo. : Substance Designer :: maya sdk path -set DCCSI_SUBSTANCE_PATH=%DCCSI_TOOLS_PATH%\Substance -echo DCCSI_SUBSTANCE_PATH = %DCCSI_SUBSTANCE_PATH% +set PATH_DCCSI_SUBSTANCE=%PATH_DCCSI_TOOLS%\Substance +echo PATH_DCCSI_SUBSTANCE = %PATH_DCCSI_SUBSTANCE% :: https://docs.substance3d.com/sddoc/project-preferences-107118596.html#ProjectPreferences-ConfigurationFile :: Path to .exe, "C:\Program Files\Allegorithmic\Substance Designer\Substance Designer.exe" -set SUBSTANCE_PATH="%ProgramFiles%\Allegorithmic\Substance Designer" -echo SUBSTANCE_PATH = %SUBSTANCE_PATH% +set PATH_SUBSTANCE_DESIGNER="%ProgramFiles%\Allegorithmic\Substance Designer" +echo PATH_SUBSTANCE_DESIGNER = %PATH_SUBSTANCE_DESIGNER% :: default config -set SUBSTANCE_CFG_PATH=%O3DE_PROJECT_PATH%\DCCsi_default.sbscfg -echo SUBSTANCE_CFG_PATH = %SUBSTANCE_CFG_PATH% +IF "%PATH_SUBSTANCE_DESIGNER_CFG%"=="" (set PATH_SUBSTANCE_DESIGNER_CFG=%PATH_O3DE_PROJECT%\DCCsi_default.sbscfg) +echo PATH_SUBSTANCE_DESIGNER_CFG = %PATH_SUBSTANCE_DESIGNER_CFG% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat index 960d910a54..dc4beedf7f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat @@ -29,7 +29,7 @@ CALL %~dp0\Env_Qt.bat :: that will change the paths assumed in this launcher (assume system install) :: vscode envars: https://code.visualstudio.com/docs/editor/variables-reference -SET VSCODE_WRKSPC=%DCCSIG_PATH%\Solutions\.vscode\dccsi.code-workspace +IF "%VSCODE_WRKSPC%"=="" (SET VSCODE_WRKSPC=%PATH_DCCSIG%\Solutions\.vscode\dccsi.code-workspace) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat index a8c3b3d073..d8ff58b575 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat @@ -28,8 +28,8 @@ CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat :: 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%\Tools\Dev\Windows\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr +IF "%WINGHOME%"=="" (set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR%) +IF "%WING_PROJ%"=="" (set WING_PROJ=%PATH_DCCSIG%\Tools\Dev\Windows\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat index e451050ab8..8802b8dd54 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat @@ -19,10 +19,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +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) @@ -34,14 +34,17 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_PyCharm.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0..\Env_Core.bat +CALL %~dp0..\Env_Python.bat +CALL %~dp0..\Env_PyCharm.bat +CALL %~dp0..\Env_Maya.bat set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -58,29 +61,14 @@ echo. echo O3DE_DEV = %O3DE_DEV% -:: shared location for default O3DE python location -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 = %O3DE_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_MAYA% 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 - echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%PYCHARM_HOME%\bin\pycharm64.exe" ( start "" "%PYCHARM_HOME%\bin\pycharm64.exe" "%PYCHARM_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat similarity index 83% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat index 4b9edb9e50..849cda7a19 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat @@ -19,13 +19,13 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +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) +IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=PYCHARM) echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: Default level logger will handle :: CRITICAL:50 @@ -34,14 +34,14 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% -:: Initialize env -CALL %~dp0\Env_PyCharm.bat - :: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Initialize env +CALL %~dp0\..\Env_PyCharm.bat echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat similarity index 79% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat index 2dc5b06032..8f978e0830 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat @@ -29,10 +29,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +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) @@ -44,15 +44,19 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% -:: Initialize envCALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Qt.bat -CALL %~dp0\Env_Maya.bat -CALL %~dp0\Env_Substance.bat -CALL %~dp0\Env_VScode.bat +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Initialize env +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Qt.bat +CALL %~dp0\..\Env_Maya.bat +CALL %~dp0\..\Env_Substance.bat +CALL %~dp0\..\Env_VScode.bat echo. echo _____________________________________________________________________ @@ -64,11 +68,11 @@ echo. echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %PATH_O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug @@ -79,9 +83,6 @@ echo DCCSI_PY_BASE = %DCCSI_PY_BASE% 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 - echo. REM "C:\Program Files\Microsoft VS Code\Code.exe" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat similarity index 77% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat index 56e278da08..5330dcd941 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat @@ -21,14 +21,14 @@ cd %~dp0 PUSHD %~dp0 :: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +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) @@ -40,16 +40,16 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Qt.bat -CALL %~dp0\Env_Maya.bat -CALL %~dp0\Env_Substance.bat -CALL %~dp0\Env_WingIDE.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Qt.bat +CALL %~dp0\..\Env_Maya.bat +CALL %~dp0\..\Env_Substance.bat +CALL %~dp0\..\Env_WingIDE.bat echo. echo _____________________________________________________________________ echo. @@ -61,13 +61,13 @@ echo. echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat index ca5b175c39..92201ef048 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat @@ -22,10 +22,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +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) @@ -37,14 +37,17 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_WingIDE.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_WingIDE.bat +CALL %~dp0\..\Env_Maya.bat echo. echo _____________________________________________________________________ @@ -57,29 +60,14 @@ echo. echo O3DE_DEV = %O3DE_DEV% -:: shared location for default O3DE python location -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 = %O3DE_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_MAYA% 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 - echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat index 5b76de1401..3387633838 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat @@ -29,6 +29,9 @@ PUSHD %~dp0 SETLOCAL ENABLEDELAYEDEXPANSION +:: if the user has set up a custom env call it +IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat + CALL %~dp0\Env_Core.bat CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat @@ -36,11 +39,8 @@ CALL %~dp0\Env_Maya.bat CALL %~dp0\Env_Substance.bat CALL %~dp0\Env_WingIDE.bat -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat index 193cb40de8..d4d5d08c19 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/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 %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat index 75d1ff8cc4..f3e815ed8c 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat @@ -39,7 +39,7 @@ echo _____________________________________________________________________ echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat index e1b075e065..133fa3906d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/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 %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat index 18a58e1371..51233b256d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat @@ -16,9 +16,9 @@ PUSHD %~dp0 set O3DE_DEV=..\..\..\..\..\.. :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -set PY_SITE=%O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python\Lib\site-packages +set PY_SITE=%PATH_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/Tools/Dev/Windows/Solutions/.idea/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore index 265145e9c1..cc9ae87641 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore @@ -1,2 +1,3 @@ # Default ignored files -./workspace.xml \ No newline at end of file +./workspace.xml +venv \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml index 764d6090c1..1d9156afc8 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml @@ -12,15 +12,9 @@ + - + - - - - + \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml index 1069eb4889..49bab22105 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml @@ -3,8 +3,8 @@ - + - + \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml index ed52866afa..07117e447d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml @@ -1,6 +1,6 @@ - + - + \ 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 958508c227..f23fa1e9a5 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py @@ -40,9 +40,9 @@ __all__ = ['config_utils', # 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) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # azpy import azpy.return_stub as return_stub @@ -52,12 +52,31 @@ import azpy.config_utils as config_utils _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))) +_DCCSI_GDEBUGGER = env_bool.env_bool(constants.ENVAR_DCCSI_GDEBUGGER, 'WING') + +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool.env_bool(constants.ENVAR_DCCSI_LOGLEVEL, + _logging.INFO)) if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) + +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=constants.FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) +# ------------------------------------------------------------------------- + +# ------------------------------------------------------------------------- # for py2.7 (Maya) we provide this, so we must assume some bootstrapping -# has occured, see DccScriptingInterface\\config.py (_DCCSI_PYTHON_LIB_PATH) +# has occured, see DccScriptingInterface\\config.py (_PATH_DCCSI_PYTHON_LIB) try: import pathlib @@ -69,16 +88,6 @@ if _DCCSI_GDEBUG: # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -# 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})) -# ------------------------------------------------------------------------- - - # ------------------------------------------------------------------------- # get/set the project name _O3DE_DEV = Path(os.getenv(constants.ENVAR_O3DE_DEV, @@ -86,21 +95,21 @@ _O3DE_DEV = Path(os.getenv(constants.ENVAR_O3DE_DEV, check_stub='engine.json'))) _LOGGER.debug('_O3DE_DEV" {}'.format(_O3DE_DEV.resolve())) -_O3DE_PROJECT_PATH = Path(os.getenv(constants.ENVAR_O3DE_PROJECT_PATH, +_PATH_O3DE_PROJECT = Path(os.getenv(constants.ENVAR_PATH_O3DE_PROJECT, config_utils.get_o3de_project_path())) -_LOGGER.debug('_O3DE_PROJECT_PATH" {}'.format(_O3DE_PROJECT_PATH.resolve())) +_LOGGER.debug('_PATH_O3DE_PROJECT" {}'.format(_PATH_O3DE_PROJECT.resolve())) # get/set the project name -if _O3DE_PROJECT_PATH: +if _PATH_O3DE_PROJECT: _O3DE_PROJECT = str(os.getenv(constants.ENVAR_O3DE_PROJECT, - _O3DE_PROJECT_PATH.name)) + _PATH_O3DE_PROJECT.name)) else: _O3DE_PROJECT='o3de' # project cache log dir path 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(), +_DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(PATH_O3DE_PROJECT=_PATH_O3DE_PROJECT.resolve(), TAG_DCCSI_NICKNAME=TAG_DCCSI_NICKNAME)) # ------------------------------------------------------------------------- @@ -214,7 +223,7 @@ if _DCCSI_GDEBUG: # debug breadcrumbs to check this module and used paths _LOGGER.debug('MODULE_PATH: {}'.format(_MODULE_PATH)) _LOGGER.debug('O3DE_DEV_PATH: {}'.format(_O3DE_DEV)) -_LOGGER.debug('DCCSI_PATH: {}'.format(_DCCSIG_PATH)) +_LOGGER.debug('PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('O3DE_PROJECT_TAG: {}'.format(_O3DE_PROJECT)) _LOGGER.debug('DCCSI_LOG_PATH: {}'.format(_DCCSI_LOG_PATH)) # ------------------------------------------------------------------------- @@ -258,5 +267,5 @@ if __name__ == '__main__': _DCCSI_DEV_MODE = True if _DCCSI_GDEBUG: - print(_DCCSIG_PATH) + print(_PATH_DCCSIG) test_imports() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py index f6b71a7d97..a1baabcfb0 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py @@ -8,7 +8,29 @@ # # # note: this module should reamin py2.7 compatible (Maya) so no f'strings -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +"""@module docstring +This module is part of the O3DE DccScriptingInterface Gem +This module is a set of utils related to config.py, it hase several methods +that can fullfil discovery of paths for use in standing up a synthetic env. +This is particularly useful when the config is used outside of O3DE, +in an external standalone tool with PySide2(Qt). Foe example, these paths +are discoverable so that we can synthetically derive code access to various +aspects of O3DE outside of the executables. + +return_stub_dir() :discover path by walking from module to file stub +get_stub_check_path() :discover by walking from known path to file stub +get_o3de_engine_root() :combines multiple methods to discover engine root +get_o3de_build_path() :searches for the build path using file stub +get_dccsi_config() :convenience method to get the dccsi config +get_current_project_cfg() :will be depricated (don't use) +get_check_global_project() :get global project path from user .o3de data +get_o3de_project_path() :get the project path while within editor +bootstrap_dccsi_py_libs() :extends code access (mainly used in Maya py27) +""" +import time +start = time.process_time() # start tracking + import sys import os import re @@ -18,34 +40,60 @@ import logging as _logging # -------------------------------------------------------------------------- -# 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 +_MODULENAME = 'azpy.config_utils' + +__all__ = ['get_os', + 'return_stub', + 'get_stub_check_path', + 'get_dccsi_config', + 'get_current_project'] + +# dccsi site/code access +#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?) +# we know where the dccsi root should be from here +_PATH_DCCSIG = os.path.abspath(os.path.dirname(os.path.dirname(_MODULE_PATH))) +# it can be set or overrriden by dev with envar +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +# ^ we assume this config is in the root of the DCCsi +# if it's not, be sure to set envar 'PATH_DCCSIG' to ensure it +site.addsitedir(_PATH_DCCSIG) # must be done for azpy + +# note: this module is called in other root modules +# must avoid cyclical imports, no imports from azpy.constants +ENVAR_DCCSI_GDEBUG = 'DCCSI_GDEBUG' +ENVAR_DCCSI_DEV_MODE = 'DCCSI_DEV_MODE' +ENVAR_DCCSI_GDEBUGGER = 'DCCSI_GDEBUGGER' +ENVAR_DCCSI_LOGLEVEL = 'DCCSI_LOGLEVEL' FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" + 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) +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.config_utils' +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG # set up module logging #for handler in _logging.root.handlers[:]: #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + _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'] # ------------------------------------------------------------------------- @@ -77,6 +125,56 @@ except Exception as e: # ------------------------------------------------------------------------- +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 +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# exapnd the global scope and module CONST + +# this is the DCCsi envar used for discovering the engine path (if set) +ENVAR_O3DE_DEV = 'O3DE_DEV' +STUB_O3DE_DEV = 'engine.json' + +# this block is related to .o3de data +# os.path.expanduser("~") returns different values in py2.7 vs 3 +# Note: py27 support will be deprecated in the future +from os.path import expanduser +PATH_USER_HOME = expanduser("~") +_LOGGER.debug('user home: {}'.format(PATH_USER_HOME)) + +# special case, make sure didn't return \documents +user_home_parts = os.path.split(PATH_USER_HOME) + +if str(user_home_parts[1].lower()) == 'documents': + PATH_USER_HOME = user_home_parts[0] + _LOGGER.debug('user home CORRECTED: {}'.format(PATH_USER_HOME)) + +# the global project may be defined in the registry +PATH_USER_O3DE = Path(PATH_USER_HOME, '.o3de') +PATH_USER_O3DE_REGISTRY = Path(PATH_USER_O3DE, 'Registry') +PATH_USER_O3DE_BOOTSTRAP = Path(PATH_USER_O3DE_REGISTRY, 'bootstrap.setreg') + +# this is the DCCsi envar used for discovering the project path (if set) +ENVAR_PATH_O3DE_PROJECT = 'PATH_O3DE_PROJECT' + +# python related envars and paths +STR_PATH_DCCSI_PYTHON_LIB = '{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages' +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# first define all the methods for the module def get_os(): """returns lumberyard dir names used in python path""" if sys.platform.startswith('win'): @@ -96,7 +194,7 @@ def get_os(): # ------------------------------------------------------------------------- -from azpy.core import get_datadir +# 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()" @@ -106,8 +204,10 @@ from azpy.core import get_datadir # ------------------------------------------------------------------------- def return_stub_dir(stub_file='dccsi_stub'): + '''discover and return path by walking from module to file stub + Input: a file name (stub_file) + Output: returns the directory of the file (stub_file)''' _dir_to_last_file = None - '''Take a file name (stub_file) and returns the directory of the file (stub_file)''' # To Do: refactor to use pathlib object oriented Path if _dir_to_last_file is None: path = os.path.abspath(__file__) @@ -129,12 +229,15 @@ def return_stub_dir(stub_file='dccsi_stub'): # ------------------------------------------------------------------------- -def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'): +def get_stub_check_path(in_path=os.getcwd(), check_stub=STUB_O3DE_DEV): ''' Returns the branch root directory of the dev\\'engine.json' - (... or you can pass it another known stub) - - so we can safely build relative filepaths within that branch. + (... or you can pass it another known stub) so we can safely build + relative filepaths within that branch. + + Input: a starting directory, default is os.getcwd() + Input: a file name stub (to search for) + Output: a path (the stubs parent directory) If the stub is not found, it returns None ''' @@ -155,7 +258,11 @@ def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'): # ------------------------------------------------------------------------- -def get_o3de_engine_root(check_stub='engine.json'): +def get_o3de_engine_root(check_stub=STUB_O3DE_DEV): + '''Discovers the engine root + Input: a file name stub, default engine.json + Output: engine root path (if found) + ''' # get the O3DE engine root folder # if we are running within O3DE we can ensure which engine is running _O3DE_DEV = None @@ -164,20 +271,61 @@ def get_o3de_engine_root(check_stub='engine.json'): 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') + _O3DE_DEV = get_stub_check_path(check_stub=STUB_O3DE_DEV) # 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 + # execute if no exception, allow for external ENVAR override _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())) + if _DCCSI_GDEBUG: # to verbose, used often + # 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 # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def get_o3de_build_path(root_directory=get_o3de_engine_root(), + marker='CMakeCache.txt'): + """Returns a path for the O3DE\build root if found. Searchs down from a + known engine root path. + Input: a root directory, default is to discover the engine root + Output: the path of the build folder (if found) + """ + + if _DCCSI_GDEBUG: + import time + start = time.process_time() + + for root, dirs, files in os.walk(root_directory): + if marker in files: + if _DCCSI_GDEBUG: + _LOGGER.debug('Find PATH_O3DE_BUILD took: {} sec' + ''.format(time.process_time() - start)) + return Path(root) + else: + if _DCCSI_GDEBUG: + _LOGGER.debug('Not fidning PATH_O3DE_BUILD took: {} sec' + ''.format(time.process_time() - start)) + return None + +# note: if we use this method to find PATH_O3DE_BUILD +# by searching for the 'CMakeCache.txt' it can take 1 or more seconds +# this will slow down boot times! +# +# this works fine for a engine dev, but is not really suitable for end users +# it assumes that the engine is being built and 'CMakeCache.txt' exists +# but the engine could be pre-built or packaged somehow +# +# other ways to deal with it: +# 1 - Use the running application .exe to discover the build path? +# 2 - Set PATH_O3DE_BUILD envar in +# "C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\.env" +# 3 - Set in commandline (or from .bat file) +# 4 - To Do (maybe): Set in a dccsi_configuration.setreg? +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # settings.setenv() # doing this will add the additional DYNACONF_ envars def get_dccsi_config(dccsi_dirpath=return_stub_dir()): @@ -231,10 +379,8 @@ def get_current_project_cfg(dev_folder=get_stub_check_path()): 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 json_file_path = Path(PATH_USER_O3DE_BOOTSTRAP) @@ -260,46 +406,44 @@ def get_check_global_project(): # ------------------------------------------------------------------------- def get_o3de_project_path(): - """figures out the o3de project path - if not found defaults to the engine folder""" - _O3DE_PROJECT_PATH = None + """figures out the o3de project path if not found defaults to the engine folder""" + _PATH_O3DE_PROJECT = 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() + _PATH_O3DE_PROJECT = 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)) + _PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, 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 + if not _PATH_O3DE_PROJECT: + _PATH_O3DE_PROJECT = get_o3de_engine_root() + + if _DCCSI_GDEBUG: # to verbose, used often + # note: can't use fstrings as this module gets called with py2.7 in maya + _LOGGER.debug('O3DE project root: {}'.format(_PATH_O3DE_PROJECT.resolve())) + return _PATH_O3DE_PROJECT # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- 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 = Path(STR_DCCSI_PYTHON_LIB_PATH.format(dccsi_dirpath, + _PATH_DCCSI_PYTHON_LIB = Path(STR_PATH_DCCSI_PYTHON_LIB.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 + if _PATH_DCCSI_PYTHON_LIB.exists(): + site.addsitedir(_PATH_DCCSI_PYTHON_LIB.resolve()) # PYTHONPATH _LOGGER.debug('Performed site.addsitedir({})' - ''.format(_DCCSI_PYTHON_LIB_PATH.resolve())) - return _DCCSI_PYTHON_LIB_PATH + ''.format(_PATH_DCCSI_PYTHON_LIB.resolve())) + return _PATH_DCCSI_PYTHON_LIB else: - message = "Doesn't exist: {}".format(_DCCSI_PYTHON_LIB_PATH) + message = "Doesn't exist: {}".format(_PATH_DCCSI_PYTHON_LIB) _LOGGER.error(message) raise NotADirectoryError(message) # ------------------------------------------------------------------------- @@ -309,27 +453,87 @@ def bootstrap_dccsi_py_libs(dccsi_dirpath=return_stub_dir()): # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': + """Run this file as a standalone cli script for testing/debugging""" + + # global scope + _MODULENAME = 'azpy.config_utils' + + # enable debug + _DCCSI_GDEBUG = False # enable here to force temporarily + _DCCSI_DEV_MODE = False + _DCCSI_LOGLEVEL = _logging.INFO + + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi: {}'.format(_MODULENAME), + epilog="Coomandline args enable deeper testing and info from commandline") + + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') + + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') + + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') + + args = parser.parse_args() + + # easy overrides + if args.global_debug: + _DCCSI_GDEBUG = True + _DCCSI_LOGLEVEL = _logging.DEBUG + _LOGGER.setLevel(_DCCSI_LOGLEVEL) + + if args.set_debugger: + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') + # To Do: implement debugger plugin pattern + + if args.developer_mode or _DCCSI_DEV_MODE: + _DCCSI_DEV_MODE = True + attach_debugger() # attempts to start debugger # happy print _LOGGER.info("# {0} #".format('-' * 72)) _LOGGER.info('~ config_utils.py ... Running script as __main__') _LOGGER.info("# {0} #".format('-' * 72)) + + from pathlib import Path + # built in simple tests and info from commandline _LOGGER.info('Current Work dir: {0}'.format(os.getcwd())) _LOGGER.info('OS: {}'.format(get_os())) + + _PATH_DCCSIG = Path(return_stub_dir('dccsi_stub')) + _LOGGER.info('PATH_DCCSIG: {}'.format(_PATH_DCCSIG.resolve())) - _LOGGER.info('DCCSIG_PATH: {}'.format(return_stub_dir('dccsi_stub'))) - - _config = get_dccsi_config() - _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(_config)) - - _LOGGER.info('O3DE_DEV: {}'.format(get_o3de_engine_root(check_stub='engine.json'))) + _O3DE_DEV = get_o3de_engine_root(check_stub='engine.json') + _LOGGER.info('O3DE_DEV: {}'.format(_O3DE_DEV.resolve())) + + _PATH_O3DE_BUILD = get_o3de_build_path(_O3DE_DEV, 'CMakeCache.txt') + _LOGGER.info('PATH_O3DE_BUILD: {}'.format(_PATH_O3DE_BUILD.resolve())) # new o3de version - _LOGGER.info('O3DE_PROJECT: {}'.format(get_check_global_project())) + _PATH_O3DE_PROJECT = get_check_global_project() + _LOGGER.info('PATH_O3DE_PROJECT: {}'.format(_PATH_O3DE_PROJECT.resolve())) - _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(bootstrap_dccsi_py_libs(return_stub_dir('dccsi_stub')))) + _PATH_DCCSI_PYTHON_LIB = bootstrap_dccsi_py_libs(_PATH_DCCSIG) + _LOGGER.info('PATH_DCCSI_PYTHON_LIB: {}'.format(_PATH_DCCSI_PYTHON_LIB.resolve())) + _DCCSI_CONFIG = get_dccsi_config(_PATH_DCCSIG) + _LOGGER.info('PATH_DCCSI_CONFIG: {}'.format(_DCCSI_CONFIG)) + # --------------------------------------------------------------------- + # custom prompt sys.ps1 = "[azpy]>>" + +_LOGGER.debug('DCCsi: config_utils.py took: {} sec'.format(time.process_time() - start)) +# --- END ----------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py index d23601a33d..43efaa1201 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py @@ -23,6 +23,7 @@ So we can make an update here once that is used elsewhere. import os import sys import site +import time from os.path import expanduser import logging as _logging # ------------------------------------------------------------------------- @@ -30,22 +31,23 @@ import logging as _logging # ------------------------------------------------------------------------- # global scope -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.constants' +_MODULENAME = 'azpy.constants' + +start = time.process_time() # start tracking 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? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # now we have azpy api access import azpy from azpy.env_bool import env_bool from azpy.config_utils import return_stub_dir +from azpy.config_utils import get_stub_check_path # ------------------------------------------------------------------------- @@ -65,18 +67,23 @@ FRMT_LOG_SHRT = "[%(asctime)s][%(name)s][%(levelname)s] >> %(message)s" # 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))) +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) -# ------------------------------------------------------------------------- + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG - -# ------------------------------------------------------------------------- # set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + _LOGGER = _logging.getLogger(_MODULENAME) -_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -107,6 +114,7 @@ TAG_DCCSI_CONFIG = str('dccsiconfiguration.setreg') # filesystem markers, stub file names. STUB_O3DE_DEV = str('engine.json') +STUB_O3DE_BUILD = str('CMakeCache.txt') STUB_O3DE_ROOT_DCCSI = str('dccsi_stub') STUB_O3DE_DCCSI_AZPY = str('dccsi_azpy_stub') STUB_O3DE_DCCSI_TOOLS = str('dccsi_tools_stub') @@ -147,27 +155,27 @@ PATH_PROGRAMFILES_X64 = str(os.environ['PROGRAMFILES']) # base env var key as str ENVAR_COMPANY = str('COMPANY') -ENVAR_O3DE_PROJECT = str('O3DE_PROJECT') -ENVAR_O3DE_PROJECT_PATH = str('O3DE_PROJECT_PATH') +ENVAR_O3DE_PROJECT = str('O3DE_PROJECT') # project name +ENVAR_PATH_O3DE_PROJECT = str('PATH_O3DE_PROJECT') # path to project ENVAR_O3DE_DEV = str('O3DE_DEV') -ENVAR_DCCSIG_PATH = str('DCCSIG_PATH') +ENVAR_PATH_DCCSIG = str('PATH_DCCSIG') ENVAR_DCCSI_AZPY_PATH = str('DCCSI_AZPY_PATH') -ENVAR_DCCSI_TOOLS_PATH = str('DCCSI_TOOLS_PATH') +ENVAR_PATH_DCCSI_TOOLS = str('PATH_DCCSI_TOOLS') ENVAR_O3DE_BUILD_DIR_NAME = str('O3DE_BUILD_DIR_NAME') -ENVAR_O3DE_BUILD_PATH = str('O3DE_BUILD_PATH') +ENVAR_PATH_O3DE_BUILD = str('PATH_O3DE_BUILD') ENVAR_QT_PLUGIN_PATH = TAG_QT_PLUGIN_PATH ENVAR_QTFORPYTHON_PATH = str('QTFORPYTHON_PATH') -ENVAR_O3DE_BIN_PATH = str('O3DE_BIN_PATH') +ENVAR_PATH_O3DE_BIN = str('PATH_O3DE_BIN') ENVAR_DCCSI_LOG_PATH = str('DCCSI_LOG_PATH') ENVAR_DCCSI_LAUNCHERS_PATH = str('DCCSI_LAUNCHERS_PATH') 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_O3DE_PYTHON_INSTALL = str('O3DE_PYTHON_INSTALL') +ENVAR_PATH_DCCSI_PYTHON = str('PATH_DCCSI_PYTHON') +ENVAR_PATH_DCCSI_PYTHON_LIB = str('PATH_DCCSI_PYTHON_LIB') +ENVAR_PATH_O3DE_PYTHON_INSTALL = str('PATH_O3DE_PYTHON_INSTALL') ENVAR_WINGHOME = str('WINGHOME') ENVAR_DCCSI_WING_VERSION_MAJOR = str('DCCSI_WING_VERSION_MAJOR') @@ -178,7 +186,7 @@ ENVAR_DCCSI_PY_DCCSI = str('DCCSI_PY_DCCSI') ENVAR_DCCSI_PY_MAYA = str('DCCSI_PY_MAYA') ENVAR_DCCSI_PY_DEFAULT = str('DCCSI_PY_DEFAULT') -ENVAR_DCCSI_MAYA_VERSION = str('DCCSI_MAYA_VERSION') +ENVAR_MAYA_VERSION = str('MAYA_VERSION') ENVAR_MAYA_LOCATION = str('MAYA_LOCATION') ENVAR_DCCSI_TOOLS_MAYA_PATH = str('DCCSI_TOOLS_MAYA_PATH') @@ -206,27 +214,29 @@ TAG_MAYA_WORKSPACE = 'workspace.mel' # dcc scripting interface common and default paths PATH_O3DE_DEV = str(return_stub_dir(STUB_O3DE_DEV)) -PATH_DCCSIG_PATH = str(return_stub_dir(STUB_O3DE_ROOT_DCCSI)) +PATH_DCCSIG = 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)) +PATH_DCCSI_TOOLS = str('{0}\\{1}'.format(PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS)) # logging into the cache -PATH_DCCSI_LOG_PATH = str('{O3DE_PROJECT_PATH}\\user\\log\{TAG_DCCSI_NICKNAME}') +PATH_DCCSI_LOG_PATH = str('{PATH_O3DE_PROJECT}\\user\\log\{TAG_DCCSI_NICKNAME}') # dev \ \ -STR_CONSTRUCT_O3DE_BUILD_PATH = str('{0}\\{1}') -PATH_O3DE_BUILD_PATH = str(STR_CONSTRUCT_O3DE_BUILD_PATH.format(PATH_O3DE_DEV, +STR_CONSTRUCT_PATH_O3DE_BUILD = str('{0}\\{1}') +PATH_O3DE_BUILD = str(STR_CONSTRUCT_PATH_O3DE_BUILD.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_O3DE_BIN_PATH = str('{0}\\bin\\profile') +STR_PATH_O3DE_BIN = str('{0}\\bin\\profile') + +STR_PATH_O3DE_BUILD = str('{0}\\{1}') +PATH_O3DE_BUILD = STR_PATH_O3DE_BUILD.format(PATH_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER) -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) +PATH_QT_PLUGIN_PATH = str(STR_QTPLUGIN_DIR).format(PATH_O3DE_BUILD) +PATH_O3DE_BIN = str(STR_PATH_O3DE_BIN).format(PATH_O3DE_BUILD) # py path string, parts, etc. TAG_DEFAULT_PY = str('Launch_pyBASE.bat') @@ -266,21 +276,21 @@ 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_O3DE_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') -PATH_DCCSI_PYTHON_PATH = str(STR_CONSTRUCT_O3DE_PYTHON_INSTALL.format(PATH_O3DE_DEV, +STR_CONSTRUCT_PATH_O3DE_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') +PATH_DCCSI_PYTHON = str(STR_CONSTRUCT_PATH_O3DE_PYTHON_INSTALL.format(PATH_O3DE_DEV, TAG_TOOLS_DIR, TAG_DCCSI_PY_VERSION_MAJOR, TAG_DCCSI_PY_VERSION_MINOR, TAG_DCCSI_PY_VERSION_RELEASE, TAG_PLATFORM)) -PATH_DCCSI_PY_BASE = str('{0}\\{1}').format(PATH_DCCSI_PYTHON_PATH, TAG_PYTHON_EXE) +PATH_DCCSI_PY_BASE = str('{0}\\{1}').format(PATH_DCCSI_PYTHON, TAG_PYTHON_EXE) PATH_DCCSI_PY_DEFAULT = PATH_DCCSI_PY_BASE # bootstrap site-packages by version TAG_PY_MAJOR = str(sys.version_info.major) # future proof TAG_PY_MINOR = str(sys.version_info.minor) -STR_DCCSI_PYTHON_LIB_PATH = str('{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages') -PATH_DCCSI_PYTHON_LIB_PATH = STR_DCCSI_PYTHON_LIB_PATH.format(PATH_DCCSIG_PATH, +STR_PATH_DCCSI_PYTHON_LIB = str('{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages') +PATH_DCCSI_PYTHON_LIB = STR_PATH_DCCSI_PYTHON_LIB.format(PATH_DCCSIG, TAG_PY_MAJOR, TAG_PY_MINOR) # default path strings (and afe associated attributes) @@ -334,14 +344,14 @@ if __name__ == '__main__': _stash_dict = {} _stash_dict['O3DE_DEV'] = Path(PATH_O3DE_DEV) - _stash_dict['DCCSIG_PATH'] = Path(PATH_DCCSIG_PATH) + _stash_dict['PATH_DCCSIG'] = Path(PATH_DCCSIG) _stash_dict['DCCSI_AZPY_PATH'] = Path(PATH_DCCSI_AZPY_PATH) - _stash_dict['DCCSI_TOOLS_PATH'] = Path(PATH_DCCSI_TOOLS_PATH) - _stash_dict['DCCSI_PYTHON_PATH'] = Path(PATH_DCCSI_PYTHON_PATH) + _stash_dict['PATH_DCCSI_TOOLS'] = Path(PATH_DCCSI_TOOLS) + _stash_dict['PATH_DCCSI_PYTHON'] = Path(PATH_DCCSI_PYTHON) _stash_dict['DCCSI_PY_BASE'] = Path(PATH_DCCSI_PY_BASE) - _stash_dict['DCCSI_PYTHON_LIB_PATH'] = Path(PATH_DCCSI_PYTHON_LIB_PATH) - _stash_dict['O3DE_BUILD_PATH'] = Path(PATH_O3DE_BUILD_PATH) - _stash_dict['O3DE_BIN_PATH'] = Path(PATH_O3DE_BIN_PATH) + _stash_dict['PATH_DCCSI_PYTHON_LIB'] = Path(PATH_DCCSI_PYTHON_LIB) + _stash_dict['PATH_O3DE_BUILD'] = Path(PATH_O3DE_BUILD) + _stash_dict['PATH_O3DE_BIN'] = Path(PATH_O3DE_BIN) _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) @@ -363,3 +373,6 @@ if __name__ == '__main__': # custom prompt sys.ps1 = "[azpy]>>" + +_LOGGER.debug('{0} took: {1} sec'.format(_MODULENAME, time.process_time() - start)) +# --- END ----------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py index cdcf99d762..ec90a17ffd 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py @@ -69,11 +69,11 @@ _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT] = '${0}'.format(ENVAR_O3DE_PROJECT) # paths _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_PATH_O3DE_PROJECT] = Path('${0}'.format(ENVAR_PATH_O3DE_PROJECT)) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] = Path('${0}'.format(ENVAR_PATH_DCCSIG)) _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_TOOLS_PATH] = Path('${0}'.format(ENVAR_DCCSI_TOOLS_PATH)) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS] = Path('${0}'.format(ENVAR_PATH_DCCSI_TOOLS)) # dev env flags _BASE_ENVVAR_DICT[ENVAR_DCCSI_GDEBUG] = '${0}'.format(ENVAR_DCCSI_GDEBUG) @@ -83,8 +83,8 @@ _BASE_ENVVAR_DICT[ENVAR_DCCSI_GDEBUGGER] = '${0}'.format(ENVAR_DCCSI_GDEBUGGER) # default python dist _BASE_ENVVAR_DICT[ENVAR_DCCSI_PY_VERSION_MAJOR] = '${0}'.format(ENVAR_DCCSI_PY_VERSION_MAJOR) _BASE_ENVVAR_DICT[ENVAR_DCCSI_PY_VERSION_MINOR] = '${0}'.format(ENVAR_DCCSI_PY_VERSION_MINOR) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_PYTHON_PATH] = '${0}'.format(ENVAR_DCCSI_PYTHON_PATH) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_PYTHON_LIB_PATH] = '${0}'.format(ENVAR_DCCSI_PYTHON_LIB_PATH) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_PYTHON] = '${0}'.format(ENVAR_PATH_DCCSI_PYTHON) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_PYTHON_LIB] = '${0}'.format(ENVAR_PATH_DCCSI_PYTHON_LIB) # try to fetch and set the base values from the environment # this makes sure all envars set, are resolved on import diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py index 2d0685b67d..21f9692dc5 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py @@ -42,9 +42,9 @@ Configures several useful environment config settings and paths, # this is the required base environment 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_TOOLS_PATH : path to associated (non-api code) DCC SDK + PATH_O3DE_PROJECT : path to project dir + PATH_DCCSIG : path to the DCCsi Gem root + PATH_DCCSI_TOOLS : path to associated (non-api code) DCC SDK # nice to haves in base env to define core support DCCSI_GDEBUG : sets global debug prints @@ -58,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=%O3DE_PYTHON_INSTALL%\python.exe + set DCCSI_PY_BASE=%PATH_O3DE_PYTHON_INSTALL%\python.exe :: shared location for 64bit python 3.7 BASE location set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%\Launch_pyBASE.bat @@ -107,9 +107,9 @@ from collections import OrderedDict os.environ['PYTHONINSPECT'] = 'True' _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) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # ------------------------------------------------------------------------- @@ -135,7 +135,7 @@ _LOGGER = _logging.getLogger(_PACKAGENAME) _logging.basicConfig(format=FRMT_LOG_LONG) _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) -_LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH)) +_LOGGER.debug('_PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) @@ -146,7 +146,7 @@ if _DCCSI_DEV_MODE: # 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, + Path(_PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -159,12 +159,12 @@ from azpy.constants import * from azpy.shared.common.core_utils import walk_up_dir from azpy.shared.common.core_utils import get_stub_check_path -_DCCSI_PYTHON_LIB_PATH = os.getenv(ENVAR_DCCSI_PYTHON_LIB_PATH, - PATH_DCCSI_PYTHON_LIB_PATH) -_LOGGER.debug('Dccsi Lib Path: {0}'.format(_DCCSI_PYTHON_LIB_PATH)) +_PATH_DCCSI_PYTHON_LIB = os.getenv(ENVAR_PATH_DCCSI_PYTHON_LIB, + PATH_DCCSI_PYTHON_LIB) +_LOGGER.debug('Dccsi Lib Path: {0}'.format(_PATH_DCCSI_PYTHON_LIB)) -if os.path.exists(_DCCSI_PYTHON_LIB_PATH): - site.addsitedir(_DCCSI_PYTHON_LIB_PATH) # add access +if os.path.exists(_PATH_DCCSI_PYTHON_LIB): + site.addsitedir(_PATH_DCCSI_PYTHON_LIB) # add access # ------------------------------------------------------------------------- # post-bootstrap global space @@ -404,53 +404,53 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # so we guess based on how I set up the original dev environment # -- envar -- - _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() + _PATH_O3DE_BUILD = Path(os.getenv(ENVAR_PATH_O3DE_BUILD, + PATH_O3DE_BUILD)) + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_BUILD] = _PATH_O3DE_BUILD.as_posix() # -- envar -- - _O3DE_BIN_PATH = Path(os.getenv(ENVAR_O3DE_BIN_PATH, - PATH_O3DE_BIN_PATH)) + _PATH_O3DE_BIN = Path(os.getenv(ENVAR_PATH_O3DE_BIN, + PATH_O3DE_BIN)) # some of these need hard checks - if not _O3DE_BIN_PATH.exists(): - raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) else: - _SYNTH_ENV_DICT[ENVAR_O3DE_BIN_PATH] = _O3DE_BIN_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_BIN] = _PATH_O3DE_BIN.as_posix() # 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'] + os.environ['PATH'] = _PATH_O3DE_BIN.as_posix() + os.pathsep + os.environ['PATH'] # -- envar -- # if that stub marker doesn't exist assume DCCsi path (fallback 1) - _O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, + _PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, Path(_O3DE_DEV, _O3DE_PROJECT))) - _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] = _O3DE_PROJECT_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] = _PATH_O3DE_PROJECT.as_posix() # -- envar -- - _DCCSIG_PATH = resolve_envar_path(ENVAR_DCCSIG_PATH, # envar + _PATH_DCCSIG = resolve_envar_path(ENVAR_PATH_DCCSIG, # envar _THIS_MODULE_PATH, # search path STUB_O3DE_ROOT_DCCSI, # stub name TAG_DEFAULT_PROJECT) # dir - _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] = _DCCSIG_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] = _PATH_DCCSIG.as_posix() # -- envar -- _AZPY_PATH = Path(os.getenv(ENVAR_DCCSI_AZPY_PATH, - Path(_DCCSIG_PATH, TAG_DIR_DCCSI_AZPY))) + Path(_PATH_DCCSIG, TAG_DIR_DCCSI_AZPY))) _SYNTH_ENV_DICT[ENVAR_DCCSI_AZPY_PATH] = _AZPY_PATH.as_posix() # -- envar -- - _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() + _PATH_DCCSI_TOOLS = Path(os.getenv(ENVAR_PATH_DCCSI_TOOLS, + Path(_PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS))) + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSI_TOOLS] = _PATH_DCCSI_TOOLS.as_posix() # -- envar -- # external dccsi site-packages - _DCCSI_PYTHON_LIB_PATH = Path(os.getenv(ENVAR_DCCSI_PYTHON_LIB_PATH, - PATH_DCCSI_PYTHON_LIB_PATH)) - _SYNTH_ENV_DICT[ENVAR_DCCSI_PYTHON_LIB_PATH] = _DCCSI_PYTHON_LIB_PATH.as_posix() + _PATH_DCCSI_PYTHON_LIB = Path(os.getenv(ENVAR_PATH_DCCSI_PYTHON_LIB, + PATH_DCCSI_PYTHON_LIB)) + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSI_PYTHON_LIB] = _PATH_DCCSI_PYTHON_LIB.as_posix() # -- envar -- # extend to py36 (conda env) and interpreter (wrapped as a .bat file) - _DEFAULT_PY_PATH = Path(_DCCSIG_PATH, TAG_DEFAULT_PY) + _DEFAULT_PY_PATH = Path(_PATH_DCCSIG, TAG_DEFAULT_PY) _DEFAULT_PY_PATH = Path(os.getenv(ENVAR_DCCSI_PY_DEFAULT, _DEFAULT_PY_PATH)) _SYNTH_ENV_DICT[ENVAR_DCCSI_PY_DEFAULT] = _DEFAULT_PY_PATH.as_posix() @@ -507,16 +507,16 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): sys.path.insert(1, str(QTFORPYTHON_PATH)) site.addsitedir(str(QTFORPYTHON_PATH)) - O3DE_BIN_PATH = Path.joinpath(O3DE_DEV, + PATH_O3DE_BIN = Path.joinpath(O3DE_DEV, 'windows', 'bin', 'profile').resolve() - 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)) + os.environ["DYNACONF_PATH_O3DE_BIN"] = str(PATH_O3DE_BIN) + os.environ["PATH_O3DE_BIN"] = str(PATH_O3DE_BIN) + site.addsitedir(str(PATH_O3DE_BIN)) + sys.path.insert(1, str(PATH_O3DE_BIN)) - QT_PLUGIN_PATH = Path.joinpath(O3DE_BIN_PATH, + QT_PLUGIN_PATH = Path.joinpath(PATH_O3DE_BIN, 'EditorPlugins').resolve() os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) os.environ["QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) @@ -534,7 +534,7 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): if sys.platform.startswith('win'): path = os.environ['PATH'] newPath = '' - newPath += str(O3DE_BIN_PATH) + os.pathsep + newPath += str(PATH_O3DE_BIN) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, 'shiboken2').resolve()) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, @@ -675,7 +675,7 @@ if __name__ == '__main__': if _DCCSI_GDEBUG: - tempBoxJsonFilePath = Path(_SYNTH_ENV_DICT['DCCSIG_PATH'], '.temp') + tempBoxJsonFilePath = Path(_SYNTH_ENV_DICT['PATH_DCCSIG'], '.temp') tempBoxJsonFilePath = Path(tempBoxJsonFilePath, 'boxDumpTest.json') _LOGGER.info(f'tempBoxJsonFilePath: {tempBoxJsonFilePath}') diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py index aad440d11f..d1ba5fbd10 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py @@ -7,10 +7,8 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # -# -- This line is 75 characters ------------------------------------------- -from __future__ import unicode_literals - # ------------------------------------------------------------------------- +from __future__ import unicode_literals import os import site import logging as _logging @@ -19,27 +17,42 @@ import logging as _logging # See example: #"dev\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Lumberyard\Scripts\set_menu.py" from pathlib import Path +# ------------------------------------------------------------------------- + # ------------------------------------------------------------------------- +# global scope +_MODULENAME = 'azpy.test.entry_test' _BOOT_CHECK = False # set true to test breakpoint in this module directly -import azpy.env_bool as env_bool +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 ENVAR_DCCSI_GDEBUGGER 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) - -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.test.entry_test' +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + # set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + _LOGGER = _logging.getLogger(_MODULENAME) -_logging.basicConfig(format=FRMT_LOG_LONG) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py index a9cf5e8ee5..33dd3f7810 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py @@ -38,78 +38,81 @@ except: # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -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' +_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?) -_DCCSI_PATH = os.getenv('DCCSI_PATH', +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', os.path.abspath(os.path.dirname(_MODULE_PATH))) +os. environ['PATH_DCCSIG'] = _PATH_DCCSIG # ^ we assume this config is in the root of the DCCsi -# if it's not, be sure to set envar 'DCCSI_PATH' to ensure it -site.addsitedir(_DCCSI_PATH) # must be done for azpy +# if it's not, be sure to set envar 'PATH_DCCSIG' to ensure it +site.addsitedir(_PATH_DCCSIG) # 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 +from azpy.constants import ENVAR_DCCSI_GDEBUGGER +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) - -# early attach WingIDE debugger (can refactor to include other IDEs later) -# requires externally enabling via ENVAR -if _DCCSI_DEV_MODE: - _debugger = attach_debugger() -# to do: ^ this should be replaced with full featured azpy.dev.util -# that supports additional debuggers (pycharm, vscode, etc.) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + # 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)) +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + +_LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {}.'.format({_MODULENAME})) +_LOGGER.debug('site.addsitedir({})'.format(_PATH_DCCSIG)) _LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) _LOGGER.debug('_DCCSI_LOGLEVEL: {}'.format(_DCCSI_LOGLEVEL)) # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +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 +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # 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) +_PATH_DCCSI_PYTHON_LIB = azpy.config_utils.bootstrap_dccsi_py_libs(_PATH_DCCSIG) # Now we should be able to just carry on with pth lib and dynaconf from dynaconf import Dynaconf @@ -119,60 +122,56 @@ except: import pathlib2 as pathlib from pathlib import Path -_DCCSI_PATH = Path(_DCCSI_PATH) # pathify -_DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') -_DCCSI_PYTHON_LIB_PATH = Path(_DCCSI_PYTHON_LIB_PATH) +_PATH_DCCSIG = Path(_PATH_DCCSIG) # pathify +_PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') +_PATH_DCCSI_PYTHON_LIB = Path(_PATH_DCCSI_PYTHON_LIB) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # start locally prepping known default values for dyanmic environment settings -_O3DE_DCCSI_PATH = os.environ['PATH'] -os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH +_O3DE_PATH_DCCSIG = os.environ['PATH'] +os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG # 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()) +_PATH_O3DE_BUILD = azpy.config_utils.get_o3de_build_path(_O3DE_DEV,'CMakeCache.txt') -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()) +from azpy.constants import STR_PATH_O3DE_BIN +_PATH_O3DE_BIN = Path(STR_PATH_O3DE_BIN.format(_PATH_O3DE_BUILD)) +os.environ["DYNACONF_PATH_O3DE_BIN"] = str(_PATH_O3DE_BIN.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()) +_PATH_O3DE_PROJECT = azpy.config_utils.get_o3de_project_path() +os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT.resolve()) # special, a home for stashing PYTHONPATHs into managed settings _O3DE_PYTHONPATH = list() -_O3DE_PYTHONPATH.append(_DCCSI_PATH) +_O3DE_PYTHONPATH.append(_PATH_DCCSIG) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, - engine_bin=_O3DE_BIN_PATH): +def init_o3de_pyside2(dccsi_path=_PATH_DCCSIG, + engine_bin=_PATH_O3DE_BIN): """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) + _PATH_DCCSIG = Path(dccsi_path) + _PATH_O3DE_BIN = Path(engine_bin) - if not _O3DE_BIN_PATH.exists(): - raise Exception('_O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('_PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) else: pass # python config - _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') - os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) + _PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') + os.environ["DYNACONF_PATH_DCCSI_PYTHON"] = str(_PATH_DCCSI_PYTHON.resolve()) # # allows to retreive from settings.QTFORPYTHON_PATH # from azpy.constants import STR_QTFORPYTHON_PATH # a path string constructor @@ -180,7 +179,7 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, # os.environ["DYNACONF_QTFORPYTHON_PATH"] = str(QTFORPYTHON_PATH) # site.addsitedir(str(QTFORPYTHON_PATH)) # PYTHONPATH - QT_PLUGIN_PATH = Path.joinpath(_O3DE_BIN_PATH,'EditorPlugins') + QT_PLUGIN_PATH = Path.joinpath(_PATH_O3DE_BIN,'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'] @@ -224,7 +223,7 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, # have not done that yet as I really want to get legal approval and # add this to the QtForPython Gem # please pass this in current code reviews - _DCCSI_PYSIDE2_TOOLS = Path(_DCCSI_PYTHON_PATH,'pyside2-tools') + _DCCSI_PYSIDE2_TOOLS = Path(_PATH_DCCSI_PYTHON,'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'] @@ -242,10 +241,10 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, status = False raise(e) else: - _LOGGER.warning('~ No PySide2 Tools: {}'.format(_DCCSI_PYSIDE2_TOOLS.resolve)) + _LOGGER.warning('~ No PySide2 Tools: {}'.format(_DCCSI_PYSIDE2_TOOLS.resolve())) - _O3DE_DCCSI_PATH = os.environ['PATH'] - os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG try: _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] @@ -287,9 +286,8 @@ def test_pyside2(): # ------------------------------------------------------------------------- def init_o3de_core(engine_path=_O3DE_DEV, - build_folder=_O3DE_BUILD_FOLDER, project_name=None, - project_path=_O3DE_PROJECT_PATH): + project_path=_PATH_O3DE_PROJECT): """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. @@ -306,70 +304,69 @@ def init_o3de_core(engine_path=_O3DE_DEV, 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'] + os.environ["DYNACONF_PATH_DCCSIG"] = str(_PATH_DCCSIG.resolve()) + os.environ['PATH'] = _PATH_DCCSIG.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) + #os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT) # 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()) + _PATH_O3DE_PROJECT = _project_path + os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT.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()) + os.environ["DYNACONF_PATH_O3DE_PROJECT"] = 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 + project_name = Path(_PATH_O3DE_PROJECT).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()) + _PATH_O3DE_BUILD = Path(azpy.config_utils.get_o3de_build_path(_O3DE_DEV, + 'CMakeCache.txt')) + os.environ["DYNACONF_PATH_O3DE_BUILD"] = str(_PATH_O3DE_BUILD.resolve()) - _O3DE_BIN_PATH = Path(STR_O3DE_BIN_PATH.format(_O3DE_BUILD_PATH)) - os.environ["DYNACONF_O3DE_BIN_PATH"] = str(_O3DE_BIN_PATH.resolve()) + _PATH_O3DE_BIN = Path(STR_PATH_O3DE_BIN.format(_PATH_O3DE_BUILD)) + os.environ["DYNACONF_PATH_O3DE_BIN"] = str(_PATH_O3DE_BIN.resolve()) # hard check - if not _O3DE_BIN_PATH.exists(): - raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) 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'] + os.environ['PATH'] = _PATH_O3DE_BIN.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()) + _PATH_DCCSI_TOOLS = Path(_PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS) + os.environ["DYNACONF_PATH_DCCSI_TOOLS"] = str(_PATH_DCCSI_TOOLS.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, + _DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(PATH_O3DE_PROJECT=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()) + _PATH_DCCSI_CONFIG = Path(project_path, TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG) + os.environ["DYNACONF_PATH_DCCSI_CONFIG"] = str(_PATH_DCCSI_CONFIG.resolve()) from azpy.constants import TAG_DIR_DCCSI_TOOLS - _DCCSIG_TOOLS_PATH = Path.joinpath(_DCCSI_PATH, TAG_DIR_DCCSI_TOOLS) + _DCCSIG_TOOLS_PATH = Path.joinpath(_PATH_DCCSIG, 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 + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG from dynaconf import settings @@ -381,26 +378,26 @@ def init_o3de_core(engine_path=_O3DE_DEV, # ------------------------------------------------------------------------- def init_o3de_python(engine_path=_O3DE_DEV, - engine_bin=_O3DE_BIN_PATH, - dccsi_path=_DCCSI_PATH): + engine_bin=_PATH_O3DE_BIN, + dccsi_path=_PATH_DCCSIG): # pathify _O3DE_DEV = Path(engine_path) - _O3DE_BIN_PATH = Path(engine_bin) - _DCCSI_PATH = Path(dccsi_path) + _PATH_O3DE_BIN = Path(engine_bin) + _PATH_DCCSIG = Path(dccsi_path) # python config - _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') - os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) + _PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') + os.environ["DYNACONF_PATH_DCCSI_PYTHON"] = str(_PATH_DCCSI_PYTHON.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()) + _PATH_DCCSI_PYTHON_LIB = azpy.config_utils.bootstrap_dccsi_py_libs(_PATH_DCCSIG) + os.environ["DYNACONF_PATH_DCCSI_PYTHON_LIB"] = str(_PATH_DCCSI_PYTHON_LIB.resolve()) + os.environ['PATH'] = _PATH_DCCSI_PYTHON_LIB.as_posix() + os.pathsep + os.environ['PATH'] + site.addsitedir(_PATH_DCCSI_PYTHON_LIB) + _O3DE_PYTHONPATH.append(_PATH_DCCSI_PYTHON_LIB.resolve()) - site.addsitedir(_O3DE_BIN_PATH) - _O3DE_PYTHONPATH.append(_O3DE_BIN_PATH.resolve()) + site.addsitedir(_PATH_O3DE_BIN) + _O3DE_PYTHONPATH.append(_PATH_O3DE_BIN.resolve()) _O3DE_PY_EXE = Path(sys.executable) _DCCSI_PY_IDE = Path(_O3DE_PY_EXE) @@ -411,24 +408,24 @@ def init_o3de_python(engine_path=_O3DE_DEV, 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'] + _PATH_O3DE_PYTHON_INSTALL = Path(_O3DE_DEV, 'python') + os.environ["DYNACONF_PATH_O3DE_PYTHON_INSTALL"] = str(_PATH_O3DE_PYTHON_INSTALL.resolve()) + os.environ['PATH'] = _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') + _DCCSI_PY_BASE = Path(_PATH_O3DE_PYTHON_INSTALL, 'python.cmd') elif sys.platform == "linux": - _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + _DCCSI_PY_BASE = Path(_PATH_O3DE_PYTHON_INSTALL, 'python.sh') elif sys.platform == "darwin": - _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + _DCCSI_PY_BASE = Path(_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 + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG try: _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] @@ -447,23 +444,21 @@ def init_o3de_python(engine_path=_O3DE_DEV, # ------------------------------------------------------------------------- # 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, + project_path=_PATH_O3DE_PROJECT, 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) + settings.PATH_O3DE_BIN, + settings.PATH_DCCSIG) # These should ONLY be set for O3DE and non-DCC environments # They will most likely cause other Qt/PySide DCC apps to fail @@ -474,8 +469,8 @@ def get_config_settings(engine_path=_O3DE_DEV, # 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) + settings = init_o3de_pyside2(settings.PATH_DCCSIG, + settings.PATH_O3DE_BIN) # now standalone we can validate the config. env, settings. from dynaconf import settings @@ -489,11 +484,11 @@ def get_config_settings(engine_path=_O3DE_DEV, # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - """Run this file as a standalone cli script""" + """Run this file as a standalone cli script for testing/debugging""" + import time + start = time.process_time() # start tracking - _MODULENAME = __name__ - if _MODULENAME is '__main__': - _MODULENAME = 'DCCsi.config' + _MODULENAME = 'DCCsi.config' from azpy.constants import STR_CROSSBAR @@ -508,7 +503,7 @@ if __name__ == '__main__': # happy print _LOGGER.info(STR_CROSSBAR) - _LOGGER.info('~ constants.py ... Running script as __main__') + _LOGGER.info('~ {}.py ... Running script as __main__'.format(_MODULENAME)) _LOGGER.info(STR_CROSSBAR) # go ahead and run the rest of the configuration @@ -521,6 +516,10 @@ if __name__ == '__main__': type=bool, required=False, help='Enables global debug flag.') + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') parser.add_argument('-dm', '--developer-mode', type=bool, required=False, @@ -549,10 +548,6 @@ if __name__ == '__main__': 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, @@ -575,13 +570,15 @@ if __name__ == '__main__': 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.') + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') # To Do: implement debugger plugin pattern + if args.developer_mode: + _DCCSI_DEV_MODE = True + attach_debugger() # attempts to start debugger + # need to do a little plumbing if not args.engine_path: args.engine_path=_O3DE_DEV @@ -589,7 +586,7 @@ if __name__ == '__main__': 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 + args.project_path=_PATH_O3DE_PROJECT if _DCCSI_GDEBUG: args.enable_python = True @@ -597,7 +594,6 @@ if __name__ == '__main__': # 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, @@ -612,47 +608,54 @@ if __name__ == '__main__': _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_O3DE_BUILD_FOLDER: {}'.format(settings.PATH_O3DE_BUILD)) + _LOGGER.info('PATH_O3DE_BUILD: {}'.format(settings.PATH_O3DE_BUILD)) + _LOGGER.info('PATH_O3DE_BIN: {}'.format(settings.PATH_O3DE_BIN)) _LOGGER.info('O3DE_PROJECT: {}'.format(settings.O3DE_PROJECT)) - _LOGGER.info('O3DE_PROJECT_PATH: {}'.format(settings.O3DE_PROJECT_PATH)) + _LOGGER.info('PATH_O3DE_PROJECT: {}'.format(settings.PATH_O3DE_PROJECT)) - _LOGGER.info('DCCSI_PATH: {}'.format(settings.DCCSI_PATH)) + _LOGGER.info('PATH_DCCSIG: {}'.format(settings.PATH_DCCSIG)) _LOGGER.info('DCCSI_LOG_PATH: {}'.format(settings.DCCSI_LOG_PATH)) - _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(settings.DCCSI_CONFIG_PATH)) + _LOGGER.info('PATH_DCCSI_CONFIG: {}'.format(settings.PATH_DCCSI_CONFIG)) - if settings.O3DE_DCCSI_ENV_TEST: + try: + settings.O3DE_DCCSI_ENV_TEST _LOGGER.info('O3DE_DCCSI_ENV_TEST: {}'.format(settings.O3DE_DCCSI_ENV_TEST)) + except: + pass # don't exist _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('PATH_DCCSI_PYTHON'.format(settings.PATH_DCCSI_PYTHON)) + _LOGGER.info('PATH_DCCSI_PYTHON_LIB: {}'.format(settings.PATH_DCCSI_PYTHON_LIB)) _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('PATH_O3DE_PYTHON_INSTALL'.format(settings.PATH_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') + _LOGGER.info('Tip: add arg --enable-python (-py) 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)) + try: + settings.DCCSI_PYSIDE2_TOOLS + _LOGGER.info('DCCSI_PYSIDE2_TOOLS: {}'.format(settings.DCCSI_PYSIDE2_TOOLS)) + except: + pass # don't exist _LOGGER.info(STR_CROSSBAR) _LOGGER.info('') else: - - _LOGGER.info('Tip: add arg --enable-qt to extend the environment with O3DE Qt/PySide2 support') + _LOGGER.info('Tip: add arg --enable-qt (-qt) to extend the environment with O3DE Qt/PySide2 support') + _LOGGER.info('Tip: add arg --test-pyside2 (-tp) to test the O3DE Qt/PySide2 support') settings.setenv() # doing this will add/set the additional DYNACONF_ envars @@ -695,14 +698,9 @@ if __name__ == '__main__': _LOGGER.warning("Could not import 'pyside2uic'") _LOGGER.warning("Refer to: '< local DCCsi >\3rdParty\Python\README.txt'") _LOGGER.error(e) + + _LOGGER.info('DCCsi: config.py took: {} sec'.format(time.process_time() - start)) # return sys.exit() -# --- END ----------------------------------------------------------------- - - - - - - - +# --- END ----------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h index 9f3f2351cd..9b756b1db2 100644 --- a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h +++ b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h @@ -35,14 +35,14 @@ enum // convert from a QString into an AZStd::string MCORE_INLINE AZStd::string FromQtString(const QString& s) { - return {s.toUtf8().data(), static_cast(s.size())}; + return { s.toUtf8().data(), static_cast(s.toUtf8().length()) }; } // convert from a QString into an AZStd::string MCORE_INLINE void FromQtString(const QString& s, AZStd::string* result) { - *result = AZStd::string{s.toUtf8().data(), static_cast(s.size())}; + *result = AZStd::string{ s.toUtf8().data(), static_cast(s.toUtf8().length()) }; } inline QString FromStdString(AZStd::string_view s) diff --git a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp index e1450c0aa8..dd7986a212 100644 --- a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp @@ -219,7 +219,7 @@ namespace ScriptCanvasEditor if (scriptCanvasSlot && scriptCanvasSlot->IsVisible()) { - int& index = (scriptCanvasSlot->IsData() && scriptCanvasSlot->IsOutput()) ? paramIndex : outputIndex; + int& index = (scriptCanvasSlot->IsData() && scriptCanvasSlot->IsOutput()) ? outputIndex : paramIndex; auto graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot), index);