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