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

Fix activation paths in cygwin using cygpath #1973

wants to merge 1 commit into from

Conversation

danyeaw
Copy link
Contributor

@danyeaw danyeaw commented Oct 9, 2020

This PR fixes #1969. It removes use of a regex to transform the path when using cygwin or MSYS2 and instead makes use of the cygpath utility.

@davidcoghlan would you be able to test in cygwin please?

Thanks for contributing, make sure you address all the checklists (for details on how see

development documentation)!

  • ran the linter to address style issues (tox -e fix_lint)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@codecov
Copy link

codecov bot commented Oct 9, 2020

Codecov Report

Merging #1973 into main will increase coverage by 2.25%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1973      +/-   ##
==========================================
+ Coverage   87.45%   89.70%   +2.25%     
==========================================
  Files         174       87      -87     
  Lines        8496     4245    -4251     
==========================================
- Hits         7430     3808    -3622     
+ Misses       1066      437     -629     
Flag Coverage Δ
#tests 89.70% <ø> (+2.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nv/create/via_global_ref/builtin/cpython/mac_os.py
src/virtualenv/app_data/na.py
src/virtualenv/config/ini.py
src/virtualenv/discovery/discover.py
src/virtualenv/util/zipapp.py
src/virtualenv/create/via_global_ref/store.py
src/virtualenv/app_data/base.py
src/virtualenv/discovery/__init__.py
src/virtualenv/run/plugin/activators.py
...ualenv/seed/embed/via_app_data/pip_install/base.py
... and 78 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c0a0d1...9d23f32. Read the comment docs.

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

You'll need to fix the CI

@@ -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!

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

@gaborbernat
Copy link
Contributor

Per #1970 (comment) the regex we have works fine, the issue is different so we can save the subprocess call for now.

@gaborbernat gaborbernat closed this Oct 9, 2020
@davidcoghlan
Copy link
Contributor

Hi @gaborbernat @danyeaw, there are two issues here I think:

  1. The regex maps paths of the form c:\somePath to /c/somePath -- this isn't right for Cygwin, it should be /c/cygdrive/somePath.
  2. If people are using the regular Windows Python build, rather than a Cygwin-specific build, the platform type is reported as win-amd64, so we don't even hit this code path.

We are in group (2) unfortunately, so it's actually a bit difficult for me to test the change you made on this PR. I've tried installing some of the Cygwin Python packages, but it always seems to pick the main Windows Python interpreter when I run virtualenv, and I'm not too sure how to make it pick the Cygwin one.

The change looks good to me though! I suspect you will need something like this to support other Cygwin folks, even if it doesn't work for us due to the second issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtualenv path not set correctly on Cygwin
3 participants