-
Notifications
You must be signed in to change notification settings - Fork 24
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
Windows compatibility when run inside a virtualenv #53
base: master
Are you sure you want to change the base?
Conversation
There should probably be a function for getting the bin dir of a virtual env, but this is not included in this commit for brevity.
Please be more precise with words like "should" and "error." Please do not just make PRs saying that they "should" be included without explaining the technical details of what you're doing and why. On #38 I wrote "This was addressed in October of last year." That is why I closed the issue. My finger didn't slip. |
The October 2014 commit, 685522d, addresses a separate issue than #38 and this PR. This is why I said that #38 was closed erroneously. I thought it would be pretty easy to check and see that this PR fixes an issue that has not yet been fixed, but just to clarify, you can look at the block of code changed by this PR (and #38) in the current version of vex: Lines 42 to 59 in b7680c4
Vex tries to remove bin paths of any existing venvs and failing that it raises an error. This is a problem on windows because if you are in an existing venv, there won't be a bin dir in the path, there will a Scripts dir instead. The effect of this is that if vex is "run inside a virtualenv", it will always fail on windows.
I suggested that the behavior of getting the correct bin/Scripts dir of a venv "should" be put in a function because this is done in a couple different places throughout the code, so creating a function (or a I think that #38 has some advantages over my fix since it deals with paths that are prefixed with something different but equivalent to the |
I decided to add a commit to (hopefully) do what #38 was trying to do wrt normalization correctly. I have not tested it yet though, so don't merge yet. I removed the error altogether because I don't think it is particularly useful and it doesn't arise naturally from the way I did things. |
Ok, I'm convinced that my new commit works now. I'm still not entirely convinced it is necessary, but IDK, maybe some venv tools setup the environment variables in a weird way that makes it necessary. I wonder if @cwacek ran into an actual issue with it that prompted him to do the normalization. |
Yes I did. I wasn’t doing it for fun ;)
However, that was a long time ago so I don’t remember what might have caused it.
|
The way that virtualenv activation mangles But it also doesn't matter that much, because the case of trying somehow to run one virtualenv inside another is bizarre and has no real application. It's impossible to tell exactly what the user might have meant from outside a shell that sourced activate. Really vex should just barf and bail if At the time I wrote this check, I was willing to deal with a simple user error that was likely to occur: forgetting you're in a virtualenv and then trying to activate another one. I was willing to handle this in a way reasonably similar to what you'd get if you ran activate again, given the kind of environment that migth be produced by using virtualenv. This doesn't mean I was committing to rescuing every conceivable nonsensical environment by guessing what the user really meant to happen, when it is impossible to know. If the environment is too wacky then really the user should know that and bug reports should make their way upstream. You might think vex should be changed any time you meet any inconvenience (instead of figuring out where the inconvenience was actually caused) but it's actually making everything worse if vex is guessing what the user wants and suppressing other tools' bugs. If This kind of nonsense is exactly why I wanted vex to use a subprocess instead of munging the environment it lives in. I think the idea of removing all occurrences of a bin path from PATH is wrong. If you read
|
I think you're missing the main point of this pull request. As I've said earlier, the main thing this change is meant to fix is that on windows the bin dir is In retrospect, you are correct that removing every matching path from |
There should probably be a function for getting the bin dir of a virtual env, but this is not included in this commit for brevity.
Edit: Looks like this is essentially equivalent to one of the changes in #38, which was closed, however this issue still exists so it seems to have been closed erroneously.