 Yeah, so hi everyone first of all, I want to thank you for your interest in my talk on cookie cutter My name is Raphael. I'm from Germany and well I do love open-source software and more specifically Python And I'd like to say a few words on about my background So I'm not just yet a web developer in Python, but I do have a solid background in 3D So it's a field where Python is actually used quite frequently I am a core developer of cookie cutter. I Worked for on the adopt py test month in April And yeah, I did it like I was acting as a technical reviewer on a book on Kiwi framework I will talk about in just a second um More importantly, yeah, as I mentioned I have the commit bit cookie cutter And this will be going to be my main subject of my presentation. My github username is hackabroad And I do have a Twitter. So please feel free to just shoot me a text with feedback or questions later on As you can possibly tell from the title of my Of this talk, I like Star Wars And I was more than happy to exchange ideas with our very own master with Giru Just on a very philosophical question in a sense, but see for yourself Yeah, so anyhow, so the talk is about cookie cutter and cookie cutter is In a sense a command line utility that helps you to start new projects Following the best practices of the Python community Simply based on templates that other people may write for you author for you or you can just do it on your own We are hosted on github So if you want to check it out this odd ray are Slash cookie cutter and it's written in pure Python as you can see from the blue bar Yeah, so you can also find it on pi pi we are currently at version 1.0 and we do have this quite Large set of features. I think so one of the best things about cookie cutter is that it's working on all platforms So it's Windows Mac Linux and Python 2.7 3 3 3 4 and also pi pi We managed to add unique code support for each of those platforms on the Python versions And it's open source obviously So the technology is used cookie cutter users templates to create projects which can be arbitrary complex So we use gender to for the whole template team and we do support both git and mercurial Almost 100% of our code base is covered by tight at pi test tests And we leverage talks for just for testing all the different environments and Python versions, obviously So about the community we have a team of five people right now So it's odd ray Daniel Michael Paul Moore and myself And we welcome everyone to just participate and contribute to the code base Up to now we are 661 people I think but it may have changed from the time I Yeah, develop this presentation until today The people of you who are working on Django might know those people. This is Audrey and Daniel They are the authors of two scoops of Django. They just recently published the news version Targeting Django 1.8 Yeah, and this is them celebrating the 10th birthday of the Django project two weeks ago About something about the history of cookie cutter So it was in a way born at Europe Python Florence two years ago. So this is a Citation of Audrey So when they came back from Florence, they were like all pumped up and want to sprint on open source And Audrey had so many scripts flying around that she will actually thinking of being very useful So she wanted to publish them but every time she was facing that She was doing the same work over and over again and this eventually was the moment when cookie cutter was born Because she said well, why not just have a template for it and focus on the like a Production logic itself instead of just setting up a setup pie all the time That's just plain stupid. Yeah, so she decided to dig into templates and Learned ginger to or get the deeper knowledge of that Yeah, and it wasn't until I think it was May 2014 that I Started contributing on cookie cutter So it was a very simple template at that time and you see there is like a spike So the next contribution was in November. I had like this a bit of a crazy idea So I wanted to learn pie test or get more knowledge of it And well, I said, well, they have a code coverage of almost 100% the code is very very clean So why not just transfer the whole code base? Python tests to just pie test and that's actually what I did it took us I don't know maybe 60 days and Right now with the latest release. We are pure pie test tests and it worked out perfectly fine So this was ultimately the reason when I was promoted to get the commit bit. I think Yeah, so in this presentation, I want to show you just how easy it can be to Author template for cookie cutter and I'm very very positive that cookie counter can be used in various Occasions regardless of the the field that you are actually working on in the following I'm going to explain you how to author template from scratch So for this presentation, I'm also using like a framework for natural user interfaces. It's called kiwi So my question to the audience is how many of you actually know kiwi? Okay, that's actually quite a quite a bit. Yeah So even Gido recognized kiwi So I think he mentioned it on PyCon 2014 last year and he emphasized that people should Start contributing to the project. Sadly as far as I know no one from the core contributors is here right now Yeah, but the best thing of cook kiwi is that you can just write Python code for your mobile so I think that's that's just pure awesome and I Think the only person disagreeing to this may be the pearl guy from the lightning talks yesterday So it wasn't amazing talk, but still yeah, I think we should do more Python on mobile devices So the first thing when I what I do when I start a template from scratch is usually just creating a project and get up because it's Just having features that you really want to leverage It's like trading a git ignore for a Python files It has a read me already set up for you and you get a license file for free as well So next you want to So those of you who are familiar with templating with ginger possibly know the syntax already It's like to using to curly braces then some kind of domain and the variable name So I'm using that since I want to use the repository name for both my Project, but also for my Python package. I'm using the repo name for both of these And inside I'm just creating four files one is an init to have a Python package then the module for my application Then I have like a kiwi file kiwi uses its own very Language of describing user interface in a very declarative way So it's very very easy to do rapid prototyping and such but it's totally optional So you can write your user interface programmatically at well or you can just combine it. It's up to you And then I using a file called main pie So when you decide eventually to deploy your Python application to Android device for example There is a tool called kiwi launcher. It's in the app in the play store and it enables you to just run Python source code without like compiling it So you don't need to create an APK for that. You can just run it through the comb to the kiwi launcher and it will just work Yeah, so inside of my in it. I do a bit of like What's that? It's made of information about my package and I'm using like a full name and email on the version Pretty standard I think next we This is the module for the application itself kiwi does a thing in the very beginning that wants you to specify the version of kiwi that you are using it's just like a Safety switch that when you are using a very old version and you try to use kiwi Features that are not yet available. It will just raise a proper exception and you know what it's about then we inherit from app obviously and we Simply set up the title and the build is some way of so it will automatically detect the kiwi language file and return What's ever inside there? and This is actually one of the main features of cookie cutter you can use it for every Programming language or markup format that you can think of it's just it needs to be readable as a text so Yeah, that's I think that's one of the best features about cookie cutter next main is just running the application. That's basically it And as I said, it's one of the easiest way to deploy our Android app. So this is a kiwi file Again, it requires you to just specify the version that you want to use and This is like a root element you we want just to have a button and a text and the text of the button Should be the application title As I said, it's optional. You can do it in source code Just as you prefer One of the most important things about cookie cutter is it requires you to do two things one of which is Having a JSON file, which is called cookie cutter jason you specify all the variables inside there And the next one is to have a folder that's actually Templated so that's basically it. That's took you literally like 30 seconds to have a cookie cutter template This is how a cookie cutter jason looks like so you as I said, you just mention all the variables that you want to use Throughout your source code. I'm using my name or the author's name an email an application title I'm using an app class name variable. This is specific to kiwi. So I was thinking it might be very helpful for me repository name version and the kiwi version The values are the defaults So when you're prompted on the command line for entering those values, this will be like the default that's shown to the user Yeah, so talking about advanced usage What you can do with kiwi is you can template your variable and variables inside of the jason So there is a best practice on a Python that you are possibly familiar with that you have like a project name Which is human readable then you have a repository name, which is just our lowercase with dashes and You usually use all lowercase without dashes just pure letters for your Python package So this is not exactly what I've been showing here But what I'm using here is that I'm using the application title. I replace every Space with just an empty string. So it removes all the spaces and it adds an app Just the string app at the very end The processor norm should be all lowercase and it doesn't have the app Another great feature of cookie cutter is that you can have post and pre generation hooks So you simply need to have a hooks folder at the very root of your template and inside you can put a shell script or Python Module and it will be executed by cookie cutter either before the generation of the project or afterwards So this is an example of a post generation hook that I'm actually using It's a bit of code But the most important part is that you need to understand that Kiwi has its own way of detecting a Kiwi file language file So what I'm doing over here is just that I'm using by default the application class name as a Kiwi language file name But since the user is allowed so there's no kind of validation that he isn't allowed to use an app Like the string app at the net at the end of the class name I'm just making sure that Kiwi because Kiwi will strip as you can see it's does the slicing thing with the last characters lower app class name, so I'm just this is basically An adaption of the source Kiwi because horse called that's responsible for finding Kiwi files So where are we right now? So we have At the root of our project we have a JSON then as I said the only mandatory name you have a templated root name for your repository We have a Kiwi file language. We have a module. We have an init a main We have a license file that was generated by a github that I just copied over from the root read me You can I usually use restructured text for that So that's why it's not using the markdown file at the very former very beginning a hooks folder and the license and the read me So I'm a bit into testing so what I tried to Because there's no kind of way that's already very well established for testing Kiwi applications I tried a bit so and I'm here for the sprint So if everyone anyone is kind of interested in testing Kiwi apps I'm very open for suggestions and collaborating and maybe writing a Python plug-in for that So just approach me and I'm very happy to collaborate Yeah, so but I did find a solution in the very end. I'm using a It's just a part of the of the source code next slide will show you what's actually important So I'm using the interactive launcher. It's a feature of Kiwi where you can change the application at runtime. So it doesn't block you from changing the code So I'm leveraging leveraging that to modify my application eventually So I return the application and this is actually my test So it will just receive the fixture from pie test Which is one of the most incredible features that I use in testing frameworks And this is my test. It's just a plain assertion And I'm just making sure that the application title is actually what I specified in the command line prompt when creating the project Next up I want to have it as a pie pie compliant package. So I'm using setup pie I usually I originally had a couple of slides on that topic But since we had so many talks on the whole packaging and distribution talk, I just included some of the most important Resources for that kind of information So the official one then Jeff Knup did a very very great blog post which has I don't know a million comments on it And you know who presented his packaging talk I think it was on Tuesday and he also referred to cookie cutter So this is him and he's actually one of the contributors for the templates, but also cookie cutter itself So next up is Sphinx documentation. You always want to have like an auto-generated documentation for your source code And this is actually a funny thing that you can Leverage exactly the same thing. So I'm using the things quick start usually it will do basically everything for you to get started and I just literally feed the cookie cutter variables to Sphinx and it will just Put the variables inside of the Sphinx documentation. So afterwards it will just be done basically Another feature of cookie cutter is to have a user configuration So in your home directory, you can just have a cookie cutter RC And what it does is it will when you use cookie cutter and you use it quite frequently You don't want to answer the same values over and over again. So when I'm running cookie cutter on my own machine I'm pretty much know that I'm Raphael and I do use this email and my github username was still the same So what I do I have this in my home directory It's by I specify those values and it also features abbreviations. So typing you don't need to type that much cookie cutter cookie dozer is one of my Templates that uses build dozer to build the APK for Android And I just have a abbreviation for that so I can I show you on the next slide how it works And another thing is just abbreviation for github So when I run this command at the very top it just says I'm referring to github I want to use a template of odd ray and I want to use the pipe package offer and When cookie cutter is running as you can see it just clones it and it asked me for the details And it automatically sets up the values from my I can still override them, of course But it will just predefined the context Yeah, so I want to talk about features that are currently in development We actually much them already, but we still didn't find the time to actually Publish them on Piper just yet, but it's just a matter of days. I think so Next up is coming. We have Choices in our templates so it was requested by the community and we also find it very reasonable to have choices in templates So at the bottom you see I can specify an orientation for my app with key I can say it doesn't matter it will be resized and auto-adjusted, but I also can fix it to being landscape or portrait mode So when I run this from a template, I will be prompted by click I mentioned in the talk I think yesterday that we use click for all the prompting and it's working really nice So if any one of you wants to write a command line, it's interactive Just use click it was working like a charm So this is a prompt for choices I Implemented in a way that it will just use indices for the choices because users can put every text in there So it would be very long if you need to type the choice. So I just decided to stick for indices And this is an implementation for the click prompt because I didn't find any really great usage On GitHub for click prompts with choices. So I decided to share my my my findings to you So as you can see at the very bottom, I'm just using click For prompt the prompt is set up up front It's just a as you saw on the previous slide. It was just strings and showing the choices And the most important part is that you specify a type You can also use click boolean for example, so it will make sure that when you enter a value It's really a boolean, but for this I'm using choice So click will do every like if you type in something that's completely awkward It will make sure that you it's not repeated as long as you really pick one of those choices Yeah, so talking about the community. I Think we are doing a pretty good job at Replying to pull requests and answering features issue two issues So I really welcome you everyone to contribute and submit your own template or even contribute to the code base So right now we have 41 templates and total most of them are for Python obviously, but we do have very various templates already Some of which I don't even know what they really do but I Think half of the Python templates actually target Django So it seems to be a common case on Django applications to use a lot of Code so you may want to use a template for that One of the most popular ones is actually from pie Danny Himself and they do have I don't know so many so I think it's 700 stars on on github already So it's used quite frequently and it's it's not only Python code. Obviously. It has all those languages inside It's really great template. It comes with a lot of features Just not commenting too much on them. You can just check it out on github on your own Next up we have cook cut up pie library. This is actually from you now who gave a talk on the packaging topic on Tuesday so everything he's been Talking about he wrote a block amazing blog post on that topic and he Author the template with all the best practices that he's using for his own work and a lot of people seem to like it So he has features as well continuous integration Set up pie test talks, obviously Yeah, and I actually want to have like a quick demo of cookie cutter for you So just give me a second Yeah, so usually What I do is I Will just run cookie cutter in here So what I usually do as I already said I use the abbreviations But since the Wi-Fi is a bit flaky sometimes I'm using just my local copy of my template But there is a way of also there's a feature you can specify a flag with dash c Which will automatically check out a branch of a like a repository which is hosted on github So you don't need to clone it and change the branch on your own you can specify it and cookie cutter will handle it for you So when I'm running this it will obviously ask me for a name and since Let's just pretend for a minute that I'm Harry and I decide to I want to write a like a Python app that's Let's people met meet on conferences How many of you have been to the lightning talks just yesterday, okay Okay, so my application will I will be pinder so The application class name as I told you The it will automatically update like the default value depending on the values that you entered before so obviously I said I want to use call my name pinder the app class name will be automatically adjusted I would just stick to the defaults for now the repository name I'll just call it fuba the short description. Let's say an app to meet squirrels squirrels badgers and mice at Europe The version well, it's in development still cookie cookie did an update just recently. So I should be on this version already so Yeah, and there you So and what you see at the very bottom after replying to this is actually my post generation hook So the template also features internationalization right now So I support English German Spanish and French at the time and using new get text for all the all this stuff So this is just me calling a make file that handles all the library setup So what I do then is usually I just go to the repository and I created a new virtual environment I Already want to use to set up like that folder for the Call it full So then there is a thing Katie uses Titan internally and sometimes I feel like it's a bit of a struggle to set up So I'm usually just doing it once and I know it works. So I use The dependencies from this very virtual environment So there's this command in virtual entropy that actually lets you use dependencies from another virtual environment so what I do now is Just calling pass and sell up by develop it will set up an entry point for me and I can Run what was the name pinder? No, that's wrong Yeah, so here we go. We have a running key application And it's as you can see it features the values that we entered I'm afraid the screen the font size a little bit So I'm just increasing the font size for the application There we go So it says like the application title then the short description that I put in It says that it's built with Kiwi And I can change like the language during runtime. So since we are here in Boba Just use the Spanish version. I'm not a Spanish speaker myself So I kind of depend on my friends to not fool me and just play a very very offensive stuff here, but it's I think it should be fine yeah, so I Was actually able to deploy it. I'm on a Mac right now But I was using Ubuntu and it was just perfectly fine once you set up a tool called build those ads and the Kiwi names Was as well it will handle all the packaging for an APK for you right now Kiwi as I said it's for It's for Mac OS. It's for Windows. It's for iOS. It's for Linux. It's for Android, obviously But the supports is by far just it's I think Linux and Android should be the the best Best environments for that right now Yeah, I can also use the German version and just change like the speed of in which the slides It has multi-touch and it has gesture recognition. So I really recommend you just giving it a try and see if it works out for you And it also has like I can click this is a link so it will automatically take me to the repository Yeah, that's it for the most part Yeah, so I'm actually writing a blog and in January I was Publishing like a series on cookie cutter. So if you really want to dig into this topic, feel free to just It's hacker bro.de and just find those three Posts they're all to two pages long and quite. Yeah comprehensive. I think Yeah, as I said if you really like the artworks, please give a Give my friend on them from Germany Some kind of love. So he really I think he deserves some kind of applause later on. He did an amazing job on those graphics Yeah, and other than that. Yeah, thank you As I already said you can find me on Twitter and github and thank you very much for your attention Thank you very much Questions please Hey, hi this project looks Actually quite similar to yeoman from JavaScript universe. Maybe you have seen that one. So I was wondering Have you looked at yeoman and how cookie cutter compares to it and what and do you think it's worth it to have Like our own python version of that Well to be perfectly honest, I don't know that project But I think there are plenty of tools that already use templates. So there's scaffold I think as well We do feature them on our github front page. So there's no like I don't know. We can we can still try to find a common solution. I think Just yesterday someone on Twitter said that he actually re-implemented cookie cutter and go so it seems to be a very fun thing to do Yeah, just I don't really know the tools. So but yeah, maybe a solution that we should have a look at Yeah Thank you for the talk. I got a question. How do you handle updates? so if for instance, I use one of the cookie cutter templates to create my project and Two months or half a year later realized that the template has now some cool new features in connect just Run it again and update my project which has now a lot of code inside Is this possible up to now? It's actually not but it's requested by the community and I Mean we are all full-time professionals. So we just didn't find the time to implement just yet But we are very open to it. So as I said, it's requested quite often So we still need to find a solution for that and once we have one. So please feel free to just recommend anything or Just submit an issue and we'll talk about it. Okay. Thank you. Yeah nobody else Okay, so maybe you want to give an applause to pilot to Daniel and Audrey as well They sadly couldn't make it this year to your apartment But I think they did a tremendous good job on this too as well So please give me do me the favor and just give them a pause