fix(extensions): ensure trusted/safe templates extensions are seen during update or copy with --vcs-ref#2557
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2557 +/- ##
==========================================
+ Coverage 97.25% 97.27% +0.01%
==========================================
Files 58 58
Lines 6751 6782 +31
==========================================
+ Hits 6566 6597 +31
Misses 185 185
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0476c29 to
b3f5747
Compare
…ring update or copy with `--vcs-ref`
b3f5747 to
296faa6
Compare
|
Are you sure this ever worked without copier-template-extensions? I've checked out the v9.4.1 tag, added your fixture and tests, and ran those tests – they're failing for me: This is an excerpt of the stack trace: |
|
You're right, it only works with I'll close the PR unless you are interested in this feature (I would be truly interested into supporting template-local imports, it would simplify a lot of things) |
|
I think that template-local extension loading using file paths is preferable over module names in the search path for better clarity. This is what copier-template-extensions is doing. I agree that loading template-local extensions is a rather common use case which may deserve first-class support by Copier. This has been discussed before (#1756), a few more points to consider were raised there. I'm curious what you think. |
Hello 👋🏼
This PR fix a regression on template extensions.
When a template provides some extensions, they are not on
sys.pathanymore when:copywith--vcs-refupdateIt fails with the following error (for a
extensionspackage in the template directory)Copier could not load some Jinja extensions: No module named 'extensions' Make sure to install these extensions alongside copier itself.I can't say precisely in what version it broke, but it was working on Copier 9.3, 9.4 (I think it worked in 9.10) and not anymore since
9.12.This PR fix this by explicitely adding the template path to
sys.pathwhen the template is trusted.