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

Cygwin and msys2 bash activator compatibility #1940

Closed
yilei opened this issue Sep 12, 2020 · 2 comments · Fixed by #1952
Closed

Cygwin and msys2 bash activator compatibility #1940

yilei opened this issue Sep 12, 2020 · 2 comments · Fixed by #1952
Labels

Comments

@yilei
Copy link

yilei commented Sep 12, 2020

Issue

Run the following via msys2:

$ /c/Users/builder/AppData/Local/Programs/Python/Python39/Scripts/virtualenv.exe --no-pip --no-setuptools --no-wheel -p /c/Users/builder/AppData/Local/Programs/Python/Python39/python.exe /tmp/tmp.uw7eZfvJIO
$ source /tmp/tmp.uw7eZfvJIO/Scripts/activate
$ python
python: command not found

The content of /tmp/tmp.uw7eZfvJIO/Scripts/activate contains VIRTUAL_ENV='C:\tools\msys64\tmp\tmp.uw7eZfvJIO', but it's expected to be VIRTUAL_ENV='/c/tools/msys64/tmp/tmp.uw7eZfvJIO', thus it can't locate python.

I believe the legacy version handles this correctly here:

virtualenv/virtualenv.py

Lines 1742 to 1748 in 4c9899f

home_dir_msys = (drive and "/{}{}" or "{}{}").format(drive[:1], tail)
# Run-time conditional enables (basic) Cygwin compatibility
home_dir_sh = """$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u '{}'; else echo '{}'; fi;)""".format(
home_dir, home_dir_msys
)
files["activate"] = ACTIVATE_SH.replace("__VIRTUAL_ENV__", home_dir_sh)

which contains:

VIRTUAL_ENV="$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u 'C:\tools\msys64\tmp\tmp.uw7eZfvJIO'; else echo '/C/tools/msys64/tmp/tmp.uw7eZfvJIO'; fi;)"

Environment

Provide at least:

  • OS: Windows 7, using msys2 v20200903.0.0
@yilei yilei added the bug label Sep 12, 2020
@gaborbernat gaborbernat changed the title On Windows using msys2, the bash Scripts/activate seems to be broken due to VIRTUAL_ENV starts with c:\... Cygwin bash activator compatibility Sep 12, 2020
@yilei yilei changed the title Cygwin bash activator compatibility Cygwin and msys2 bash activator compatibility Sep 14, 2020
@danyeaw
Copy link
Contributor

danyeaw commented Sep 21, 2020

I am also having this issue. I would be glad to submit a PR if someone could help point me in the right direction. It seems like the creator is correctly building the virtualenv, but we need to modify the path only for setting the VIRTUAL_ENV in the activate script.

@gaborbernat
Copy link
Contributor

gaborbernat commented Sep 21, 2020

gaborbernat pushed a commit that referenced this issue Sep 30, 2020
Closes #1940. In cygwin and MSYS2, the path is in POSIX format.
This PR converts the Windows path to POSIX format using a regex
so that it is added to the bash activation script in the correct
format.
@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants