Only use site.USER_SITE is ENABLE_USER_SITE is set

Fixes loading packages from user site even in a virtual environment.

Should fix #42978.
This commit is contained in:
Milan Straka 2020-12-04 11:05:21 +01:00
parent 7beefe17ee
commit 5a190aca86

View File

@ -116,7 +116,8 @@ from tensorflow.python.lib.io import file_io as _fi
# Get sitepackages directories for the python installation.
_site_packages_dirs = []
_site_packages_dirs += [] if _site.USER_SITE is None else [_site.USER_SITE]
if _site.ENABLE_USER_SITE and _site.USER_SITE is not None:
_site_packages_dirs += [_site.USER_SITE]
_site_packages_dirs += [_p for _p in _sys.path if 'site-packages' in _p]
if 'getsitepackages' in dir(_site):
_site_packages_dirs += _site.getsitepackages()