summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Pedrosa <brupelo@gmail.com>2017-09-21 00:50:36 +0200
committerBruno Pedrosa <brupelo@gmail.com>2017-09-21 00:50:36 +0200
commitc5edf1a1a353b8aac4a06ba75eedb04f53be3fb0 (patch)
tree4f906d82ed8393f49b7efdc9694136d5dbba5ab2
parente6c1eaf157cf33c3c88a4edced8e7360692db812 (diff)
downloadvirtualenv-c5edf1a1a353b8aac4a06ba75eedb04f53be3fb0.tar.gz
Fix issue #1050 - Copy additional python dll to the scripts folder so libraries like pyqt5 can import succesfully
-rwxr-xr-xvirtualenv.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/virtualenv.py b/virtualenv.py
index 1a98779..d1c487f 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1241,24 +1241,33 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
elif os.path.exists(python_d_dest):
logger.info('Removed python_d.exe as it is no longer at the source')
os.unlink(python_d_dest)
+
# we need to copy the DLL to enforce that windows will load the correct one.
# may not exist if we are cygwin.
- py_executable_dll = 'python%s%s.dll' % (
- sys.version_info[0], sys.version_info[1])
- py_executable_dll_d = 'python%s%s_d.dll' % (
- sys.version_info[0], sys.version_info[1])
- pythondll = os.path.join(os.path.dirname(sys.executable), py_executable_dll)
- pythondll_d = os.path.join(os.path.dirname(sys.executable), py_executable_dll_d)
- pythondll_d_dest = os.path.join(os.path.dirname(py_executable), py_executable_dll_d)
- if os.path.exists(pythondll):
- logger.info('Also created %s' % py_executable_dll)
- shutil.copyfile(pythondll, os.path.join(os.path.dirname(py_executable), py_executable_dll))
- if os.path.exists(pythondll_d):
- logger.info('Also created %s' % py_executable_dll_d)
- shutil.copyfile(pythondll_d, pythondll_d_dest)
- elif os.path.exists(pythondll_d_dest):
- logger.info('Removed %s as the source does not exist' % pythondll_d_dest)
- os.unlink(pythondll_d_dest)
+ py_executable_dlls = [
+ (
+ 'python%s.dll' % (sys.version_info[0]),
+ 'python%s_d.dll' % (sys.version_info[0])
+ ),
+ (
+ 'python%s%s.dll' % (sys.version_info[0], sys.version_info[1]),
+ 'python%s%s_d.dll' % (sys.version_info[0], sys.version_info[1])
+ )
+ ]
+
+ for py_executable_dll, py_executable_dll_d in py_executable_dlls:
+ pythondll = os.path.join(os.path.dirname(sys.executable), py_executable_dll)
+ pythondll_d = os.path.join(os.path.dirname(sys.executable), py_executable_dll_d)
+ pythondll_d_dest = os.path.join(os.path.dirname(py_executable), py_executable_dll_d)
+ if os.path.exists(pythondll):
+ logger.info('Also created %s' % py_executable_dll)
+ shutil.copyfile(pythondll, os.path.join(os.path.dirname(py_executable), py_executable_dll))
+ if os.path.exists(pythondll_d):
+ logger.info('Also created %s' % py_executable_dll_d)
+ shutil.copyfile(pythondll_d, pythondll_d_dest)
+ elif os.path.exists(pythondll_d_dest):
+ logger.info('Removed %s as the source does not exist' % pythondll_d_dest)
+ os.unlink(pythondll_d_dest)
if is_pypy:
# make a symlink python --> pypy-c
python_executable = os.path.join(os.path.dirname(py_executable), 'python')