Skip to content

Commit 28f9d35

Browse files
committed
Merge branch 'release/4.6.22'
2 parents 875e3b2 + be27057 commit 28f9d35

File tree

3 files changed

+61
-11
lines changed

3 files changed

+61
-11
lines changed

pyrevitlib/pyrevit/loader/basetypes/__init__.py

+57-7
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,38 @@
2121
mlogger = get_logger(__name__)
2222

2323

24+
# C:\Windows\Microsoft.NET\Framework\
25+
2426
if not EXEC_PARAMS.doc_mode:
2527
INTERFACE_TYPES_DIR = op.join(LOADER_DIR, 'basetypes')
2628

29+
DOTNET_DIR = op.join(os.getenv('windir'), 'Microsoft.NET','Framework')
30+
2731
DOTNET_SDK_DIR = op.join(os.getenv('programfiles(x86)'),
2832
'Reference Assemblies',
2933
'Microsoft', 'Framework', '.NETFramework')
3034

35+
36+
try:
37+
# get sorted list of installed frawework paths
38+
DOTNET_FRAMEWORK_DIRS = sorted(
39+
[x for x in os.listdir(DOTNET_DIR)
40+
if x.startswith('v4.') and 'X' not in x], reverse=True)
41+
except Exception as dotnet_fw_err:
42+
DOTNET_FRAMEWORK_DIRS = []
43+
mlogger.debug('Dotnet Frawework is not installed. | %s', dotnet_fw_err)
44+
3145
try:
46+
# get sorted list of installed frawework sdk paths
3247
DOTNET_TARGETPACK_DIRS = sorted(
3348
[x for x in os.listdir(DOTNET_SDK_DIR)
3449
if x.startswith('v4.') and 'X' not in x], reverse=True)
3550
except Exception as dotnet_sdk_err:
3651
DOTNET_TARGETPACK_DIRS = []
3752
mlogger.debug('Dotnet SDK is not installed. | %s', dotnet_sdk_err)
3853
else:
39-
INTERFACE_TYPES_DIR = DOTNET_SDK_DIR = DOTNET_TARGETPACK_DIRS = None
54+
DOTNET_DIR = INTERFACE_TYPES_DIR = DOTNET_SDK_DIR = \
55+
DOTNET_FRAMEWORK_DIRS = DOTNET_TARGETPACK_DIRS = None
4056

4157

4258
# base classes for pyRevit commands --------------------------------------------
@@ -67,6 +83,7 @@
6783
# get and load the active Cpython engine
6884
CPYTHON_ENGINE = user_config.get_active_cpython_engine()
6985
CPYTHON_ENGINE_ASSM = CPYTHON_ENGINE.AssemblyPath
86+
mlogger.debug('Loading cpython engine: %s', CPYTHON_ENGINE_ASSM)
7087
load_asm_file(CPYTHON_ENGINE_ASSM)
7188

7289
# create a hash for the loader assembly
@@ -125,41 +142,75 @@ def _get_resource_file(resource_name):
125142

126143

127144
def _get_framework_module(fw_module):
145+
# start with the newest sdk folder and
146+
# work backwards trying to find the dll
147+
for fw_folder in DOTNET_FRAMEWORK_DIRS:
148+
fw_module_file = op.join(DOTNET_DIR,
149+
fw_folder,
150+
make_canonical_name(fw_module,
151+
ASSEMBLY_FILE_TYPE))
152+
mlogger.debug('Searching for installed: %s', fw_module_file)
153+
if op.exists(fw_module_file):
154+
mlogger.debug('Found installed: %s', fw_module_file)
155+
sys.path.append(op.join(DOTNET_DIR, fw_folder))
156+
return fw_module_file
157+
158+
return None
159+
160+
161+
def _get_framework_sdk_module(fw_module):
128162
# start with the newest sdk folder and
129163
# work backwards trying to find the dll
130164
for sdk_folder in DOTNET_TARGETPACK_DIRS:
131165
fw_module_file = op.join(DOTNET_SDK_DIR,
132166
sdk_folder,
133167
make_canonical_name(fw_module,
134168
ASSEMBLY_FILE_TYPE))
169+
mlogger.debug('Searching for sdk: %s', fw_module_file)
135170
if op.exists(fw_module_file):
171+
mlogger.debug('Found sdk: %s', fw_module_file)
136172
sys.path.append(op.join(DOTNET_SDK_DIR, sdk_folder))
137173
return fw_module_file
138174

139175
return None
140176

141177

142178
def _get_reference_file(ref_name):
179+
mlogger.debug('Searching for dependency: %s', ref_name)
143180
# First try to find the dll in the project folder
144181
addin_file = framework.get_dll_file(ref_name)
145182
if addin_file:
146183
load_asm_file(addin_file)
147184
return addin_file
148185

186+
mlogger.debug('Dependency is not shipped: %s', ref_name)
187+
mlogger.debug('Searching for dependency in loaded assemblies: %s', ref_name)
149188
# Lastly try to find location of assembly if already loaded
150189
loaded_asm = find_loaded_asm(ref_name)
151190
if loaded_asm:
152191
return loaded_asm[0].Location
153192

154-
# Then try to find the dll in windows SDK
155-
if DOTNET_TARGETPACK_DIRS:
193+
mlogger.debug('Dependency is not loaded: %s', ref_name)
194+
mlogger.debug('Searching for dependency in installed frameworks: %s',
195+
ref_name)
196+
# Then try to find the dll in windows installed framework files
197+
if DOTNET_DIR:
156198
fw_module_file = _get_framework_module(ref_name)
157199
if fw_module_file:
158200
return fw_module_file
159201

202+
203+
mlogger.debug('Dependency is not installed: %s', ref_name)
204+
mlogger.debug('Searching for dependency in installed frameworks sdks: %s',
205+
ref_name)
206+
# Then try to find the dll in windows SDK
207+
if DOTNET_TARGETPACK_DIRS:
208+
fw_sdk_module_file = _get_framework_sdk_module(ref_name)
209+
if fw_sdk_module_file:
210+
return fw_sdk_module_file
211+
160212
# if not worked raise critical error
161-
mlogger.critical('Can not find required reference assembly: %s',
162-
ref_name)
213+
mlogger.critical('Can not find required reference assembly: %s', ref_name)
163214

164215

165216
def _get_references():
@@ -177,8 +228,7 @@ def _get_references():
177228

178229
refs = [_get_reference_file(ref_name) for ref_name in ref_list]
179230

180-
# add cpython engine dll to references
181-
# _get_reference_file('engines/372/Python.Runtime')
231+
# add cpython engine assembly
182232
refs.append(CPYTHON_ENGINE_ASSM)
183233

184234
return refs

pyrevitlib/pyrevit/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.6.21
1+
4.6.22

release/pyRevit.aip

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
<ROW Property="DialogBitmap" Value="dialog" MultiBuildValue="DefaultBuild:pyRevit1.bmp" Type="1" MsiKey="DialogBitmap"/>
2929
<ROW Property="Manufacturer" Value="Ehsan Iran-Nejad"/>
3030
<ROW Property="MsiLogging" MultiBuildValue="DefaultBuild:vp"/>
31-
<ROW Property="ProductCode" Value="1033:{DB9FCA88-7183-4A7E-9842-798975628854} " Type="16"/>
31+
<ROW Property="ProductCode" Value="1033:{D763A045-F988-4C82-9A94-20645FAD8D83} " Type="16"/>
3232
<ROW Property="ProductLanguage" Value="1033"/>
3333
<ROW Property="ProductName" Value="pyRevit"/>
34-
<ROW Property="ProductVersion" Value="4.6.21" Type="32"/>
34+
<ROW Property="ProductVersion" Value="4.6.22" Type="32"/>
3535
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
3636
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
3737
<ROW Property="UpgradeCode" Value="{CF0C9661-A782-4D2E-A850-C29B657B57AB}"/>
@@ -447,7 +447,7 @@
447447
</COMPONENT>
448448
<COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent">
449449
<ROW Component="ACT" ComponentId="{1C2437CB-91AB-4EEF-B858-DCFDF94CC556}" Directory_="Australia_Dir" Attributes="0" KeyPath="ACT" Type="0"/>
450-
<ROW Component="AI_CustomARPName" ComponentId="{3B7C9776-B777-4A64-8BE8-1A2A91325738}" Directory_="APPDIR" Attributes="260" KeyPath="DisplayName" Options="1"/>
450+
<ROW Component="AI_CustomARPName" ComponentId="{77B45724-FC83-4469-B057-2C3FF98AC06B}" Directory_="APPDIR" Attributes="260" KeyPath="DisplayName" Options="1"/>
451451
<ROW Component="AI_DisableModify" ComponentId="{C77D802D-6409-4BD6-9303-97390842F7D5}" Directory_="APPDIR" Attributes="260" KeyPath="NoModify" Options="1"/>
452452
<ROW Component="AI_ExePath" ComponentId="{505F96D2-054E-4761-AE20-B27603EF0AAB}" Directory_="APPDIR" Attributes="260" KeyPath="AI_ExePath"/>
453453
<ROW Component="Abidjan" ComponentId="{E25482B2-113F-4CD0-9DB0-FA9EAE110FC6}" Directory_="Africa_Dir" Attributes="0" KeyPath="Abidjan" Type="0"/>

0 commit comments

Comments
 (0)