"sitevendor" is required because "sitecustomize" already "taken": imagine
organization XYZ , they install Python/Anaconda for workers in XYZ. Admin
in XYZ places some XYZ-specific code into "sitecustomize". As to "usersite"
- each worker of XYS uses it for their own purposes. This is what we have
now now (in general, as far as I understand the story).
Now we have Anaconda in addition to Python distribution. Where do we
suppose to place startup related code, which is different between Python
and Anaconda ? Example: sys.path to load python py-modules and
os.environ['PATH'] to load DLLs. Anaconda already uses some crazy patch in
Python/main.c code and it is controlled by environment variables like
CONDA_DLL_SEARCH_MODIFICATION_ENABLE. Somebody like you have to explain
Anaconda developers that following sitevendor.py shipped with Anaconda may
solve this problem (as alternative to patching C code). Real problem in
Anaconda is following: attempt to run "python.exe -m conda update --all"
gives error in SSL access to update server. Problem is that OpenSSL.dll was
moved into PythonHome\Lib\Bin and can't be loaded from there when I run
python.exe without activate.bat. Anaconda already solve this problem using
above CONDA_DLL_SEARCH_MODIFICATION_ENABLE and it is totally crazy and it
introduce problem how to set this variable. They can solve it by shipping
sitevendor.py as of:
import os
import sys
prefix = os.path.split(os.path.abspath(sys.executable))[0]
env = os.environ
env['CONDA_DLL_SEARCH_MODIFICATION_ENABLE'] = '1'
env['CONDA_DEFAULT_ENV'] = 'base'
env['CONDA_PREFIX'] = prefix
env['CONDA_SHLVL'] = '1'
# end of first sitevendor example
Next sitevendor.py example presented below:
# this sitevendor.py can theoretically be shipped with Anaconde if they
want, it works for me even without
# any CONDA_DLL_SEARCH_MODIFICATION_ENABLE
import os
import sys
import site
from os.path import join, pathsep
prefix = os.path.split(os.path.abspath(sys.executable))[0]
new_paths = pathsep.join([
prefix, # not required if we start python[w].exe from prefix folder
join(prefix, "Library", "mingw-w64", "bin"),
join(prefix, "Library", "usr", "bin"), # if not exist: see
removeduppath_ex(, True)
join(prefix, "Library", "bin"),
##join(prefix, "Scripts")
])
L = [] # empty array for folders from path
env = os.environ
strpath = new_paths + pathsep + env['PATH'];
# string with combined path to array of folders:
for dir in strpath.split(';') :
L.append(dir);
####print("dir=%s" % (dir))
# remove duplicated and nonexested folders
site.removeduppaths_ex(L , True)
strpath = pathsep.join(L);
### modify environment variables for current process
env['PATH'] = strpath;
env['CONDA_PREFIX'] = prefix
###env['CONDA_DLL_SEARCH_MODIFICATION_ENABLE'] = '1'
# Python module search path:
site.removeduppaths_ex(sys.path , True) # True to remove nonexistent
folder/files
# eof
On Mon, May 13, 2019 at 6:01 AM STINNER Victor <report@bugs.python.org>
wrote:
>
> Change by STINNER Victor <vstinner@redhat.com>:
>
>
> ----------
> nosy: +vstinner
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36891>
> _______________________________________
>
|