Skip to content

Conversation

@ymilki
Copy link
Member

@ymilki ymilki commented Jan 12, 2026

Problem

pypa/virtualenv#2996 (virtualenv==20.36.0) changes how the VIRTUAL_ENV variable is defined in the bash activate script. Our tool explicitly reads and parses the activate script for the value of VIRTUAL_ENV=, which no longer works with the change and breaks with

AssertionError: Could not find VIRTUAL_ENV= in activation script: venv/bin/activate

Additionally, 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_ENV path 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_path and test_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

@ymilki
Copy link
Member Author

ymilki commented Jan 14, 2026

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.

__editable___myproject_0_0_0_finder.py


MAPPING: dict[str, str] = {'mypackage': '/nail/tmp/tmpg7d3dfwo/myproject/mypackage', 'standalone': '/nail/tmp/tmpg7d3dfwo/myproject/standalone'}

These now also need to be changed.

@ymilki ymilki force-pushed the fix_virtualenv_update_for_new_bash_activation_script branch from 454a3eb to 41f42b0 Compare January 14, 2026 19:40
@ymilki ymilki force-pushed the fix_virtualenv_update_for_new_bash_activation_script branch 2 times, most recently from 28df0ad to 81698c8 Compare January 14, 2026 23:52
@ymilki ymilki force-pushed the fix_virtualenv_update_for_new_bash_activation_script branch from 81698c8 to d105f20 Compare January 15, 2026 00:22
@ymilki ymilki marked this pull request as ready for review January 20, 2026 19:41
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)

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 🤦‍♀️

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

Comment on lines +84 to +91
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
Copy link
Member

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

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.

Conflict with venv on Python 3.12

4 participants