-
Notifications
You must be signed in to change notification settings - Fork 8
Fix virtualenv update for new bash activation script #36
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
base: main
Are you sure you want to change the base?
Fix virtualenv update for new bash activation script #36
Conversation
|
virtualenv 20.36.0 upgrades pip to 25.3 pypa/virtualenv/pull/2989 which includes support for PEP 660 (via pypa/setuptools#3265). PEP 660 adds editable finder files which modules by their path. These now also need to be changed. |
454a3eb to
41f42b0
Compare
28df0ad to
81698c8
Compare
81698c8 to
d105f20
Compare
| path = os.path.join(bin_dir, fname) | ||
| if fname in ACTIVATION_SCRIPTS and activation: | ||
| update_activation_script(path, new_path) | ||
| update_activation_script(path, orig_path, new_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore my last comment, i missed that this is the same function 🤦♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait it isn't; yeah i think maybe old_path in update_activation_script is no longer necessary? unless i'm missing something obvious
| if line != new_line: | ||
| lines[idx] = new_line | ||
| changed = True | ||
| else: | ||
| new_line = _activation_path_re.sub(_handle_sub, line) | ||
| if line != new_line: | ||
| lines[idx] = new_line | ||
| changed = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big deal, but this repeated code can be taken out and be placed after the if-else:
if line != new_line:
lines[idx] = new_line
changed = True
Problem
pypa/virtualenv#2996 (
virtualenv==20.36.0) changes how theVIRTUAL_ENVvariable is defined in the bash activate script. Our tool explicitly reads and parses the activate script for the value ofVIRTUAL_ENV=, which no longer works with the change and breaks withAdditionally, the upstream changes add an explicit exists check for
VIRTUAL_ENV. This must also be changed.Fixes #34.
Solution
Because there are now multiple references to
VIRTUALENV_ENVpath in the bash activation, we must replace them all. We will handle this script differently from the rest of the scripts uses bash-specific regexes.Validation
We added a new test
test_get_orig_pathandtest_update_activation_script. During development, we tested against both older and newer virtualenv. Our change is compatible with both so we don't need to explicitly test different virtualenvs.Note
HLFH in #34 provided their own patch in their fork for this change in HLFH@4971532, but it seems to be targeting a different form of the activation script.
Notes
This is an alternative approach to #35