pixi
pixi copied to clipboard
Allow `pixi init` to start with an template.
Problem description
As a user I would like to start a project with a template. This might be helpful for tutorials.
This is also nice of developers that ship their code to customers with the intent for them to use pixi.
My design proposal would be that pixi init can except a --template option which can hold either a name for the default templates that the prefix-dev org proposes, or it can except urls to git repositories.
pixi init --template python
pixi init --template rust
pixi init --template https://github.com/prefix-dev/pixi-python-template
This would be great! I was going to be implementing this within the {pixi} R package, but if you'll implement it within pixi I'd be happy to help develop a good template for R here!
perhaps instead of reinventing the wheel we could use https://github.com/cookiecutter/cookiecutter (which you can install with pixi of course π )
Or copier. Copier has the advantage that you can update your projects if a new version of the template was released. We use it extensively at our company and it works great.
Current idea is to automatically global install copier and then invoke that. If this feature would become more important we could look at integrating the templating into the rust code.
In copier you can define arbitrary tasks afterwards. In these tasks you might have additional dependencies to copier itself. Maybe checking for an optional pixi.toml+pixi.lock in the template repo could make sense?
What would be the benefit of having a global install of copier? Can't we just run pixi runx copier copy ... once #624 is implemented?
Yes even better!
What's the status on this issue? If https://github.com/prefix-dev/pixi/pull/1442 gets merged, does that also mean this issue could be solved?
Then somebody would need to create a template (i wanted to do that anyway at some point) and then we could link it in the docs for example.
Coolio, I can make a basic one for R next week. βΊοΈ
Have made a template we can use to test. It's the first time I've made a template, so just let me know or make a PR if anything needs to be changed. :) https://github.com/roaldarbol/r-template/
Yeah @roaldarbol, I think you are right. Could you give the exec branch a go maybe :)?
I might find time to test it over the weekend, but can't promise it. The only thing that I found was an issue with the template is pulling github user.name and email. pixi has some functions for that, but I don't know how we would incorporate them with copier.
Re the user-facing implementation - If it works with exec, would we just make an extra argument (--template) that then instead calls pixi exec copier copy path/to/template current-folder? (So if I were to call pixi init --template r or pixi init --template gh:roaldarbol/r-template)
i would suggest just writing something like the following in your readme
To initialize your repository, please run
pixi exec copier copy --trust https://github.com/roaldarbol/r-template.git .
Added a README with some suggested ways of using it - which will of course be dependent on how this issue is implemented in the end. :-)
Update on this: just tried out the solution
pixi exec copier copy --trust https://github.com/roaldarbol/r-template.git .
and it seems to have worked, creating an .Rproj file and everything!
See commit above the previous comment for details..
After that I tried
pixi install
But alas I got " WARN Not installing dependency on current platform: (linux-64) as it is not part of this project's supported platforms." and R seems to have not been installed. Any ideas how to fix this @roaldarbol ?
Hi @robinlovelace-ate! Great to see someone try it out! Yeah, I've realised this, I'll patch in the coming days - for now, in pixi.toml, you'll just need to change platforms = ["osx-64"] to platforms = ["linux-64"] (as I assume you're on a Linux computer π).
Just realised that at the same time, patched and things now happening:
Next question: how do I get R repl? I tried R but got "command not found".
pixi install
β The default environment has been installed.
root@codespaces-837842:/workspaces/netgen# R
bash: R: command not found
Currently working on the Python template, hopefully it's done soon.
pixi shell
R
works π
How can I make that shell env load by default?
@robinlovelace-ate I've made an issue for the platform question here: https://github.com/roaldarbol/r-template/issues/2 You can ask more questions on that repo, I think it's probably a better place - but happy to try helping out!
Yup, you'll need to either make a pixi shell first, or run pixi run R.
@pavelzw Let's chat a bit on Discord about the templates, I'd be really interested to ensure feature parity between the templates!
The R template now works for VS Code too.
our template for open source python projects that are managed with pixi: https://github.com/Quantco/copier-template-python-open-source
Still wip and not tested much yet, though. Adding automatic docs generation is on my roadmap
With all the copier and cookiecutter templates coming in i would like to let those tools take over this request for now. Closing as stale and not the focus for now.