-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Cookiecutter for the package-template (APE 12) #17
Conversation
This week is a little crazy because of travel so I'll have to do a more thorough review in a few days, but my gut reaction is that I'm +1 to the idea. I don't know much about |
extensive changes to the actual package template, thereby making it easy to pull | ||
in changes from the Astropy template without lots of complex merging. | ||
|
||
There are also secondary advantages to using a Cookiecutter project, such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two "such as" clauses in the same sentence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reworded
APE12.rst
Outdated
This APE proposes migrating the `package-template | ||
<https://github.com/astropy/package-template/>`_ to use the `Cookiecutter | ||
<http://cookiecutter.readthedocs.io/>`_ project to provide templating facilities | ||
to the package template to ease use of the package template and to make it easy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeated 'package template' - maybe reword. Somewhere in abstract you need to spell out more clearly that creating new projects will be much easier for people (ease use doesn't quite cover it). Maybe have a separate sentence for the fact it's easier for people to use, and to 'subclass'. You said it better in the detailed bit. Can you try and improve it here too?
APE12.rst
Outdated
in changes from the Astropy template without lots of complex merging. | ||
|
||
There are also secondary advantages to using a Cookiecutter project, such as | ||
being able to include code, such as tests, in the ``package-template`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a link instead of double backquotes?
APE12.rst
Outdated
|
||
Cookiecutter is not the only project templating system, others such as | ||
`diecutter <https://diecutter.readthedocs.io/>`_ could be used. Cookiecutter was | ||
chosen due to wide adoption and implementation in Python. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative is to write our own setup script. Might be worth mentioning at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I used my own cookiecutter template for new python projects until I discovered and switched to the astropy affiliated template because it was much more comprehensive in its support for RTD, travis, etc, and "just works". This proposal sounds like it would significantly simply the initial setup (although I found it useful to go through the steps manually, at least the first time, so I knew what was under the hood). How do bug fixes and maintenance updates (e.g., version bumps) to the template propagate to affiliated packages in this proposal? I guess this part of the proposal is relevant but I wasn't sure how the automatically generated template repo would solve the problem:
|
Thanks for the feedback! The idea is that for people who want to continue a git-remote based update workflow (where they start a project with the git history of the template) could pull form the automatically generated repo. My thoughts on people who start with cookiecutter would be that you could render any updates to a new folder and then diff the updated template to your project and see any changes and pull them in as needed. |
@Cadair Hmm, that sounds quite a bit more tedious than the current workflow though... |
@adrn really because isn't that what you are doing in a mature project at the moment? Some files have changed in upstream and you have to manually merge them? |
@Cadair Sorry, I meant the 2nd case above -- rending updates to a new folder and diffing. |
Yeah I did as well, although I went a little to "git" in my terminology. If you are not tracking a git remote, you have the rendered template in a |
What about adding a working solution to astropy/package-template#197 to this APE? I agree with the others that having an easy way to update an existing package that uses the template is just as important (actually in my view it is more important) as having an easy way to start up something new. |
I suspect most users don't care about inheriting the template git history (and it has burned me a few times when I forgot to delete the template repo's tags). The ideal update workflow for a new user is something like:
|
While I agree that having a nice update mechanism is important, I am not sure I want to conflate that with this PR. (Ignoring the git remote case) I can't see how this make things worse and because cookiecutter will remember the settings you used to render the template the first time it is possible to get your customised version of the template for diffing, which could be scripted out later. |
I agree with @bsipocz that straightforward updates are at least as important as a more convenient initial install. The main benefit of the template is that it allows developers to adopt the best practices of the astropy community (RTD, travis, etc) without necessarily understanding all of the details of how they are implemented (which was true for me when I started using the template). However, a lower barrier to adopting best practices also requires a simple and robust mechanism for keeping the relevant files up to date. |
Another agreement with the importance of updating: I have one project for which I use the astropy template, and I found setting it up via the current instructions not particularly onerous, but I find updating it painful (mostly because it needs to be done so infrequently that I have no memory any more about how it is to be done; indeed, I have no clue whether I'm currently up-to-date). That said, I do like the idea of providing a more automated way of getting a useful environment. |
One idea I've had for a while would be that repositories which would like to see updates could include a configuration file (e.g. |
Agreements that updating is important. I currently have 4 or 5 packages that use the template, most of them are for my own personal use (although two or three might be advertised to a wider community in the future and will hopefully grow into affiliated packages). Suggestion: Poll the astropy template users list to find how many people use git for updating vs. a more manual approach. |
@hamogu - thanks for mentioning the template users list -- I didn't even know it existed... (for others like me: https://groups.google.com/forum/#!forum/astropy-affiliated-maintainers) |
@Cadair - Thanks! I'm +1 to introduce cookiecutter for this. Along the lines of what several others have stated, I think it would be important to think through (or even exercise through) how updating existing packages will work. That's been the painful and time wasted part for me. Currently you have this which is pretty vague and thin IMO:
I currently have the following thoughts / questions, which I think would be useful to address in the APE (not just the GH discussion here):
|
nit-picking, but the With the rest I agree. |
And I think we can easily adapt the astropy-helpers update script to also update e.g. |
Not |
APE12.rst
Outdated
rendered version of the template with the default settings. This will result in | ||
a repository that looks like the current package-template repository. This could | ||
then be used as a git remote for people who wish to continue using this update | ||
method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention it will share the history up to the point where cookiecutter was added. Also maybe just a new branch in the repo rather than a separate repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do, not sure which one is better, I suppose a new branch does not require remote change on the local git side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be +:100: for having a new branch rather than a new repo for the current template (unless the cookiecutter version goes into the new repo)
APE12.rst
Outdated
chosen due to wide adoption and implementation in Python. | ||
|
||
Finally, a custom templating system could be developed and maintained for the | ||
Astropy project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add 'but this would likely require a lot of effort'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit is better than implicit I suppose :p
@Cadair - I like this idea, but have a couple small bits that should be stated expressly in the APE:
(Also have some thoughts on implementation details, but they don't affect the APE so I will put them in astropy/package-template#202) |
@eteq I did mention "automatically" in the text of the APE, I have added Travis to be explicit. As for the documentation, the move to cookiecutter means that it is possible to have the canonical documentation for using the template to be in the template repo. I defer to group opinion on if this is something we want to do. Personally I like it, you would only need one PR to update the docs and the template, easy to version the docs with the template etc. |
@eteq I addressed both your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. To make things smoother, I propose that in package-template the master branch remains the one where the rendered version gets put, and we put the cookiecutter template in a cookiecutter branch, and make that the default repo branch.
I very much like the branching suggestion by @astrofrog. |
@astrofrog it being the default repo branch means it is the one that's displayed by default by GitHub right? If so I am fine with it. |
@Cadair - yes, that's correct |
@Cadair - can you update the APE accordingly? (the bit about making the new branch for the rendered version) |
@Cadair - alright, I'm satisfied with this - thanks! On the documentation, after a bit further investigation, I think the reason we made it a separate doc in the first place was because it enabled the fancy javascript magic of filling in the package name using a form. But now that's not needed due to cookiecutter, so indeed it does make sense to move it back into the package-template. |
@astrofrog @eteq I pushed the re-word. |
APE12.rst
Outdated
example uses the `Cadair/pacakage-template <https://github.com/Cadair/package-template/tree/cookiecutter>`_ | ||
``cookiecutter`` branch, if this work was to be merged the command would be | ||
``cookiecutter gh:astropy/package-template`` as the ``-c`` option specifies a | ||
non-master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cadair - very minor before I approve and merge, we should keep the -c cookiecutter since we're going to merge this into a cookiecutter branch. So can you update it here and in the first command of the code block below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just tested this and cookiecutter uses the default git branch rather than "master".
Wooop 🎆 |
Great to see this finally happen! |
I have a package I'd like to set up in the next days using the package template. @Cadair - Would you recommend doing it via cookiecutter version you have made now? |
No description provided.