copier icon indicating copy to clipboard operation
copier copied to clipboard

feat: Allow copier-templates-extensions as an extra

Open henryiii opened this issue 1 year ago β€’ 12 comments

This allows pipx users to use this:

pipx install copier[templates-extensions]

Or this:

pipx run copier[templates-extensions] <args>

Instead of this:

pipx install copier
pipx inject copier copier-templates-extensions

I think this was mentioned a while back, but never added.

I'm not very familiar with non-PEP 621 backends (Poetry. Just Poetry.), so hopefully I got the syntax correct. Also not sure if you want a min version here.

henryiii avatar May 08 '24 05:05 henryiii

The current project's supported Python range (>=3.8) is not compatible with some of the required packages Python requirement:
  - copier-templates-extensions requires Python >=3.6.1,<3.10, so it will not be satisfied for Python >=3.10
  - copier-templates-extensions requires Python >=3.6.1,<3.10, so it will not be satisfied for Python >=3.10
  - copier-templates-extensions requires Python >=3.6.2,<3.11, so it will not be satisfied for Python >=3.11

Because no versions of copier-templates-extensions match <0.1.0 || >0.1.0,<0.1.1 || >0.1.1,<0.2.0 || >0.2.0,<0.3.0 || >0.3.0
 and copier-templates-extensions (0.1.0) requires Python >=3.6.1,<3.10, copier-templates-extensions is forbidden.
And because copier-templates-extensions (0.1.1) requires Python >=3.6.1,<3.10, copier-templates-extensions is forbidden.
And because copier-templates-extensions (0.2.0) requires Python >=3.6.2,<3.11
 and copier-templates-extensions (0.3.0) depends on copier (>=6), every version of copier-templates-extensions requires copier (>=6).
So, because copier depends on copier-templates-extensions (*)
 and copier is 0.0.0, version solving failed.

  β€’ Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For copier-templates-extensions, a possible solution would be to set the `python` property to ">=3.8,<3.10"
    For copier-templates-extensions, a possible solution would be to set the `python` property to ">=3.8,<3.10"
    For copier-templates-extensions, a possible solution would be to set the `python` property to ">=3.8,<3.11"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

henryiii avatar May 08 '24 05:05 henryiii

(The stuff about limits is bogus, because older versions used to have Python caps, that's not the correct solution and would result in the wrong solve)

henryiii avatar May 08 '24 05:05 henryiii

I could probably just change the dummy version number, not sure if there's a better way to fix this with the poetry-dynamic-versioning hack. Edit: I did that, can try something else if someone has a different suggestion.

henryiii avatar May 08 '24 06:05 henryiii

I assume you installed the poetry-dynamic-versioning plugin, right? If so, it seems that Poetry's dependency resolver does not consider the version computed by the plugin but instead simply uses the version from the metadata. I wonder whether the plugin could be extended to let Poetry use the computed version during dependency resolution. Then, hardcoding a sufficiently high though arbitrary version in our metadata would not be necessary.

sisp avatar May 08 '24 06:05 sisp

I assume you installed the poetry-dynamic-versioning plugin, right?

Ah, no, I was just using my brew-installed poetry, which doesn't support adding plugins. I just unlinked my poetry with brew, then installed poetry with pipx and injected the plugin. That fixed it. Other tools (like PDM or Hatch) usually respect your build-system.requires, but Poetry plugins apparently don't.

henryiii avatar May 08 '24 16:05 henryiii

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.39%. Comparing base (4ffd143) to head (db24619). Report is 160 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1633      +/-   ##
==========================================
+ Coverage   97.20%   97.39%   +0.19%     
==========================================
  Files          48       48              
  Lines        4728     4728              
==========================================
+ Hits         4596     4605       +9     
+ Misses        132      123       -9     
Flag Coverage Ξ”
unittests 97.39% <ΓΈ> (+0.19%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 08 '24 16:05 codecov[bot]

Nice! The RTD build is failing because poetry-dynamic-versioning is not installed there. This should be fixed by adding poetry self add "poetry-dynamic-versioning[plugin]" to .readthedocs.yml after Poetry is installed. I'm not sure why the two CI / flake-check ... checks are failing though.

sisp avatar May 08 '24 17:05 sisp

Okay, fixed readthedocs. On the nix jobs (CI / flake-check), it's still giving:

Run copier --version
/Users/runner/work/_temp/ede4b13e-8f0d-4491-9ff7-7771f5b39c64.sh: line 1: copier: command not found

henryiii avatar May 09 '24 19:05 henryiii

The JRMurr/direnv-nix-action@v3 action fails in the Nix Environment setup step with the following error:

  Because copier-templates-extensions (0.3.0) depends on copier (>=6)
   and no versions of copier-templates-extensions match !=0.3.0, every version of copier-templates-extensions requires copier (>=6).
  So, because copier depends on copier-templates-extensions (*)
   and copier is 0.0.0, version solving failed.

I guess the poetry-dynamic-versioning plugin is missing. Will try to look into it some more.

sisp avatar Jun 14 '24 10:06 sisp

One could want to add any jinja extension to the Copier env. I think I like it better without this PR. Sorry...πŸ˜…

yajo avatar Jul 08 '24 05:07 yajo

I'm wondering if copier-templates-extensions shouldn't be integrated into Copier directly, since we have the --trust flag now.

pawamoy avatar Aug 27 '24 14:08 pawamoy

Makes sense to me.

sisp avatar Aug 27 '24 17:08 sisp

You mean deprecate the entire project and integrate missing features here?

Yeah, maybe it makes more sense... I never had the need to use it, to be honest. Maybe we can discuss it in a separate issue?

For now, I'll close this. Having this dependency adds some unneeded burden here. FWIW I'd have to fix the flake and the lock file conflicts, things I didn't need to do until now πŸ˜†

Just inject the extension in the pyenv like any other and you're good to go with it.

Thanks anyway!

yajo avatar Aug 29 '24 16:08 yajo

@henryiii, you can now tell your users to use uv:

uv tool install copier --with copier-templates-extensions
uv tool run --with copier-templates-extensions copier <args>

:smile:

pawamoy avatar Sep 21 '24 10:09 pawamoy