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

relocatable activate for bash, dash, zsh, ksh, fish, Windows #236

Closed
wants to merge 9 commits into from

Conversation

jpenney
Copy link

@jpenney jpenney commented Mar 6, 2012

Updated activate.bat, activate.fish, and activate.sh that set VIRTUAL_ENV based on where the the activate.* file is sourced or executed from.

See: #11

Also contains tempfile -> mktemp change from #8 since I needed to in order to verify the activate.fish change.

@kbrowder
Copy link

kbrowder commented Apr 2, 2012

Wow this is exactly what I need for one of my project when will this make it in to the official dev branch?

@carljm
Copy link

carljm commented Apr 3, 2012

I'm really not a fan of this. I don't like --relocatable in the first place, it's implementation, or the pattern of virtualenv usage that it encourages. If I could go back in time and remove --relocatable from ever having been added to virtualenv, I'd do it in an instant.

One of the most difficult bits of keeping virtualenv maintained is maintaining all of the activation scripts. I'd like to be finding ways to simplify them, but this does the opposite - it makes them significantly more complex and makes it harder to verify their correctness.

I guess in the end I'm a -0 here. I'm not going to merge it, but I won't stand in the way if @jezdez wants to.

@carljm
Copy link

carljm commented Apr 3, 2012

I should have also added that regardless, I very much appreciate the contribution and the time that went into it! Thank you.

@jpenney
Copy link
Author

jpenney commented Apr 3, 2012

Thanks. I actually agree fully that the activate.sh stuff is messy (Windows and fish were pretty straightforward). I was hoping there was a nice portable solution, but it seems every shell handles it differently, which is a shame.

I have a specific case where I have a need for relocatable, but normally I don't use it either. Still these changes should be transparent if you are NOT using the relocatable stuff.

@carljm
Copy link

carljm commented Apr 3, 2012

Yeah, they should be transparent, but just the added complexity alone worries me - I don't know what other bugs we might be introducing that we won't find out about until later, or maintenance difficulties down the road. Interested to know what @jezdez thinks.

@jezdez
Copy link
Member

jezdez commented Jun 22, 2012

Yeah, I agree with @carljm that the complexity of the activation scripts is bothersome.

@robi-wan
Copy link

robi-wan commented Jul 4, 2012

Here is another suggestion for making activate.bat more relocatable:
It uses another approach for dynamically determining the directory of the virtual env and
it also changes the prompt.

virtualenv.py | 9 +++++----
virtualenv_embedded/activate.bat | 6 ++++--
2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/virtualenv.py b/virtualenv.py
index 0ad059b..eede4d4 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -2148,10 +2148,11 @@ i4Un70/3X5WjwzZMlciUNff39a5T/N3difzB/qM0y71r7H5Wv4DubrNS4VPRvDPW/FmM/QUd6WEa

##file activate.bat
ACTIVATE_BAT = convert("""
-eJyFUkEKgzAQvAfyhz0YaL9QEWpRqlSjWGspFPZQTevFHOr/adQaU1GaUzI7Mzu7ZF89XhKkEJS8
-qxaKMMsvboQ+LxxE44VICSW1gEa2UFaibqoS0iyJ0xw2lIA6nX5AHCu1jpRsv5KRjknkac9VLVug
-sX9mtzxIeJDE/mg4OGp47qoLo3NHX2jsMB3AiDht5hryAUOEifoTdCXbSh7V0My2NMq/Xbh5MEjU
-ZT63gpgNT9lKOJ/CtHsvT99re3pX303kydn4HeyOeAg5cjf2EW1D6HOPkg9NGKhu
+eJyFkk+LgzAQxe+BfIehdEAvZc9bhLUYqmwbxWYLhYUcVtN6McuuZz/7Jv7fougpzrz3y8wjb/nX
+Q4NWihKlfwDxCEUJzgbr7Ptlt9u4kGm4MAHy4F+YDKLUQ6zVkZLfvIJrlIoP/yQZv3o4KJASSgoF
+pa4gy1VR5hkkaXxOBDiUgPmst61422RrYG5n6eUyPgWypy96cUaGa7CbCGMexmfWA1viUH6mDo2e
+bOUzF3s4DLCSpIlIct/ehHXZJdkxHBy66MJI/LfPwgoLY5u5pivMbbwWmS/C1mIOz/GYEu7hriuz
+3HuU2P/5kBpvI7f911E8kifPCT+lPES8SULK/cTIeEDJHzLSu6g=
""")

##file deactivate.bat
diff --git a/virtualenv_embedded/activate.bat b/virtualenv_embedded/activate.bat
index 1b06941..4d58b98 100644
--- a/virtualenv_embedded/activate.bat
+++ b/virtualenv_embedded/activate.bat
@@ -1,5 +1,6 @@
@echo off
-set VIRTUAL_ENV=VIRTUAL_ENV
+for %%G in ("%~dp0..") do SET _BASE_DIR=%%~fG
+set VIRTUAL_ENV=%_BASE_DIR%

if not defined PROMPT (
set PROMPT=$P$G
@@ -14,7 +15,8 @@ if defined _OLD_VIRTUAL_PYTHONHOME (
)

set _OLD_VIRTUAL_PROMPT=%PROMPT%
-set PROMPT=VIRTUAL_WINPROMPT %PROMPT%
+for %%G in ("%~dp0..") do SET _DIR_NAME=%%~nG
+set PROMPT=(%_DIR_NAME%) %PROMPT%

if defined PYTHONHOME (
set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%

@pnasrat
Copy link

pnasrat commented Oct 24, 2012

Can you ensure this is mergeable and I'll take another look.

@elistevens
Copy link

Any traction on this?

@geordanr
Copy link

+1

@hex108
Copy link

hex108 commented Nov 20, 2014

+1 for this feature, it is very useful when you need to copy the virtual environment to another directory.

@pfmoore
Copy link
Member

pfmoore commented Nov 20, 2014

I'm with @carljm I'm afraid. I don't like --relocatable (I'm not sure it even works on Windows, where the exe wrappers can't be updated) and so I don't see any value in added complexity to the activate scripts to support a usage I don't want to encourage.

@bukzor
Copy link

bukzor commented Jan 1, 2015

+1

@bukzor
Copy link

bukzor commented Jan 1, 2015

It's really uncomfortable that this fairly complex behavioral change doesn't necessitate any changes to the test suite =/

@Ivoz
Copy link

Ivoz commented Jan 1, 2015

@bukzor you could call the test suite fairly non-existent atm, which is why :(

@dstufft dstufft mentioned this pull request Jan 5, 2015
5 tasks
@Ivoz Ivoz force-pushed the develop branch 2 times, most recently from d33e617 to 1682ed6 Compare September 20, 2015 16:57
@aknight1969
Copy link

+1

@BrownTruck
Copy link

Hello!

As part of an effort to ease the contribution process and adopt a more standard workflow pip has switched to doing development on the master branch. However, this Pull Request was made against the develop branch so it will need to be resubmitted against master. Unfortunately, this pull request does not cleanly merge against the current master branch.

If you do nothing, this Pull Request will be automatically closed by @BrownTruck since it cannot be merged.

If this pull request is still valid, please rebase it against master (or merge master into it) and resubmit it against the master branch, closing and referencing the original Pull Request.

If you choose to rebase/merge and resubmit this Pull Request, here is an example message that you can copy and paste:

Updated activate.bat, activate.fish, and activate.sh that set VIRTUAL_ENV based on where the the activate.* file is sourced or executed from.

See: #11

Also contains tempfile -> mktemp change from #8 since I needed to in order to verify the activate.fish change.

---

*This was migrated from pypa/virtualenv#236 to reparent it to the ``master`` branch. Please see original pull request for any previous discussion.*

@BrownTruck
Copy link

This Pull Request was closed because it cannot be automatically reparented to the master branch and it appears to have bit rotted.

Please feel free to re-open it or re-submit it if it is still valid and you have rebased it onto master or merged master into it.

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.

None yet