Using and Mastering Cookiecutter Transcripts
Chapter: Adding features to Cookiecutter
Lecture: Concept: Modifying cookiecutter
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Now that we've worked through actually adding a feature or enhancement to Cookiecutter
0:08
let's go back and review the core concepts or steps that we needed. So, we're going to start by forking the Cookiecutter repo
0:15
so github.com/audreyr/cookiecutter and we're going to fork that to our own repository.
0:21
Next, we want to clone that locally so we can work with the source so git clone our cookiecutter fork- downloads and then we're ready to go,
0:31
just make sure that that is your user name not audreyr, because if it's audreyr you probably can't make changes
0:37
and submit fixes back to the repository. Next, we're going to create a feature branch.
0:42
This is partly optional, but I strongly recommend you create a feature branch,
0:46
and this whole PR work flow, so probably you can just go to the top of the list I have changes on mine I had to go back a little bit
0:55
because I tweaked my fork for some other reasons you can read them there in the list
1:00
but I went back to this one that's highlighted and I said create a branch from there
1:04
and you saw my convention, my github name / feature or fix branch name make sure it's all underscores or something like that
1:12
so we checked it out and it was ready for us to start working on it. Next, we have to create a virtual environment;
1:18
technically is not required but you probably don't want to run your dev version of Cookiecutter as your main thing on your computer
1:25
maybe you do, but let's go ahead and create a virtual environment here so we're going to make sure we have, in Python 2 we have virtualenv
1:34
remember on Windows pip2 doesn't exist, you just have to make sure you use pip out of Python 2.
1:39
Okay, so we've installed it, next we can create the virtual environment again making sure we're using the Python 2 version
1:44
so Python2 -m virtualenv .env (-m for module) and then we activated it, and notice how when we activated the prompt changed
1:53
okay so now we're ready to basically register the local dev package as something we can run. So we're going to do that when I register the dev package
2:04
so we just say Python setup.py develop, not install or any of these things, Python setup.py develop, so that means
2:11
the local it's going to basically run out of our source directory so as we make changes, those changes will immediately appear
2:17
in this virtual environment, so if we run this it does a whole bunch of work to install the dependencies and then finally when it's done
2:22
we have cookiecutter 1.5.1 or whatever version you have registered and ready to run from the command line.
2:30
Finally we go and make our change, we've got it ready to run locally so we can test it, we've got our branch checked out for our feature
2:37
in our case I was really bugged by that missing by that weird pars error in YAML and so I went and fixed that by adding a newline at the end
2:47
if there wasn't one right, it didn't really make a change to the contents of the file but it made it parseable even if it wasn't there.
2:55
Make sure you follow the conventions that they use in Cookiecutter and notice the u for Unicode, so we were using Python 2
3:03
because it's little less forgiving and some other the things and it's a little easier for me, at least to remind myself
3:10
I'll put the u for Unicode rather than in Python 3 where it's not required ok so we made our change here, then we're going to check in our change
3:18
and we're going to give it a detailed description notice we have a detailed description for the people reviewing the PR
3:23
and were pushing the changes to mikeyckennedy/ in this case forgiving YAML fix, whatever the name of our feature branch is.
3:31
Finally, once that's done, we go back to GitHub to our repo click the button to create the pull request, and boom, then our pull request is here,
3:40
one final note, notice down here at the bottom, there is 3 checkins with my picture next to it,
3:44
it says if the YAML config file does not end with the single blank line, it has an X
3:48
now I ran the tox tests and I guess I didn't look carefully enough, I just figured oh no, I don't have flake 8 installed or whatever,
3:55
and that didn't work, but it actually didn't work when I checked it in here,
3:58
this comes from the continuous integration, on the server, on the git repo, that they have configured, and what happened was,
4:06
I had actually my docstring was 83 characters long and they have a restriction that says 79 columns or fewer in any given line,
4:18
so notice I actually made another change I fixed that format in the docstring and I just checked it back into my repo, to that branch
4:26
and it automatically updates the pull request, and finally, it went all green everything was happy, everything passed.
4:32
Alright, do you have a great idea to make Cookiecutter better, now you know how to develop and do contributions back to it.