Using and Mastering Cookiecutter Transcripts
Chapter: Adding features to Cookiecutter
Lecture: Running Cookiecutter locally
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Next step is to actually run cookiecutter, so if I type which cookiecutter you'll see this is the one actually installed into Python 3.6
0:11
and installed into my machine at least my user profile now, couple of things to note here, one if you're on Windows,
0:18
you want to type where cookiecutter on Linux and MacOS it's which, so those are basically equivalent commands but not exactly the same.
0:27
Second, cookiecutter runs both on Python 2 and on Python 3, but it's a little easier to develop under Python 2,
0:33
so we're going to create a Python 2 virtual environment, all right, so let's look here, we want to go into the cookiecutter folder
0:40
and here we are in the cookiecutter folder, and we're going to create a virtual environment so we want to have, we want to say which virtualenv
0:49
now you probably don't have this command, see I don't have it here for example,
0:53
so I want to install it but I want to make sure that it gets installed into Python 2, so we'll say pip2 install virtualenv
1:00
to keep things simple I could even just do that to my user profile. Now on windows, you can't say pip2, they for some reason don't have those aliases
1:11
so either create an alias or just make sure you run pip from Python 2. Okay, so this should install it, great, it's already installed.
1:20
Next, after this we want to create the virtual environment, and again, to make sure that this is using Python 2
1:27
instead of Python 3, I want to be careful so I'm going to say instead of just saying virtual environment create the directory
1:36
I am going to say Python2 -m virtualenv .env (-m for module) So, when we say .env, it's going to create one right at the root of the cookiecutter
1:43
which we're going to ignore that, okay great, it's creating it here in this folder, I want to make sure that I next actually activate this,
1:52
so right now, if I ask which or where Python2, it's the global one, so what I want to do is, I want to say (dot) on
2:00
Windows you don't need to do the (dot) but on Mac and Linux you do, so we'll say .env/bin/activate and it's activate.bat on windows,
2:09
notice how my prompt changed, now if I ask the same question, which Python, you can see now it is this Python,
2:16
okay so we've installed the virtual environment, we've activated our virtual environment,
2:21
the final thing to do here is when we're in the folder with the setup
2:25
is to register it, so if I ask which cookiecutter, right now, it's still this one,
2:29
that's not cool, so that's the globally installed one, we're not modifying we want to have only run cookiecutter to run the code that's in this folder
2:38
cool so what we're going to do, is we're going to say Python and you might want to double check which Python,
2:45
that's the one in our virtual environment, okay cool, Python setup.py develop now the develop says don't copy this over to the system
2:55
but just leave it here, and point here when you run it like run it straight from our modifiable source here
3:00
ok so go- beautiful, now let's ask the question again which cookiecutter
3:05
Perfect, so now we're going to run the one that is here, and if we actually try notice, if we actually try to change directories into there
3:16
ok perfect so now you can see that we have our cookiecutter installed and ready to go and let's just say cookiecutter -V for version
3:24
oh notice this how it says it's not found, sometimes this happens and it's super annoying, I'm not quite sure why
3:31
but I think if I exit my terminal, this is not always required, but I think in this case it might be
3:38
I am going to exit the terminal, reactivate the environment, and I think it should find cookiecutter again. Reactivate the virtual environment,
3:51
alright, so it looks good, there we go, yeah I don't know why, you sometimes have to restart the shell but whatever, it doesn't matter
4:02
it's working fine, so you can see we have this, and it's from this location and it's running on Python 2.7, so at the end of this step
4:09
you should have it, so it says cookiecutter whatever the version you got was from your virtual environment location
4:15
or really where you checked out the code and just say Python 2.7, 3.6, 3.5, something like that so now we can run cookiecutter locally, which is great,
4:26
now let's go add our feature.