Skip to content

Updated info plugin to exclude guessed venv paths #8286

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

Merged
merged 4 commits into from
Jun 29, 2025

Conversation

kamilkrzyskow
Copy link
Collaborator

Hi 👋,
since the amount of cases with minimal reproduction containing an inactive Virtual Environment reached a comfortable threshold I decided to update it and detect/guess possible venv paths.

To guess the paths I use the pyvenv.cfg file, which is added in the default python -m venv call:

Perhaps other "venv" solutions don't do that, and a better alternative would be to use site-packages or look for "python" executables, but Linux might not use python but specifically some python3.12 name variant, so I picked the simplest solution for now with the pyvenv.cfg ✌️

9.6.14-guess.zip

$ mkdocs build
INFO    -  Started archive creation for bug report

Please name your bug report (2-4 words): guess
Possible inactive venv: C:\Users\...\material-info-venv-test\venv2
INFO    -  Archive successfully created:

  9.6.14-guess/docs/index.md 287.0 B
  9.6.14-guess/mkdocs.yml 61.0 B
  9.6.14-guess/platform.json 352.0 B
  9.6.14-guess/requirements.lock.txt 332.0 B

  9.6.14-guess.zip 1.6 kB

In the final platform.json I decided to hide the username as it's a potential breach of privacy, a bit late after months but better late than never ✌️
... - in this case I obfuscated the username in the text here, however it would display for the user in the terminal.

Additionally, I added the output of the VIRTUAL_ENV environmental variable to make sure we see the activated venv and don't have to guess based on the sys.path

Ref:

@squidfunk
Copy link
Owner

Thanks for the PR. As always, I trust you on this one, since you're the one championing most of the improvements and bug fixes in the plugin. We can fast track this by our feature freeze, since it's not a feature.

@squidfunk squidfunk merged commit 2b0417f into squidfunk:master Jun 29, 2025
4 checks passed
@kamilkrzyskow
Copy link
Collaborator Author

Thanks, I did test on Windows and WSL, and it's working as I would expect. 🙂
It should work on macOS as well, but I didn't go the extra mile to test it on GitHub Actions this time around.

Minor bug was on WSL, with the username substitution, as WSL loads the name as lowercase and Windows itself uses uppercase for the directory. So I would have to replace it with regex to make it work in this scenario of mixed case between Windows and WSL, however I think that's a very rare scenario, so I didn't optimise for it. If somebody uses Docker with WSL they likely don't put files in any personal path either 🤔

@squidfunk
Copy link
Owner

Released as part of 9.6.15.

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.

2 participants