Skip to content

Commit

Permalink
Fix cross-major creation on Windows of activate_this.py throws… (#1730)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat authored Mar 18, 2020
1 parent 59ea2ef commit 893050e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/1710.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``activate_this.py`` throws ``AttributeError`` on Windows when virtual environment was created via cross python
mechanism - by :user:`gaborbernat`.
4 changes: 2 additions & 2 deletions src/virtualenv/activation/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
from collections import OrderedDict

from virtualenv.info import WIN_CPYTHON_2
from virtualenv.util.path import Path
from virtualenv.util.six import ensure_text

Expand All @@ -17,10 +16,11 @@ def templates(self):
def replacements(self, creator, dest_folder):
replacements = super(PythonActivator, self).replacements(creator, dest_folder)
lib_folders = OrderedDict((os.path.relpath(str(i), str(dest_folder)), None) for i in creator.libs)
win_py2 = creator.interpreter.platform == "win32" and creator.interpreter.version_info.major == 2
replacements.update(
{
"__LIB_FOLDERS__": ensure_text(os.pathsep.join(lib_folders.keys())),
"__DECODE_PATH__": ("yes" if WIN_CPYTHON_2 else ""),
"__DECODE_PATH__": ("yes" if win_py2 else ""),
}
)
return replacements
Expand Down

0 comments on commit 893050e

Please sign in to comment.