Replies: 3 comments 19 replies
-
There's a way with pipx: pipx run --pip-args="$deps" copier copy $src $dst Though it's not automated for users: they do have to copy/paste this command from a template's documentation for example. |
Beta Was this translation helpful? Give feedback.
-
What about just letting folks ship a bootstrap python script that copier runs before executing anything? That way users can do whatever they want outside of just installing dependencies. If that API was well defined, you could even inject a helper object that bootstrap scripts could use to install these dependencies in a "copier-aware" way. |
Beta Was this translation helpful? Give feedback.
-
Copier is kinda similar to Ansible. We even include the extension with similar filters. Both are configured with yaml, written on Python, both rely on jinja a lot, both can be extensible. Ansible inventend Ansible Galaxy, which is a way to install ansible content. Some docs here. If you ever used Ansible's We have enough of those tools: Nix, poetry, pip, pipx... Let's not add this burden to Copier please... 😅 My solution is Nix, just like always when we talk about packaging matters. 🤷🏼♂️ Check out this example. There, I provide a version of Copier based on upstream but including an extension. It's all done in a short
I'm actually bitten no less than once a week by this design of pre-commit. When it happens publicly on some specific projects, I keep a list updated here just for fun: OCA/oca-addons-repo-template#175. But it happens privately and on other kinds of projects too! As you can read there, I've invented an alternative called precommix which solves the problem with Nix. Others have invented pre-commit-hooks.nix which is better on some things, worse in some others (and we use it here in Copier BTW). So, if I'm fleeing away of this broken system, please don't ask me to invent a similar one in Copier. 😅 |
Beta Was this translation helpful? Give feedback.
-
Copier templates sometimes require additional Python packages, e.g.
copier-templates-extensions
(+ e.g. additional packages needed to implement custom local Jinja extensions that are loaded viacopier_templates_extensions.TemplateExtensionLoader
) or external Jinja extensions. In those cases, a developer needs to install Copier and also the required additional packages manually. IMO, the UX isn't good and it's error-prone. Instead, I'd prefer a way to generate a new project or update an existing project without manual installation of additional packages.Currently, I don't think there's a good way to do it because the template is an external resource that in essence consists only of folders and files some of which happen to contain Jinja template syntax. But I have an idea how to extend Copier and equip a template with information about additional Python packages:
copier.yml
could be extended to have a new field for specifying dependencies, e.g.:Copier would offer a new CLI subcommand, e.g.
copier install $src
, to install the dependencies in a Copier-managed virtual env for this template and version (e.g. like Poetry orpre-commit
manage their own virtual envs). To allow Copier to use those dependencies and to avoid dependency conflicts, the same version of Copier would need to be installed again in this virtual env along with the additional dependencies, and a call of, e.g.,copier copy $src $dst
would transparently delegate the call to thecopier
executable installed in the virtual env. Essentially, the originalcopier
executable (e.g. Copier installed viapipx
) would only be a kind of orchestrator. Alternatively, the virtual env could be prepended to Copier'sPYTHONPATH
, but I fear this might be error-prone when different (possibly incompatible) versions of the same package are installed in both the virtual env and in the, e.g.,pipx
-managed virtual env in which Copier is installed.It might be conceivable to make the
copier install $src
step optional. When a Copier template with dependencies shall be used butcopier install $src
wasn't run before, Copier could automatically create the virtual env and install the dependencies, similar to howpre-commit
works.I'm curious about others' opinions. 🙇
/cc @yajo @pawamoy
Beta Was this translation helpful? Give feedback.
All reactions