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 absolute paths for Cygwin #1970

Merged
merged 8 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/virtualenv/activation/bash/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV='__VIRTUAL_ENV__'
VIRTUAL_ENV="$(if [ "$OSTYPE" = "cygwin" ]; then cygpath -u '__VIRTUAL_ENV__'; else echo '__VIRTUAL_ENV__'; fi;)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather have this line un-changed and have a follow-up line that normalizes the env-var (if needed). Let's not cramp things in a single line.

export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/activation/via_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def generate(self, creator):

def replacements(self, creator, dest_folder):
current_platform = sysconfig.get_platform()
platforms = ["mingw", "cygwin", "msys"]
platforms = ["mingw", "msys"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove this section of code entirely if you prefer, just wondered if this would be safer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean someone needs to check if mings, msys works same/different, and if is there a cygpath there. There're also tests you need to ammend/remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I download MinGW/MSYS -- as I understand it, MSYS is an environment built on top of the MinGW tools (http://www.mingw.org/wiki/MSYS). The string that gets returned from sysconfig.get_platform() depends on which flavour you install, but they are all different versions of the same thing.

Running it locally, it seems that MSYS wants paths in the form /c/somePath, and it does not understand Cygwin-style paths:

dn_co@DESKTOP-1TDKNNU /c/Users/dn_co
$ cd /cygdrive/c/
sh: cd: /cygdrive/c/: No such file or directory

So I think the current implementation is good for MSYS/MinGW.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would suffer though from the same problem as cygwin does. Does msys has it's own variant of cygpath that we should be using to offer same guarantees we're offering for cygwin?

Copy link
Contributor

Choose a reason for hiding this comment

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

https://stackoverflow.com/a/12063651 has some detailed answer to this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I can confirm that MSYS has cygpath, so we can approach it in the same way.

if any(platform in current_platform for platform in platforms):
pattern = re.compile("^([A-Za-z]):(.*)")
match = pattern.match(str(creator.dest))
Expand Down