Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/python/nimbusml/internal/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,20 @@ def get_clr_path():
Python 3.x only, as dotnetcore2 is not available for Python 2.x.

@glebuk glebuk Dec 13, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python [](start = 57, length = 6)

do we check the python version here? How do we ensure that we fail of Python 2.7? #Closed

"""
from dotnetcore2 import runtime as clr_runtime
clr_version = pkg_resources.get_distribution('dotnetcore2').version
partial_path = os.path.join(clr_runtime._get_bin_folder(), 'shared', 'Microsoft.NETCore.App')
clr_path = os.path.join(partial_path, clr_version)
if not os.path.exists(clr_path):
# If folder name does not match published version, use the folder that
# exists
try:
version_folder = os.listdir(partial_path)[0]
except IndexError:
raise ImportError("Trouble importing dotnetcore2: "
"{} had no version folder.".format(partial_path))
clr_path = os.path.join(partial_path, version_folder)
# Verify binaries are present
if not os.path.exists(os.path.join(clr_path, 'Microsoft.CSharp.dll')):
raise ImportError(
"Trouble importing dotnetcore2: Microsoft.CSharp.dll was not "
"found in {}.".format(clr_path))
bin_root = os.path.join(clr_runtime._get_bin_folder(), 'shared', 'Microsoft.NETCore.App')

# Search all bin folders to find which one contains the .NET CLR binaries
bin_folders = os.listdir(bin_root)
if len(bin_folders) == 0:
raise ImportError("Trouble importing dotnetcore2: "
"{} had no bin folders.".format(bin_root))

@glebuk glebuk Dec 13, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin [](start = 39, length = 3)

perhaps be specific that bin/shared/ms.netore.app is missing in the message?
#Closed

clr_path = None
for folder in bin_folders:
if os.path.exists(os.path.join(bin_root, folder, 'Microsoft.CSharp.dll')):
clr_path = os.path.join(bin_root, folder)
break
if not clr_path:
raise ImportError(
"Trouble importing dotnetcore2: Microsoft.CSharp.dll was not "
"found in {}.".format(bin_root))
return clr_path