Skip to content

Delete references to ruamel.yaml at Spack start-up, if they are present#9725

Merged
tgamblin merged 2 commits intospack:developfrom
epfl-scitas:fixes/ruamel_yaml_deletted_sys_modules
Nov 7, 2018
Merged

Delete references to ruamel.yaml at Spack start-up, if they are present#9725
tgamblin merged 2 commits intospack:developfrom
epfl-scitas:fixes/ruamel_yaml_deletted_sys_modules

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Nov 5, 2018

fixes #9619
fixes #9206

closes #9702 (alternative solution to the same issue)
closes #9261 (alternative solution to the same issue)

ruamel.yaml generates a .pth file when installed via pip that has the effect of always preferring the version of this package installed at site scope (effectively preventing us from vendoring it).

This mechanism triggers when implicitly importing the site module when the python interpreter is started. In this PR we explicitly delete references to ruamel.yaml and ruamel in sys.modules, if any, after we set sys.path to search from the directory where we store vendored packages. This ensures that the imports after those statements will be done from our vendored version.

fixes spack#9206

ruamel.yaml generates a .pth file when installed via pip that has the
effect of always preferring the version of this package installed at
site scope (effectively preventing us from vendoring it).

This mechanism triggers when implicitly importing the 'site' module
when the python interpreter is started. In this PR we explicitly delete
references to 'ruamel.yaml' and 'ruamel' in sys.modules, if any, after
we set 'sys.path' to search from the directory where we store vendored
packages. This ensures that the imports after those statements will be
done from our vendored version.
@alalazo alalazo added bug Something isn't working broken-develop hotfix labels Nov 5, 2018
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Nov 5, 2018

@ax3l @ibaned Can you confirm this solution works also for you?

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Nov 5, 2018

Works for me, thanks a lot! :)

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalazo: LGTM! So much shorter! Can you please update the comment to just summarize what ruamel.yaml does with the system .pth files, and that we are undoing it here? I think the discussion of this being rare can be left to #9206.

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Nov 6, 2018

@tgamblin done

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 7, 2018

@alalazo: thanks!

@tgamblin tgamblin merged commit a474d83 into spack:develop Nov 7, 2018
@alalazo alalazo deleted the fixes/ruamel_yaml_deletted_sys_modules branch November 7, 2018 06:40
@ax3l
Copy link
Copy Markdown
Member

ax3l commented Nov 8, 2018

@alalazo thanks a lot again!! 🚀 ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

broken-develop bug Something isn't working hotfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python RecursionError when sourcing setup-env.sh Debian ruamel.yaml 0.15: Infinite Recoursion On Setup

4 participants