diff --git a/cmake/modules/FindUFE.cmake b/cmake/modules/FindUFE.cmake index df022ab818..261aff70e9 100644 --- a/cmake/modules/FindUFE.cmake +++ b/cmake/modules/FindUFE.cmake @@ -46,10 +46,6 @@ if(UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/ufe.h") if("${UFE_MAJOR_VERSION}" STREQUAL "0") math(EXPR UFE_PREVIEW_VERSION_NUM "${UFE_MINOR_VERSION} * 1000 + ${UFE_PATCH_LEVEL}") - elseif("${UFE_VERSION}" STREQUAL "3.0.0") - # Temporary. Once next Maya PR is released with UFE v3.0.0 this should - # be removed (along with all the UFE_PREVIEW_VERSION_NUM checks). - set(UFE_PREVIEW_VERSION_NUM 3014) endif() file(STRINGS diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp index e143758eae..086e9cfae1 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp @@ -239,7 +239,7 @@ ProxyShapeHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::Sc return insertChildCommand->insertedChild(); } -#if (UFE_PREVIEW_VERSION_NUM >= 3005) +#ifdef UFE_V3_FEATURES_AVAILABLE Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(const Ufe::PathComponent& name) const { Ufe::SceneItem::Ptr createdItem; @@ -272,13 +272,8 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup( } #endif -#if (UFE_PREVIEW_VERSION_NUM >= 3001) +#ifdef UFE_V3_FEATURES_AVAILABLE Ufe::InsertChildCommand::Ptr -#else -Ufe::UndoableCommand::Ptr -#endif - -#if (UFE_PREVIEW_VERSION_NUM >= 3005) ProxyShapeHierarchy::createGroupCmd(const Ufe::PathComponent& name) const { auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim()); @@ -286,8 +281,9 @@ ProxyShapeHierarchy::createGroupCmd(const Ufe::PathComponent& name) const return UsdUndoCreateGroupCommand::create(usdItem, name.string()); } #else -ProxyShapeHierarchy::createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) - const +Ufe::UndoableCommand::Ptr ProxyShapeHierarchy::createGroupCmd( + const Ufe::Selection& selection, + const Ufe::PathComponent& name) const { auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim()); diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h index d64ca9a5cd..3185c0e62e 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h @@ -64,21 +64,13 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy #endif #ifdef UFE_V2_FEATURES_AVAILABLE -#if (UFE_PREVIEW_VERSION_NUM >= 3005) - Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; +#ifdef UFE_V3_FEATURES_AVAILABLE + Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; + Ufe::InsertChildCommand::Ptr createGroupCmd(const Ufe::PathComponent& name) const override; #else Ufe::SceneItem::Ptr createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override; -#endif - -#if (UFE_PREVIEW_VERSION_NUM >= 3001) - Ufe::InsertChildCommand::Ptr -#else Ufe::UndoableCommand::Ptr -#endif -#if (UFE_PREVIEW_VERSION_NUM >= 3005) - createGroupCmd(const Ufe::PathComponent& name) const override; -#else createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override; #endif diff --git a/lib/mayaUsd/ufe/UsdAttribute.cpp b/lib/mayaUsd/ufe/UsdAttribute.cpp index 18988c4e7b..0802c24e71 100644 --- a/lib/mayaUsd/ufe/UsdAttribute.cpp +++ b/lib/mayaUsd/ufe/UsdAttribute.cpp @@ -17,7 +17,7 @@ #include "private/Utils.h" -#if (UFE_PREVIEW_VERSION_NUM >= 3011) +#ifdef UFE_V3_FEATURES_AVAILABLE #include #endif #include @@ -44,7 +44,7 @@ static constexpr char kErrorMsgFailedConvertToString[] = "Could not convert the attribute to a string"; static constexpr char kErrorMsgInvalidType[] = "USD attribute does not match created attribute class type"; -#if (UFE_PREVIEW_VERSION_NUM >= 3013) +#ifdef UFE_V3_FEATURES_AVAILABLE static constexpr char kErrorMsgInvalidValueType[] = "Unexpected Ufe::Value type"; #endif @@ -93,7 +93,7 @@ template bool setUsdAttr(const PXR_NS::UsdAttribute& attr, const T& return attr.Set(value); } -#if (UFE_PREVIEW_VERSION_NUM >= 3011) +#ifdef UFE_V3_FEATURES_AVAILABLE bool setUsdAttrMetadata( const PXR_NS::UsdAttribute& attr, const std::string& key, @@ -118,7 +118,6 @@ bool setUsdAttrMetadata( // We must convert the Ufe::Value to VtValue for storage in Usd. // Figure out the type of the input Ufe Value and create proper Usd VtValue. PXR_NS::VtValue usdValue; -#if (UFE_PREVIEW_VERSION_NUM >= 3013) if (value.isType()) usdValue = value.get(); else if (value.isType()) @@ -132,22 +131,6 @@ bool setUsdAttrMetadata( else { TF_CODING_ERROR(kErrorMsgInvalidValueType); } -#else - if (value.type() == typeid(bool)) - usdValue = value.get(); - else if (value.type() == typeid(int)) - usdValue = value.get(); - else if (value.type() == typeid(float)) - usdValue = value.get(); - else if (value.type() == typeid(double)) - usdValue = value.get(); - // Workaround a bug on OSX (with Clang) with the type_info not comparing correctly. - // For now we know the known types that Ufe::Value supports. So if not one of - // the basic types, then it must be std::string. Once Ufe is fixed we can change - // this else into else if and assert for unknown type. - else /*if (value.type() == typeid(std::string))*/ - usdValue = value.get(); -#endif if (!usdValue.IsEmpty()) { PXR_NS::TfToken tok(key); return attr.SetMetadata(tok, usdValue); @@ -252,7 +235,7 @@ class SetUndoableCommand : public UsdUndoableCommand const T _newValue; }; -#if (UFE_PREVIEW_VERSION_NUM >= 3011) +#ifdef UFE_V3_FEATURES_AVAILABLE class SetUndoableMetadataCommand : public UsdUndoableCommand { public: @@ -307,7 +290,7 @@ std::string UsdAttribute::string(const Ufe::SceneItem::Ptr& item) const return getUsdAttributeValueAsString(fUsdAttr, getCurrentTime(item)); } -#if (UFE_PREVIEW_VERSION_NUM >= 3011) +#ifdef UFE_V3_FEATURES_AVAILABLE Ufe::Value UsdAttribute::getMetadata(const std::string& key) const { // Special cases for known Ufe metadata keys. diff --git a/lib/mayaUsd/ufe/UsdAttribute.h b/lib/mayaUsd/ufe/UsdAttribute.h index dba87b25d1..73c43d8b4f 100644 --- a/lib/mayaUsd/ufe/UsdAttribute.h +++ b/lib/mayaUsd/ufe/UsdAttribute.h @@ -23,16 +23,7 @@ #include // Ufe::Attribute overrides (minus the type method) -#if (UFE_PREVIEW_VERSION_NUM < 3011) -#define UFE_ATTRIBUTE_OVERRIDES \ - bool hasValue() const override { return UsdAttribute::hasValue(); } \ - std::string name() const override { return UsdAttribute::name(); } \ - std::string documentation() const override { return UsdAttribute::documentation(); } \ - std::string string() const override \ - { \ - return UsdAttribute::string(Ufe::Attribute::sceneItem()); \ - } -#else +#ifdef UFE_V3_FEATURES_AVAILABLE #define UFE_ATTRIBUTE_OVERRIDES \ bool hasValue() const override { return UsdAttribute::hasValue(); } \ std::string name() const override { return UsdAttribute::name(); } \ @@ -62,6 +53,15 @@ { \ return UsdAttribute::hasMetadata(key); \ } +#else +#define UFE_ATTRIBUTE_OVERRIDES \ + bool hasValue() const override { return UsdAttribute::hasValue(); } \ + std::string name() const override { return UsdAttribute::name(); } \ + std::string documentation() const override { return UsdAttribute::documentation(); } \ + std::string string() const override \ + { \ + return UsdAttribute::string(Ufe::Attribute::sceneItem()); \ + } #endif namespace MAYAUSD_NS_DEF { @@ -79,7 +79,7 @@ class UsdAttribute std::string name() const; std::string documentation() const; std::string string(const Ufe::SceneItem::Ptr& item) const; -#if (UFE_PREVIEW_VERSION_NUM >= 3011) +#ifdef UFE_V3_FEATURES_AVAILABLE Ufe::Value getMetadata(const std::string& key) const; bool setMetadata(const std::string& key, const Ufe::Value& value); Ufe::UndoableCommand::Ptr setMetadataCmd(const std::string& key, const Ufe::Value& value); diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 679c2f9c0c..8962ae7039 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -254,7 +254,7 @@ UsdHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::SceneItem } // Create a transform. -#if (UFE_PREVIEW_VERSION_NUM >= 3005) +#ifdef UFE_V3_FEATURES_AVAILABLE Ufe::SceneItem::Ptr UsdHierarchy::createGroup(const Ufe::PathComponent& name) const { Ufe::SceneItem::Ptr createdItem = nullptr; @@ -284,18 +284,13 @@ UsdHierarchy::createGroup(const Ufe::Selection& selection, const Ufe::PathCompon } #endif -#if (UFE_PREVIEW_VERSION_NUM >= 3001) -Ufe::InsertChildCommand::Ptr -#else -Ufe::UndoableCommand::Ptr -#endif - -#if (UFE_PREVIEW_VERSION_NUM >= 3005) -UsdHierarchy::createGroupCmd(const Ufe::PathComponent& name) const +#ifdef UFE_V3_FEATURES_AVAILABLE +Ufe::InsertChildCommand::Ptr UsdHierarchy::createGroupCmd(const Ufe::PathComponent& name) const { return UsdUndoCreateGroupCommand::create(fItem, name.string()); } #else +Ufe::UndoableCommand::Ptr UsdHierarchy::createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const { return UsdUndoCreateGroupCommand::create(fItem, selection, name.string()); diff --git a/lib/mayaUsd/ufe/UsdHierarchy.h b/lib/mayaUsd/ufe/UsdHierarchy.h index a1ac2f848d..716b292da2 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.h +++ b/lib/mayaUsd/ufe/UsdHierarchy.h @@ -71,22 +71,13 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : public Ufe::Hierarchy #ifdef UFE_V2_FEATURES_AVAILABLE -#if (UFE_PREVIEW_VERSION_NUM >= 3005) - Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; +#ifdef UFE_V3_FEATURES_AVAILABLE + Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; + Ufe::InsertChildCommand::Ptr createGroupCmd(const Ufe::PathComponent& name) const override; #else Ufe::SceneItem::Ptr createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override; -#endif - -#if (UFE_PREVIEW_VERSION_NUM >= 3001) - Ufe::InsertChildCommand::Ptr -#else Ufe::UndoableCommand::Ptr -#endif - -#if (UFE_PREVIEW_VERSION_NUM >= 3005) - createGroupCmd(const Ufe::PathComponent& name) const override; -#else createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override; #endif diff --git a/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp b/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp index 85c8c1cc8a..ccf77e1826 100644 --- a/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp +++ b/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp @@ -35,14 +35,14 @@ namespace ufe { UsdUndoCreateGroupCommand::UsdUndoCreateGroupCommand( const UsdSceneItem::Ptr& parentItem, -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE const Ufe::Selection& selection, #endif const Ufe::PathComponent& name) : Ufe::InsertChildCommand() , _parentItem(parentItem) , _name(name) -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE , _selection(selection) #endif , _groupCompositeCmd(std::make_shared()) @@ -53,12 +53,12 @@ UsdUndoCreateGroupCommand::~UsdUndoCreateGroupCommand() { } UsdUndoCreateGroupCommand::Ptr UsdUndoCreateGroupCommand::create( const UsdSceneItem::Ptr& parentItem, -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE const Ufe::Selection& selection, #endif const Ufe::PathComponent& name) { -#if (UFE_PREVIEW_VERSION_NUM >= 3005) +#ifdef UFE_V3_FEATURES_AVAILABLE return std::make_shared(parentItem, name); #else return std::make_shared(parentItem, selection, name); @@ -85,7 +85,7 @@ void UsdUndoCreateGroupCommand::execute() _groupCompositeCmd->append(setKindCmd); setKindCmd->execute(); } -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE // Make sure to handle the exception if the parenting operation fails. // This scenario happens if a user tries to group prim(s) in a layer // other than the one where they were defined. In this case, the group creation itself diff --git a/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h b/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h index 9fa9b29a47..c6ffa90777 100644 --- a/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h +++ b/lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h @@ -34,7 +34,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom UsdUndoCreateGroupCommand( const UsdSceneItem::Ptr& parentItem, -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE const Ufe::Selection& selection, #endif const Ufe::PathComponent& name); @@ -49,7 +49,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom //! Create a UsdUndoCreateGroupCommand from a USD scene item and a UFE path component. static UsdUndoCreateGroupCommand::Ptr create( const UsdSceneItem::Ptr& parentItem, -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE const Ufe::Selection& selection, #endif const Ufe::PathComponent& name); @@ -64,7 +64,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom UsdSceneItem::Ptr _parentItem; Ufe::PathComponent _name; UsdSceneItem::Ptr _groupItem; -#if (UFE_PREVIEW_VERSION_NUM < 3005) +#ifndef UFE_V3_FEATURES_AVAILABLE Ufe::Selection _selection; #endif diff --git a/test/lib/mayaUsd/fileio/CMakeLists.txt b/test/lib/mayaUsd/fileio/CMakeLists.txt index bfb94230ea..4b9465a278 100644 --- a/test/lib/mayaUsd/fileio/CMakeLists.txt +++ b/test/lib/mayaUsd/fileio/CMakeLists.txt @@ -37,8 +37,6 @@ foreach(script ${TEST_SCRIPT_FILES}) mayaUsd_add_test(${target} PYTHON_MODULE ${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ENV - "UFE_PREVIEW_VERSION_NUM=${UFE_PREVIEW_VERSION_NUM}" ) # Add a ctest label to these tests for easy filtering. @@ -69,7 +67,6 @@ if(CMAKE_UFE_V3_FEATURES_AVAILABLE) PYTHON_MODULE ${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ENV - "UFE_PREVIEW_VERSION_NUM=${UFE_PREVIEW_VERSION_NUM}" "${PXR_OVERRIDE_PLUGINPATH_NAME}=${CMAKE_CURRENT_SOURCE_DIR}/UsdCustomRigSchema/" ) endif() diff --git a/test/lib/mayaUsd/fileio/testDiscardEdits.py b/test/lib/mayaUsd/fileio/testDiscardEdits.py index 1488c99fd3..aaf8206a92 100644 --- a/test/lib/mayaUsd/fileio/testDiscardEdits.py +++ b/test/lib/mayaUsd/fileio/testDiscardEdits.py @@ -20,6 +20,7 @@ from mayaUtils import setMayaTranslation from usdUtils import createSimpleXformScene +from ufeUtils import ufeFeatureSetVersion import mayaUsd.lib @@ -60,7 +61,7 @@ def tearDownClass(cls): def setUp(self): cmds.file(new=True, force=True) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testDiscardEdits(self): '''Discard edits on a USD transform.''' @@ -106,7 +107,7 @@ def testDiscardEdits(self): with self.assertRaises(RuntimeError): om.MSelectionList().add(aMayaPathStr) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testDiscardEditsUndoRedo(self): '''Discard edits on a USD transform then undo and redo.''' diff --git a/test/lib/mayaUsd/fileio/testEditAsMaya.py b/test/lib/mayaUsd/fileio/testEditAsMaya.py index 4a07daaf86..f185115979 100644 --- a/test/lib/mayaUsd/fileio/testEditAsMaya.py +++ b/test/lib/mayaUsd/fileio/testEditAsMaya.py @@ -19,6 +19,7 @@ import fixturesUtils from usdUtils import createSimpleXformScene +from ufeUtils import ufeFeatureSetVersion import mayaUsd.lib @@ -61,7 +62,7 @@ def tearDownClass(cls): def setUp(self): cmds.file(new=True, force=True) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testTransformEditAsMaya(self): '''Edit a USD transform as a Maya object.''' @@ -111,7 +112,7 @@ def testTransformEditAsMaya(self): assertVectorAlmostEqual(self, mayaValues, usdValues) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testEditAsMayaUndoRedo(self): '''Edit a USD transform as a Maya object and apply undo and redo.''' @@ -176,7 +177,7 @@ def verifyNoLongerEdited(): verifyEditedScene() - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testIllegalEditAsMaya(self): '''Trying to edit as Maya on object that doesn't support it.''' @@ -203,7 +204,7 @@ def testIllegalEditAsMaya(self): # self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(scopePathStr)) # self.assertFalse(mayaUsd.lib.PrimUpdaterManager.editAsMaya(scopePathStr)) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testSessionLayer(self): '''Verify that the edit gets on the sessionLayer instead of the editTarget layer.''' diff --git a/test/lib/mayaUsd/fileio/testMergeToUsd.py b/test/lib/mayaUsd/fileio/testMergeToUsd.py index 3e654d2384..bd68e844cb 100644 --- a/test/lib/mayaUsd/fileio/testMergeToUsd.py +++ b/test/lib/mayaUsd/fileio/testMergeToUsd.py @@ -20,6 +20,7 @@ from mayaUtils import setMayaTranslation, setMayaRotation from usdUtils import createSimpleXformScene, mayaUsd_createStageWithNewLayer +from ufeUtils import ufeFeatureSetVersion import mayaUsd.lib @@ -62,7 +63,7 @@ def tearDownClass(cls): def setUp(self): cmds.file(new=True, force=True) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testTransformMergeToUsd(self): '''Merge edits on a USD transform back to USD.''' @@ -127,7 +128,7 @@ def testTransformMergeToUsd(self): with self.assertRaises(RuntimeError): om.MSelectionList().add(mayaPathStr) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testTransformMergeToUsdUndoRedo(self): '''Merge edits on a USD transform back to USD and use undo redo.''' @@ -212,7 +213,7 @@ def verifyMergeIsUndone(): verifyMergeToUsd() - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater') + @unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') def testMergeToUsdToNonRootTargetInSessionLayer(self): '''Merge edits on a USD transform back to USD targeting a non-root destination path that does not exists in the destination layer.''' diff --git a/test/lib/ufe/testAttribute.py b/test/lib/ufe/testAttribute.py index 3a9549b2e2..0d4d110e9a 100644 --- a/test/lib/ufe/testAttribute.py +++ b/test/lib/ufe/testAttribute.py @@ -962,7 +962,7 @@ def testTransformationAttributeBlocking(self): # check the "transform op order" stack. self.assertEqual(sphereXformable.GetXformOpOrderAttr().Get(), Vt.TokenArray(('xformOp:translate','xformOp:rotateXYZ', 'xformOp:scale'))) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3011', 'testMetadata is only available in UFE preview version 0.3.11 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testMetadata is only available in UFE v3 or greater.') def testMetadata(self): '''Test attribute metadata.''' cmds.file(new=True, force=True) @@ -1054,7 +1054,7 @@ def runMetadataUndoRedo(func, newValue, startValue=None): runMetadataUndoRedo(float, 65.78, 0.567) runMetadataUndoRedo(str, 'New doc from command', 'New doc starting value') - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3011', 'testAttributeLock is only available in UFE preview version 0.3.11 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testAttributeLock is only available in UFE v3 or greater.') def testAttributeLock(self): '''Test attribute lock/unlock.''' cmds.file(new=True, force=True) diff --git a/test/lib/ufe/testCamera.py b/test/lib/ufe/testCamera.py index c6ae41b28a..2ae1d97840 100644 --- a/test/lib/ufe/testCamera.py +++ b/test/lib/ufe/testCamera.py @@ -229,7 +229,7 @@ def _TestProjection(self, ufeCamera, usdCamera): usdAttr.Set("orthographic") self.assertAlmostEqual(ufe.Camera.Orthographic, ufeCamera.projection()) - @unittest.skipIf(mayaUtils.previewReleaseVersion() <= 124, 'Missing Python API for Ufe::Camera before Maya Preview Release 125.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Python API only available in Maya 2023 or greater.') def testUsdCamera(self): self._StartTest('TranslateRotate_vs_xform') mayaPathSegment = mayaUtils.createUfePathSegment('|stage|stageShape') diff --git a/test/lib/ufe/testComboCmd.py b/test/lib/ufe/testComboCmd.py index 166c3ce037..fcbadbc666 100644 --- a/test/lib/ufe/testComboCmd.py +++ b/test/lib/ufe/testComboCmd.py @@ -654,7 +654,7 @@ def testFallbackCases(self): "xformOp:rotateZ", "!invert!xformOp:translate:pivot", "xformOp:rotateXYZ:maya_fallback"))) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 123, 'Requires Maya fixes only available in Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testBrokenFallback(self): '''Maya fallback transform stack must be final on prim transform op stack.''' # Create a prim and add transform ops to it that don't match the Maya @@ -716,7 +716,7 @@ def testBrokenFallback(self): capsuleT3d = ufe.Transform3d.transform3d(capsuleItem) self.assertIsNone(capsuleT3d) - @unittest.skipIf(mayaUtils.previewReleaseVersion() < 123, 'Fallback transform op handling only available in Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Fallback transform op handling only available in Maya 2023 or greater.') def testFallback(self): '''Transformable not handled by standard Transform3d handlers must be handled by fallback handler.''' diff --git a/test/lib/ufe/testGroupCmd.py b/test/lib/ufe/testGroupCmd.py index 6e6b3112bc..c3bfb4da90 100644 --- a/test/lib/ufe/testGroupCmd.py +++ b/test/lib/ufe/testGroupCmd.py @@ -130,8 +130,7 @@ def testUsdGroup(self): self.assertEqual("ballset.usda", layer.GetDisplayName()) stage.SetEditTarget(layer) - if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') > '3000'): - + if ufeUtils.ufeFeatureSetVersion() >= 3: globalSn = ufe.GlobalSelection.get() globalSn.append(ball5Item) globalSn.append(ball3Item) @@ -166,7 +165,7 @@ def testUsdGroup(self): # The command will now append a number 1 at the end to match the naming # convention in Maya. - if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') > '3000'): + if ufeUtils.ufeFeatureSetVersion() >= 3: newGroupPath = parentPath + ufe.PathComponent(groupName) else: newGroupPath = parentPath + ufe.PathComponent("newGroup1") @@ -183,13 +182,13 @@ def testUsdGroup(self): self.assertTrue(ball5Path not in childPaths) self.assertTrue(ball3Path not in childPaths) - if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') > '3000'): + if ufeUtils.ufeFeatureSetVersion() >= 3: cmds.undo() else: groupCmd.undo() # global selection should not be empty after undo. - if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') > '3004'): + if ufeUtils.ufeFeatureSetVersion() >= 3: self.assertEqual(len(globalSelection), 2) else: self.assertEqual(len(globalSelection), 1) @@ -202,7 +201,7 @@ def testUsdGroup(self): self.assertTrue(ball5Path in childPathsUndo) self.assertTrue(ball3Path in childPathsUndo) - if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') > '3000'): + if ufeUtils.ufeFeatureSetVersion() >= 3: cmds.redo() else: groupCmd.redo() @@ -368,7 +367,7 @@ def testGroupRestriction(self): stage.GetPrimAtPath("/Ball_set/Props/Ball_6"), stage.GetPrimAtPath("/Sphere1")]) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3005', 'testGroupAbsolute is only available in UFE preview version 0.3.5 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testGroupAbsolute is only available in UFE v3 or greater.') def testGroupAbsolute(self): '''Verify -absolute flag.''' @@ -405,7 +404,7 @@ def testGroupAbsolute(self): "xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"))) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3005', 'testGroupRelative is only available in UFE preview version 0.3.5 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testGroupRelative is only available in UFE v3 or greater.') def testGroupRelative(self): '''Verify -relative flag.''' cmds.file(new=True, force=True) @@ -440,7 +439,7 @@ def testGroupRelative(self): self.assertFalse(newspherePrim.HasAttribute('xformOp:rotateXYZ')) self.assertFalse(newspherePrim.HasAttribute('xformOp:scale')) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3005', 'testGroupWorld is only available in UFE preview version 0.3.5 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testGroupWorld is only available in UFE v3 or greater.') def testGroupWorld(self): '''Verify -world flag.''' cmds.file(new=True, force=True) @@ -483,7 +482,7 @@ def testGroupWorld(self): stage.GetPrimAtPath("/group2/Sphere2"), stage.GetPrimAtPath("/group2/Sphere3")]) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3005', 'testGroupUndoRedo is only available in UFE preview version 0.3.5 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testGroupUndoRedo is only available in UFE v3 or greater.') def testGroupUndoRedo(self): '''Verify grouping after multiple undo/redo.''' cmds.file(new=True, force=True) @@ -528,7 +527,7 @@ def testGroupUndoRedo(self): stage.GetPrimAtPath("/group1/Sphere2"), stage.GetPrimAtPath("/group1/Sphere3")]) - @unittest.skipIf(mayaUtils.previewReleaseVersion() < 128, 'Test requires fix in Maya Preview Release 128 or greater.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testGroupHierarchy(self): '''Grouping a node and a descendant.''' # MAYA-112957: when grouping a node and its descendant, with the node @@ -647,7 +646,7 @@ def checkAfter(a, b, c, e, f, g): children = hierarchyAfter() checkAfter(*children) - @unittest.skipIf(mayaUtils.previewReleaseVersion() < 128, 'Test requires fix in Maya Preview Release 128 or greater.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testGroupHierarchyWithRenaming(self): '''Grouping a node and a descendant when all descendants share the same name''' # MAYA-113532: when grouping a node and its descendant sharing the same name, we need to diff --git a/test/lib/ufe/testMoveCmd.py b/test/lib/ufe/testMoveCmd.py index fcd3aaa56a..c8fcbed21f 100644 --- a/test/lib/ufe/testMoveCmd.py +++ b/test/lib/ufe/testMoveCmd.py @@ -395,7 +395,7 @@ def createCommonAPI(testCase, sphereXformable): self.runTestOpUndo(createCommonAPI, 'xformOp:translate') - @unittest.skipUnless(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3014', 'Creating a SceneItem was fixed in UFE v3.14') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() < 3, 'Creating a SceneItem was fixed in UFE v3.') def testBadSceneItem(self): '''Improperly constructed scene item should not crash Maya.''' @@ -428,7 +428,7 @@ def testBadSceneItem(self): cmds.move(0, 10, 0, relative=True, os=True, wd=True) - @unittest.skipUnless(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') >= '3014', 'Creating a SceneItem works in UFE v3.14') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'Creating a SceneItem works in UFE v3.') def testFactorySceneItem(self): '''A scene item can be constructed directly and will work.''' diff --git a/test/lib/ufe/testObject3d.py b/test/lib/ufe/testObject3d.py index 5ada6bc1e7..dde2903e2b 100644 --- a/test/lib/ufe/testObject3d.py +++ b/test/lib/ufe/testObject3d.py @@ -494,7 +494,7 @@ def testMayaHideAndShowHiddenUndoCommands(self): self.assertTrue(bool(primSpecCylinder and UsdGeom.Tokens.visibility in primSpecCylinder.attributes)) # MAYA-114407: Hide the stage, then reveal a stage item. The stage must unhide without crashing. - if mayaUtils.previewReleaseVersion() >= 131: + if mayaUtils.mayaMajorVersion() >= 2023: cmds.hide(proxyShape) self.assertEqual(cmds.getAttr("%s.visibility" % proxyShape), 0) cmds.showHidden("%s,/Cylinder1" % proxyShape, above=True) diff --git a/test/lib/ufe/testParentCmd.py b/test/lib/ufe/testParentCmd.py index de8760e8e6..d2b9fdaf11 100644 --- a/test/lib/ufe/testParentCmd.py +++ b/test/lib/ufe/testParentCmd.py @@ -280,7 +280,7 @@ def testParentAbsolute(self): cylChildren = cylHier.children() self.assertEqual(len(cylChildren), 1) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 123, 'Requires Maya fixes only available in Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testParentAbsoluteSingleMatrixOp(self): """Test parent -absolute on prim with a single matrix op.""" @@ -413,7 +413,7 @@ def testParentAbsoluteSingleMatrixOp(self): cylChildren = cylHier.children() self.assertEqual(len(cylChildren), 1) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 123, 'Requires Maya fixes only available in Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testParentAbsoluteFallback(self): """Test parent -absolute on prim with a fallback Maya transform stack.""" # Create a scene with an xform and a capsule. @@ -535,7 +535,7 @@ def checkParentDone(): checkParentDone() - @unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 123, 'Requires Maya fixes only available in Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testParentAbsoluteMultiMatrixOp(self): """Test parent -absolute on prim with a transform stack with multiple matrix ops.""" @@ -1052,7 +1052,7 @@ def testParentingToGPrim(self): cmds.parent("|Tree_usd|Tree_usdShape,/TreeBase/trunk", "|Tree_usd|Tree_usdShape,/TreeBase/leavesXform/leaves") - @unittest.skipIf(mayaUtils.previewReleaseVersion() < 128, 'Test requires fix in Maya Preview Release 128 or greater.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testParentHierarchy(self): '''Parenting a node and a descendant.''' diff --git a/test/lib/ufe/testRotatePivot.py b/test/lib/ufe/testRotatePivot.py index e4cb974b21..2ca29990b4 100644 --- a/test/lib/ufe/testRotatePivot.py +++ b/test/lib/ufe/testRotatePivot.py @@ -189,7 +189,7 @@ def testRotatePivotCmd(self): # Start with a non-zero initial rotation. This is required to test # MAYA-112175, otherwise a zero initial rotation means rotate pivot # translation will be empty and we get the correct result by accident. - if (mayaUtils.previewReleaseVersion() >= 127): + if (mayaUtils.mayaMajorVersion() >= 2023): cmds.rotate(0, 0, 90) print(type(pivot)) pivot = om.MPoint(0, 10, 0) @@ -219,7 +219,7 @@ def testRotatePivotCmd(self): sphereMatrix = om.MMatrix(t3d.inclusiveMatrix().matrix) self.checkPos(sphereMatrix, rotatedPosition) - if (mayaUtils.previewReleaseVersion() >= 127): + if (mayaUtils.mayaMajorVersion() >= 2023): cmds.undo() cmds.move(10, 10, 0, absolute=True) sphereMatrix = om.MMatrix(t3d.inclusiveMatrix().matrix) diff --git a/test/lib/ufe/testSelection.py b/test/lib/ufe/testSelection.py index aaf3bfcffb..2228aa7bb8 100644 --- a/test/lib/ufe/testSelection.py +++ b/test/lib/ufe/testSelection.py @@ -275,7 +275,7 @@ def testMayaSelectFlags(self): self.assertTrue(globalSn.contains(first.path())) self.assertEqual(globalSn.back(), first) - @unittest.skipUnless(((ufeUtils.ufeFeatureSetVersion() >= 2) and (mayaUtils.previewReleaseVersion() >= 123)), 'testMayaSelectMuteLayer only available in UFE v2 or greater and Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only avaiable in Maya 2023 or greater.') def testMayaSelectMuteLayer(self): '''Stale selection items must be removed on mute layer.''' @@ -350,7 +350,7 @@ def testMayaSelectMuteLayer(self): self.assertTrue(sn.empty()) - @unittest.skipUnless(((ufeUtils.ufeFeatureSetVersion() >= 2) and (mayaUtils.previewReleaseVersion() >= 123)), 'testMayaSelectSwitchVariant only available in UFE v2 or greater and Maya Preview Release 123 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testMayaSelectSwitchVariant(self): '''Stale selection items must be removed on variant switch.''' @@ -445,7 +445,7 @@ def testMayaSelectSwitchVariant(self): self.assertTrue(sn.empty()) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 126, 'Requires Maya fixes only available in Maya Preview Release 126 or later.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testMayaSelectUndoPrimCreation(self): '''Test if the SceneItem's prim is still valid on selection after the prim creation is undone then redone''' diff --git a/test/lib/ufe/testSelectionByArray.py b/test/lib/ufe/testSelectionByArray.py index e1e5bbeb8c..94283cdf5c 100644 --- a/test/lib/ufe/testSelectionByArray.py +++ b/test/lib/ufe/testSelectionByArray.py @@ -86,7 +86,7 @@ def makeUsdPath(name): # Clear selection to start off cmds.select(clear=True) - @unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2022, 'testSelectMayaPathInMel only works starting with Maya 2022.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2022, 'Requires Maya fixes only available in Maya 2022 or greater.') def testSelectMayaPathInMel(self): """ Select multiple Maya items by passing them in an array to a mel command. @@ -97,7 +97,7 @@ def testSelectMayaPathInMel(self): sn = ufe.GlobalSelection.get() self.assertEqual(len(sn), 3) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() > 130, 'testSelectUFEInMel only works with fixes available in Maya 2023 after PR 130.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testSelectUFEInMel(self): """ Select multiple UFE items by passing them in an array to a mel command. @@ -108,7 +108,7 @@ def testSelectUFEInMel(self): sn = ufe.GlobalSelection.get() self.assertEqual(len(sn), 3) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() > 130, 'testSelectUFEAndMayaInMel only works with fixes available in Maya 2023 after PR 130.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testSelectUFEAndMayaInMel(self): """ Select a mix of Maya and UFE items by passing them in an array to a mel command. @@ -124,7 +124,7 @@ def testSelectUFEAndMayaInMel(self): sn = ufe.GlobalSelection.get() self.assertEqual(len(sn), 6) - @unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2022, 'testSelectMayaPathInPython only works starting with Maya 2022.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2022, 'Requires Maya fixes only available in Maya 2022 or greater.') def testSelectMayaPathInPython(self): """ Select multiple Maya items by passing them in an array to a Python command. @@ -135,7 +135,7 @@ def testSelectMayaPathInPython(self): sn = ufe.GlobalSelection.get() self.assertEqual(len(sn), 3) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() > 130, 'testSelectUFEInPython only works with fixes available in Maya 2023 after PR 130.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testSelectUFEInPython(self): """ Select multiple UFE items by passing them in an array to a Python command. @@ -146,7 +146,7 @@ def testSelectUFEInPython(self): sn = ufe.GlobalSelection.get() self.assertEqual(len(sn), 3) - @unittest.skipUnless(mayaUtils.previewReleaseVersion() > 130, 'testSelectUFEAndMayaInPython only works with fixes available in Maya 2023 after PR 130.') + @unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.') def testSelectUFEAndMayaInPython(self): """ Select a mix of Maya and UFE items by passing them in an array to a Python command. diff --git a/test/lib/ufe/testUngroupCmd.py b/test/lib/ufe/testUngroupCmd.py index 66314fce11..f0f692bf0e 100644 --- a/test/lib/ufe/testUngroupCmd.py +++ b/test/lib/ufe/testUngroupCmd.py @@ -358,7 +358,7 @@ def testUngroupLeaf(self): # ungroup cmds.ungroup(ufe.PathString.string(sphere1Path)) - @unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3004', 'testUngroupSelectionAfterUndoRedo is only available in UFE preview version 0.3.4 and greater') + @unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 3, 'testUngroupSelectionAfterUndoRedo is only available in UFE v3 or greater.') def testUngroupSelectionAfterUndoRedo(self): ''' ''' # create a sphere generator diff --git a/test/lib/usd/translators/testUsdExportImportRoundtripPreviewSurface.py b/test/lib/usd/translators/testUsdExportImportRoundtripPreviewSurface.py index 96617357cb..3ec7b1de5e 100644 --- a/test/lib/usd/translators/testUsdExportImportRoundtripPreviewSurface.py +++ b/test/lib/usd/translators/testUsdExportImportRoundtripPreviewSurface.py @@ -63,7 +63,7 @@ def testUsdPreviewSurfaceRoundtripSpecular(self): def testUsdPreviewSurfaceRoundtripMetallic(self): self.__testUsdPreviewSurfaceRoundtrip(metallic=True) - @unittest.skipUnless("mayaUtils" in globals() and mayaUtils.previewReleaseVersion() >= 126 and Usd.GetVersion() > (0, 21, 2), 'Requires MaterialX support.') + @unittest.skipUnless("mayaUtils" in globals() and mayaUtils.mayaMajorVersion() >= 2023 and Usd.GetVersion() > (0, 21, 2), 'Requires MaterialX support.') def testUsdPreviewSurfaceRoundtripMaterialX(self): self.__testUsdPreviewSurfaceRoundtrip(metallic=True, convertTo="MaterialX") diff --git a/test/testUtils/mayaUtils.py b/test/testUtils/mayaUtils.py index 265c02ef4e..a11688fad2 100644 --- a/test/testUtils/mayaUtils.py +++ b/test/testUtils/mayaUtils.py @@ -263,6 +263,8 @@ def previewReleaseVersion(): If the version of Maya is 2020, returns 110. + If the version of Maya is 2022, returns 122. + If the version of Maya is current and is not a Preview Release, returns sys.maxsize (a very large number). If the environment variable MAYA_PREVIEW_RELEASE_VERSION_OVERRIDE is defined, return its value instead.