Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
da541bfa
Unverified
Commit
da541bfa
authored
Aug 24, 2020
by
liuzhe-lz
Committed by
GitHub
Aug 24, 2020
Browse files
Hotfix installation problem on Windows without conda/venv (#2793)
Co-authored-by:
liuzhe
<
zhliu1@microsoft.com
>
parent
e6ef08f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
26 deletions
+12
-26
src/sdk/pynni/nni/package_utils.py
src/sdk/pynni/nni/package_utils.py
+12
-26
No files found.
src/sdk/pynni/nni/package_utils.py
View file @
da541bfa
...
...
@@ -286,32 +286,9 @@ def create_customized_class_instance(class_params):
return
instance
def
get_python_dir
(
sitepackages_path
):
if
sys
.
platform
==
"win32"
:
return
str
(
Path
(
sitepackages_path
))
else
:
return
str
(
Path
(
sitepackages_path
).
parents
[
2
])
def
get_nni_installation_parent_dir
():
''' Find nni installation parent directory
'''
def
try_installation_path_sequentially
(
*
sitepackages
):
'''Try different installation path sequentially util nni is found.
Return None if nothing is found
'''
def
_generate_installation_path
(
sitepackages_path
):
python_dir
=
get_python_dir
(
sitepackages_path
)
entry_file
=
os
.
path
.
join
(
python_dir
,
'nni'
,
'main.js'
)
if
os
.
path
.
isfile
(
entry_file
):
return
python_dir
return
None
for
sitepackage
in
sitepackages
:
python_dir
=
_generate_installation_path
(
sitepackage
)
if
python_dir
:
return
python_dir
return
None
if
os
.
getenv
(
'VIRTUAL_ENV'
):
# if 'virtualenv' package is used, `site` has not attr getsitepackages, so we will instead use VIRTUAL_ENV
# Note that conda venv will not have VIRTUAL_ENV
...
...
@@ -321,12 +298,21 @@ def get_nni_installation_parent_dir():
# If system-wide python is used, we will give priority to using `local sitepackage`--"usersitepackages()" given
# that nni exists there
if
python_sitepackage
.
startswith
(
'/usr'
)
or
python_sitepackage
.
startswith
(
'/Library'
):
python_dir
=
try_installation_path_sequentially
(
site
.
getusersitepackages
(),
site
.
getsitepackages
()
[
0
]
)
python_dir
=
_
try_installation_path_sequentially
(
site
.
getusersitepackages
(),
*
site
.
getsitepackages
())
else
:
python_dir
=
try_installation_path_sequentially
(
site
.
getsitepackages
()[
0
],
site
.
getusersitepackages
())
python_dir
=
_try_installation_path_sequentially
(
*
site
.
getsitepackages
(),
site
.
getusersitepackages
())
return
python_dir
def
_try_installation_path_sequentially
(
*
sitepackages
):
'''Try different installation path sequentially util nni is found.
Return None if nothing is found
'''
for
sitepackage
in
sitepackages
:
for
path
in
[
Path
(
sitepackage
).
parents
[
2
],
Path
(
sitepackage
)]:
if
(
path
/
'nni'
/
'main.js'
).
is_file
():
return
str
(
path
)
return
None
def
get_nni_installation_path
():
''' Find nni installation directory
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment