Add to Watchlist

How to Setup a new Python Project


Citation of segment
Embed Code
Purchasing a DVD Cite video

Automated Media Analysis

Recognized Entities
Speech transcript
hello everybody back come to the afternoon sessions that's he replied in 2014 when in this stuff and you are a member of the local . user groups and please book column Felix which you will talk aboat total set up a new point projects we were
thanks and welcome to my
talk so as you already heard so this will be about how to set up a new pleasant project so this will be quite often introductory talk but there might also be a few interesting tweets or maybe more 1 quantifies the user so it might also be interesting for them so
what to do when you start a new horizon project so the 1st thing you you need to do is just want to start implementing but before you can start implementing you have to set up a lot of stuff so you are you just have all your ideas together you know
which packages you want to use and everything but 1st of all you have to do the boring stuff before it can reduce the coding and what you usually need 1st listening even environments so
and you might have Python interpreter installed a new system and decide packages and system but usually have several projects and I just want so you need to have some kind of tool to to manage the different projects under different dependencies which might have and you just need to that's a project-specific environment for Europe for different projects and their average length this is a really cool tools to do that and you can just use it to install all your stuff there so 1st of all a few words about individual and so as I said
this is just a tool to create an isolated Python environment and what I mean we've isolated this that you get an old enticement freedom for each of your project and you get an on-site pictures for each of the project so and the only thing you need to have to install it as you or you just yet you just need to have and on your on your over let's say Tilbury Python interpreter package so we just started by up to 4 orders sources and then you can create in you richly environment by just typing in which and and then the name of the rich environment is just as
easy as that and this then directly comes with 4 was set up to use and to install you will include new virtual environment and you can then there's a small head PostScript activated but you can use to just let you know
which and to your to your path variables so that means you can when you would find its type I installed of something as after it just gets instantly of its environment and so on and to get out of it just have the activated and then you can directly jump to another of its environment if you will work on different projects at the same time so this is really a very good tool for that so in a few
words about it so you probably all of you know but as it is just a tool to install and manage your packages and
middle-class installation from the package index is its local global was also binary distribution so whatever you have so for example to get together and install of the latest version of the package in this case it just shows the package pi scaffold which you will learn about in a few minutes from the public piety I just happen to be installed by so this you standard very of often so but it gets more interesting if you have something like versions of the packages which you which which are different in different projects for example so then you can use the requirements specified hasn't been started so for example here you just take you actions which I had an open set by and so on and what's even
nicer is that you can also use just the whole requirement find to to get volume all you dependencies in once so it just use this minus our option and to all you requirements you just type them in your package in your file requirements for example so if you then after type and it frees you see what you have installed so in this case it's just prior scaffold and a few other things you will see it later in the term demonstration so
OK so now you have fewer your environment so you can restart with your project so what what you need to do to organize it so the 1st thing is you need of course version control system so this you need all the time and for this talk and find a demonstration later access to skip because I think this is a good choice but there are a lot of other is also so and after you have this this set up so this is another thing which you have to do then you need a reasonable directory structure and you need of course tests and documentation so these are the things which I have to take care that have a good destruction for it and that
you have to have the right tools and so on and so on so what is a good directory structure for it the
1st of all if you have a few words about what I mean in the end the following with module and package so module is nothing and then the file containing Python code to something which was too but high end and a package this is this a folder which contains an entire file and all of the other Python modules which 1 class in this package so in this case you have to you have to package might take which is an approach which has the same name so this is usually of a good practice that you just the name you approach a costlier package a licenses and in this might have been just as in a
powerful so this just the best so in principle and that you can import all this stuff with the inside of the directory structure and you have your you modules in which to do the actual stuff so you actually implement implementation in module 1 and module 2 in this case and you might also have some practice subpackages and if you're doing different things in your package and then in each of the sub picture sub-packages there's another in a Python electric and import all that stuff afterwards properly so this is the 1st step so and then you need to test the test and the
documentation so this usually should go to separate folders so which i just call you test for the unit tests and docks for quite some distance documentation and inside you test and test so you know you could have another in Python and you should have all you for each of you molecules you should have a separate test module which adjusts the starts with the which test and school and and what name so then you haven't really you know or way and you know what belongs to what and you can start after with the test for example had to do with it whatever it is we we see moment that ducks following you have
all your reStructuredText text files for example so this might be index RST which is the the 1 that's the index html things and you might have a configuration pi animate find if you have those things set up beforehand and there is also another file which was set apply about which I will also talk in a few minutes so or
actually you know so policy of the next step if you if you have been implemented everything have everything in order and what you need to do then this you you want to to to tell this stuff to other people so you want to distributed in some way so how to do that so they're Python comes with a watching on board toward which is called utility so this this is actually this basically the set up I want to know which I showed you so but there's also something the concept of was which was hurt and which is that which comes with richer and so which is more or less just an extension of this of this due so usually I would just recommend to you set up to assist your hand stuff inside and that might also be referred models of distributed so this is another thing which is something in between so this was kind of a flock of set up to but that someone has no illusions so just that you set up to introduce you to use if you don't want
to get additional features OK then if you have your package everything in order and you want to install it no individual and so then you you just have been
pies instead of installing and this instance everything everything which you have just implemented into your virtual environment what is helpful during development is this set up I develop command because then there were just links created in your site packages in a new virtual environment and this means that if you change something in your source code implementation than it directly change the installation individual environment otherwise you would have to type in install python set up I install again afterwards you changed something OK and if you want to take it and ship it then you can just use this set up I asked this the set of the ETC commands so this means the source distribution on a
binary distribution so ready for this will be city toppled the and for the binary distribution is of course dependent and machine so this we would also like to see later in the demonstration
OK so now we have found on this stuff so but if you want to to ship something to somebody then you have to give it away because of the words that will then have a new will version the few weeks later a few months later and then some 1 was maybe 1 0 . 0 and some at some time you have a 1 . 0 or something so you need to update that Russian stuff all the time so that means you need to update the version that a few package a module and some you need to work to it to get the sense identification in the in the Python and you need to update and document in this in instead of pilots and that sort of
information of the set up either that you test test to the right name for a package and also have to the right thing and for the major information for the analysis of for example and this is really cumbersome to do this manually because then if you really have to do this all the time you will forget it and then you will have to do it again you need something which is just pass this automatically for you and what this is a course module Virginia you package so this this managers just the world from so I get so this means that you can just would attacked if you want to read so just tech version 0 . 0 and afterwards you directly has the right to phenomena should then do work analysis of the disk and you directly after the version of the last vertex so this
is really cool my makes recent OK and so on this would be the let's say the basic behavior of of after the set of points and if you don't want to do you test and the documentation also was set upon so that there director comes before the for unified unit has packages comes on books justify I and set up like test and it runs on your test and you test for that if you have set up instead hiding correctly just wants them all with unit test OK so maybe you want to want to use piste Pietist instead because you
noticed that is OK but maybe you wanted to coverage of something else so then there is the possibility to have been set up this command class documents so that you can just define your old command classes that's the way you can use stand test instead of unit test for example and just run it a set of why you want to do something like 5 flakes or whatever so because can just to everything you want with instead of the set up and what is but by putting to do for example is to run the documentation but so you overwrite you command this command thing and then you can for example to set up by docks and it just landed documentation with with a set of points and otherwise you would have to type in order to make a 2 minute it can something like that OK
so now I have talked a lot about that up here so you see you have just as boring code now so in this case is just imported from set up to a set function which is basically what is in there and a smaller helping function find packages and know what is really the the basic of the of set of function is that the name and the version of this is also what your package will be called so you about for example if you do an instance and you need to to Telenor wire packages what has to be included in the distribution of Sunday for example used sign picketers where include everything but just
execute the tests for us for example and this installed requires this is this is testing in beforehand before you install package is all this stuff is already dead and if it's not there it would
install it afterward layers using story but as we have already done it beforehand with with all of the requirements for the we can also known at this position just use requirements filed for example and have it also again in 1 in 1 place so the test would this is just a test which need to be run by the by acid up test commanders have already seen and what is a nice functionality is this entry points so there in this in all take into my package which we had before there was this module 1 and inside is much you wonder might be function run and is trying to run gets maybe some arguments and you can't just if you if you set it up this way you can just after words in the on the command line type run and then the options of this and then you just run dysfunctions will so this is another interesting thing if you for
example want to start a web server low whatever just like you where the central point OK
so to to set up the prize and go check you as you know we need to do quite a few things so you need to think about a good project structure you have to set up a gift repository of something or another version control system you have to to auditory expressions that applies to the a lot of a lot more commands and the ones I have shown you how you have to take care of the versioning and everything so all this stuff this is pretty and let's say tough if you if you are new Python uses of it is boring if you if you experience so you don't want to do this all the time and again so uh there and this was the case it's fast when we and we did this over and over again for small projects to this was why we just implemented a small tool which is caused by pi scaffold which just ask this for you so can interesting started by applying the eyes have installed by scaffold and the sources so we it up so on and it only
requires vigilance on and get to be installed a new system and setting up a project is then just simple put up my bro words and then you will have everything so now I just give you a small short
demonstration so
let's say we we want to have a natural environment 1st so already done so now we have a rich environment in our directory so we saw that we have to to activated so now it's activated it changed the prompt which you know which of the sun's lights so now what do we want to do we want to test scaffold and if the network to screw you would OK then so check what we have inside all its
environment so that has good for the standard version . 7 at the moment so now we are need new approach so
just put it up already done so then we have our approach followed my approaches instead we have no
for example this set up by we have the approach forward a microchip we have our tests followed and our documentation followed so for example reopened test as a leading player in Austin Microtech so there's a there's another thing this worse and worse inuktitut comes from watching you still don't have to go into details about that so you don't need to care about it usually so and then we have this requirements for for example so that could not
put on your requirements for example but there would be an employer outside of government and this
manifests in so something which you which you might know this is about as this so this is kind of the template fired when you can just think you would what you want to include in your source distribution and what is
good practice is to have something that can read media so we could also you stand in your this is me that information in your set applied for example to
have to directly on on Titan and knowledge see what we wanted to do we wanted to into the In started so already done so of the words and because was unknown for the moment so we might technology 1st version of which might be where and 1 and recorded there's something so I don't know if
you look through to get K then Israel and see almost nothing but there's no new the new tech in there and so now we
could for example do the highest instead prior so now we have forward this
in year and we have now all they FIL
lactoperoxidase microchip or just 1 party so this is not diversion which is gets from version know why at this disk take the name which we gave in in our setup time so let's have a look at the end and a set of points shortly so that you see but
that actually happening there so you need you know we do need to to do anything but of despite all images that took off in order to maintain information which we have to use this command can pass and was it has that this stops and set up the toxin and testing them already configured so yeah basically but as we
wanted to do so we wanted to have maybe something like that and the distance would have to see this this to so this is then and induced another another
topic which is Japan and under a new machine and if we want to run now for example the test so on this is as easy as that so if we have no test
positive coverage is perfect for them and if you want to know how to run a for example the stocks and so there was this will fail because we have no and and started to sing some to notice is the only thing which you which would then need to do to this way so
it doesn't and this were then
tested the
documentation takes a
moment to so don't know we have
everything in our dogs for for example so if we now want to to have a look at how to select as you can so just
clusters current in the year
so we have on the project and after 2 steps forward and then it comes into a job to HTML and there you have time just index HMM and you see
here the documentation for something between which we just wrote to desist from 1 s much a reference and what you want but you could have a new injury in txt so and is basically so yeah as as you want to know more
on so you can now of course the last knowledge has come to our to our use of the words
and then we can discuss recent shh score thanks a lot for the
talk of the any questions yeah please come
forward to the microphone so the recording and thanks what about the we'll packaging yet repackaging you could just do With was set up by the this week for example and then you have directly down to be there so you you realize that is a good thing to do so we can just just do it so would the the would from
something like that so you need to cause instead we beforehand no another which was question that's why
I'm asking is always missing like is the new cool formant implements some or all of doctors to know you can you can do it it's so the a good thing to do here from course will to the most you can do it and and uses it as we used in our knowledge things you are there
any more questions OK thanks a lot
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation


Formal Metadata

Title How to Setup a new Python Project
Title of Series EuroPython 2014
Part Number 87
Number of Parts 120
Author Wick, Felix
Wilhelm, Florian
License CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
DOI 10.5446/19970
Publisher EuroPython
Release Date 2014
Language English
Production Place Berlin

Content Metadata

Subject Area Information technology
Abstract Felix Wick/Florian Wilhelm - How to Setup a new Python Project Setting up a new Python project from scratch can be quite hard. How to structure your files and directories. Where should my packages, modules, documentation and unit tests go? How do I configure, Sphinx and so on? We provide proven answers! ----- Whenever a Python beginner starts with its own project he or she is confronted with the same technical questions. Questions about a well thought out directory structure to hold all the files. How needs to be configured and even what it is capable of like specifying entry points and other goodies. We show from the experience of our yearslong work with Python how to structure your Python project in terms of folders, files, modules and packages. How to configure to specify your requirements, to use it with nosetests, with Sphinx and so on. We also elaborate on the usage of Git and Versioneer to help you version your package.
Keywords EuroPython Conference
EP 2014
EuroPython 2014

Related Material


AV-Portal 3.5.0 (cb7a58240982536f976b3fae0db2d7d34ae7e46b)


  782 ms - page object