Skip to content

Commit fee5860

Browse files
Copilotromangolev
andauthored
[WIP] Fix cannot open plugin in Revit 2019 (#3357)
* Initial plan * Guard new loader for Revit < 2021: fall back to legacy Python loader with deprecation warning Agent-Logs-Url: https://github.com/pyrevitlabs/pyRevit/sessions/041bf213-bde3-458a-915d-b1e9dd218d3c Co-authored-by: romangolev <67314258+romangolev@users.noreply.github.com> * Use HOST_APP.is_older_than() for version comparison instead of int() cast Agent-Logs-Url: https://github.com/pyrevitlabs/pyRevit/sessions/041bf213-bde3-458a-915d-b1e9dd218d3c Co-authored-by: romangolev <67314258+romangolev@users.noreply.github.com> * Change deprecation/fallback messages from warning to debug, fix 'future release' -> 'future releases' Agent-Logs-Url: https://github.com/pyrevitlabs/pyRevit/sessions/11659bb4-5401-4c6d-9352-68b7ec99f902 Co-authored-by: romangolev <67314258+romangolev@users.noreply.github.com> * Use warning level for forced legacy-loader fallback on old Revit versions Agent-Logs-Url: https://github.com/pyrevitlabs/pyRevit/sessions/ed0545a9-44ee-41f5-9160-3421e880d4c8 Co-authored-by: romangolev <67314258+romangolev@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: romangolev <67314258+romangolev@users.noreply.github.com>
1 parent 496e71b commit fee5860

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pyrevitlib/pyrevit/loader/sessionmgr.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
# Build strategy constant (Roslyn is the only supported strategy)
5050
BUILD_STRATEGY_ROSLYN = "Roslyn"
5151

52+
# Minimum Revit version that supports the new C# loader.
53+
# Revit 2019/2020 ship an older .NET Framework and system assemblies
54+
# (System.Runtime.CompilerServices.Unsafe, System.Collections.Immutable)
55+
# that are incompatible with the Roslyn version bundled in pyRevit.
56+
NEW_LOADER_MIN_REVIT_VERSION = 2021
57+
5258

5359
AssembledExtension = namedtuple("AssembledExtension", ["ext", "assm"])
5460

@@ -389,6 +395,23 @@ def load_session():
389395
# create a new session
390396
if not user_config.new_loader:
391397
mlogger.info("Creating new pyRevit session with pyRevitLoader.py...")
398+
mlogger.debug(
399+
"The legacy Python loader is deprecated and will be removed in "
400+
"future releases. Enable the new loader in pyRevit settings."
401+
)
402+
_new_session()
403+
elif HOST_APP.is_older_than(NEW_LOADER_MIN_REVIT_VERSION):
404+
mlogger.warning(
405+
"The new C# loader is not supported on Revit %s (requires Revit %s+). "
406+
"Falling back to the legacy Python loader automatically.",
407+
HOST_APP.version,
408+
NEW_LOADER_MIN_REVIT_VERSION,
409+
)
410+
mlogger.warning(
411+
"The legacy Python loader is deprecated and will be removed in "
412+
"future releases. Upgrade to Revit %s or newer to use the new loader.",
413+
NEW_LOADER_MIN_REVIT_VERSION,
414+
)
392415
_new_session()
393416
else:
394417
mlogger.info("Creating new Session with pyRevitAssemblyMaker.dll...")

0 commit comments

Comments
 (0)