UCL-ARC / python-tooling

Python package template for new research software projects
http://github-pages.arc.ucl.ac.uk/python-tooling/
MIT License
43 stars 2 forks source link

Applying the cookiecutter on an existing repo #416

Open sfmig opened 5 months ago

sfmig commented 5 months ago

Is Your Feature Request Related to a Problem? Please Describe

When @samcunliffe and I had to apply a cookiecutter to an existing repo, we ended up creating the template on a separate directory and copying files across. Is there a better way to do this? And should we document this usecase in this repo?

@matt-graham mentioned that in the ARC festival workshop they tried a different approach to keep the git history.

Describe the Solution You'd Like

Mention this case in the readme and add some steps with the best way to do this.

Describe Alternatives You've Considered

No response

Additional Context

No response

samcunliffe commented 5 months ago

Should it be on the website too? Perhaps a bit out of scope: the website is "just" recommending tools, the root-level README is instructions for how to use the cookie-cutter template.

paddyroddy commented 5 months ago

Do we know if this is a common use-case? Obviously, it would be very handy, but perhaps out of scope? Would be good to document either way, perhaps the website could have a blog section where we write this kind of thing up?

matt-graham commented 5 months ago

In the workshop we worked on applying the cookiecutter package structure to the existing package in zmek/patientflow. We initially tried following a git merge approach following this guide @paddyroddy pointed me to, with the cookiecutter package created in a new repository to which we added the existing (local) repository as a remote. However we subsequently realised in this case this seemed overkill as there was no history from the new package repository we wanted to preserve so just doing what @sfmig suggested above of copying across the new package structure in to the existing repository in a new commit made sense (we did this in this commit on patientflow).

Some thoughts / comments on doing this for this specific case:

dstansby commented 5 months ago

FWIW https://cruft.github.io/cruft/ might be of interest, which I've seen used for exactly this elsewhere (https://github.com/OpenAstronomy/packaging-guide)

paddyroddy commented 5 months ago

Just FYI @matt-graham, one big advantage of having all ruff rules on is that, for example, NPY201 is automatically turned on, which will help with numpy>=2.0

sfmig commented 2 months ago

From an RSECon24 workshop: copier does seem to deal with this nicely, as it allows you to apply the template to an existing project.

Some other interesting features:

One downside may be that it abstracts away too much for beginners. It seems better to gradually increase complexity, rather than abstract everything away from the start. But they do have the option to add selected features, which is maybe more aligned with that second approach.

Relatedly, the neuroinformatics team pointed me to a guide Laura did a while ago on how to use cruft to apply a cookiecutter template to an existing repo.

samcunliffe commented 2 months ago

Should we just point to Laura's guide? (@dstansby ... cruft)

dstansby commented 2 months ago

I have no opinions or useful advice other than I've seen cruft being used before 😄