Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activation paths in cygwin using cygpath #1973

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/1973.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix cygwin path conversion using cygpath - by :user:`danyeaw`.
10 changes: 3 additions & 7 deletions src/virtualenv/activation/via_template.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import absolute_import, unicode_literals

import os
import re
import sys
import sysconfig
from abc import ABCMeta, abstractmethod

from six import add_metaclass

from virtualenv.util.six import ensure_text
from virtualenv.util.subprocess import run_cmd

from .activator import Activator

Expand Down Expand Up @@ -36,12 +36,8 @@ def replacements(self, creator, dest_folder):
current_platform = sysconfig.get_platform()
platforms = ["mingw", "cygwin", "msys"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this variable inline, and make it a tuple? 😊 And end it with a coma to have each name on it's own line to make it merge friendly? Thanks!

if any(platform in current_platform for platform in platforms):
pattern = re.compile("^([A-Za-z]):(.*)")
match = pattern.match(str(creator.dest))
if match:
virtual_env = "/" + match.group(1).lower() + match.group(2)
else:
virtual_env = str(creator.dest)
code, out, err = run_cmd(["cygpath", str(creator.dest)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use _ and __ for the variable names you don't need/use; though you should raise here in error if the code is not zero, not? with the out and error attached to the error

virtual_env = out.decode().strip()
else:
virtual_env = str(creator.dest)
return {
Expand Down