Why does virtualenv not create a DLL folder?

I am wondering what is the reason virtualenv does not create the DLLs folder in the same way that it creates Lib and Scripts ones?

The question came to me when I had the following problem with PyDev:
I installed one of my virtualenvs as a Python interpreter, and everything was fine with one exception. I continued to receive unauthorized import warnings for all imports from the select module. This is due to the fact that the select module, unlike most others, is present only in the DLL folder.

+8
python windows dll virtualenv pydev
source share
3 answers

I explored this topic a bit more. I started with a Techtonik statement. The answer is simple - no one has implemented it. This, however, raises another question - why didn’t anyone implement it? I suspect the answer is because it works. This leads to another question - why does it work?

The reason that everything works without the DLLs folder copied to virtualenv is because

  • Python searches sys.path to find whatever DLL it needs.
  • sys.path after virtualenv activation contains the path to the source sys.path folder

You can simply test the first statement by removing the path to the DLLs folder from sys.path and trying to import the select module (this module needs the select.pyd file from the DLLs ), which then fails.

In the comment you are saying, I would like to save the Python module DLLs in a virtual environment along with the Python code. This is possible by simply copying the DLLs folder to virtualenv. The reason for this is that sys.path after activating virtualenv, also contains the path to the DLLs folder inside virtualenv (although this folder is not created when creating virtualenv). This path is placed in front of the road into the source DLLs folder, which means that the search is performed first and thus overrides the source DLLs folder.

I sent a question called a DLL folder in Windows to the Python mailing list.

+8
source share

The answer is simple - no one has implemented it. When I created a patch for copying pythonXX.dll to a virtual environment - I was solving another problem:

When Python is installed on a system-wide system - the python.exe binary that is copied to virtualenv can always find its pythonXX.dll, because this .dll is accessible from Windows \ System32. If Python is installed only for the current user - pythonXX.dll is placed in the PythonXX directory where the source python.exe file is located. Thus, the problem I was solving was fixing virtualenvs created using Python installed for the current user. It was a pretty difficult task to dig it all out.

Back to the question. I really don't know how this pythonXX.dll finds its DLL modules - this is a question for Python developers, but I suspect that it does not find them. The reason I did not fix this problem while fixing issue # 87 was because my code probably never used modules from this DLL.

+6
source share

IMO there are more reasons for this:

  • Security. In some environments, the policy is to prohibit the execution / download of materials from random locations in an attempt to prevent security breaches. Thus,
  • Somewhat famous DLL load order , which prevents the download of malicious dll :). See also here.

NTN

+3
source share

All Articles