Writing Awesome PyPI packages in Python

Video in TIB AV-Portal: Writing Awesome PyPI packages in Python

Formal Metadata

Writing Awesome PyPI packages in Python
Title of Series
CC Attribution - NonCommercial - ShareAlike 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 and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Writing Awesome PyPI packages in Python [EuroPython 2017 - Talk - 2017-07-14 - PyCharm Room] [Rimini, Italy] One of the strengths of the Python programming language is the huge base of Open Source libraries. The PyPI (Python Package Index) repository provides currently 105,917 packages, many of them developed actively by contributors. This talk is a tour through various tools and practices, which help to keep your package in a good state for your users and make it easier for other developers to contribute. One can find these practices in projects of different size, such as Django (24,244 commits, 1,397 contributors) Pandas (15,005 commits, 754 contributors) and Faker (20 commits, 3 contributors). Some things to consider when creating your own package: using a Makefile for automatic testing, coverage analysis and environment setup. structuring your .gitignore file. using pyenv and .python-version for Python version management. using tox to ascertain that code is working in different environments. squashing different configuration files to a single setup.cfg file. using EditorConfig and .editorconfig to automatically set project coding standards in the editor
Ripping Open source Software developer Projective plane Plastikkarte Word Process (computing) Voting Repository (publishing) Operator (mathematics) Configuration space Game theory Data structure
Dataflow Default (computer science) Functional (mathematics) Multiplication sign Closed set Projective plane Sampling (statistics) Parameter (computer programming) Field (computer science) Usability Latent heat Benutzerhandbuch Personal digital assistant Repository (publishing) Configuration space Software testing Software testing Data structure Data structure
Open source Computer file Computer file Projective plane Formal language Template (C++) Tablet computer Repository (publishing) Finite difference Synchronization Cuboid Text editor Data structure Document Type Definition Digital Equipment Corporation Computing platform Physical system
Meta element Information Interface (computing) Projective plane Set (mathematics) Flow separation Metadata Revision control Personal digital assistant Different (Kate Ryan album) Configuration space Software testing Quicksort
Revision control Mathematics INTEGRAL Personal digital assistant Configuration space Set (mathematics) Software testing Line (geometry) Mereology Error message Plug-in (computing)
Addition File format Line (geometry) Consistency Projective plane Electronic program guide Set (mathematics) Line (geometry) Cartesian coordinate system Software maintenance Revision control Word Configuration space Spacetime Text editor Software testing
Point (geometry) Default (computer science) Weight Uniqueness quantification Multiplication sign Projective plane Variable (mathematics) Machine vision Twitter Neuroinformatik Revision control Personal digital assistant Different (Kate Ryan album) Text editor
Revision control Integrated development environment Copyright infringement Different (Kate Ryan album) Projective plane Configuration space Software testing Software testing Line (geometry) Mereology Freeware Machine vision
Touchscreen Error message Semiconductor memory String (computer science) Software testing Pattern language Open set Streaming media Error message Typprüfung Asynchronous Transfer Mode
Error message Integrated development environment Repository (publishing) Line (geometry) Projective plane Speech synthesis Software testing
Server (computing) Installation art Computer file State of matter Software developer Multiplication sign Projective plane Set (mathematics) Maxima and minima Computer programming Programmer (hardware) Data management Video game Software testing Software testing Physics Task (computing)
Point (geometry) Standard deviation Projective plane System call Template (C++) Revision control Goodness of fit Integrated development environment Repository (publishing) Different (Kate Ryan album) Forest Revision control Configuration space Software testing Text editor Software testing HTTP cookie Data structure Task (computing) Position operator Task (computing)
Revision control Slide rule Sign (mathematics) Goodness of fit Different (Kate Ryan album) Digitizing Website Software testing Software testing Product (business)
Personal identification number Mobile app Parsing Information Software developer Projective plane Set (mathematics) Bit Rule of inference Different (Kate Ryan album) Operator (mathematics) Configuration space Speech synthesis Pattern language Software testing Sinc function
I Magdalena and I a jungle beckoned developer from Berlin the I work for their digital agency locally as a challenge I made in my everyday Warwick is working with men the project the and frequently of switching between them this is why I'm interested and project structure and configuration In my talk and I will talk about some tools and techniques and how to approach this challenge I implement that's an a project and do other votes against humanity and it is based on the card game DevOps against humanity hand In this game you need to do all kinds and create sentences about development and operations the all sentences and phrases and words as well as contemplates are available in open-source repository and in Bridget from how repository under the Creative Commons license but now let's have a look appestat job and DevOps against humanity rip a project the project
structure I want to find things in my project easily the I don't want to be into each folder and file to find the right place to add a new function or a new tests what can you do about it we can use a standard structure so in case of your devils against humanity we have a dataflow therefore at the time and wrong folder for the main project college the and a tests and folded for tests you may already know this attractive because this structure is described and is described by the Python packaging and user guide and it is also available in sample project repository this it was a Tory contains uh along with this nice folded scaffold also a Banjul 5 these are set up by some innate how they tell you about project and configuration files some of these fires are and the others are already breath field for us so for example as set up by already and imports setuptools and has set up finds in the with default argument moreover it the ease of the DAG followed arguments has extensive common extensive documentation of both so it is easily to exchange it for the real specific for the project argument In this talk I will concentrate on 3 fires that are already provided by a sample project and would add on the way 3 other Chanel fires that this collection but 1st before we jump into the configuration let's have a look what's draw DevOps against humanity does let's draw us a sentence the they're starting from back
upstairs due to a closed cup of coffee I imagine it could have happened
and now don't get in your I want to have in my repository in only defies that belong there yeah I don't want to include in the outer generated files as they can lead to box what can we do about it we can see from the project started to include duty in our some templates for GT nor are provided by tidy tap in data DTD nor repositories they have their templates for over a hundred languages these tablets are very elegantly structure the R and ignored file are structures are classified based on their gene so that is quite transparent and easy to extend you can also work Baron in mind and have for especially for open source project that also code editors and so different operating and platforms systems also produce some outer generated files and also for DEC on indeed in our repository provides templates and then and they're and global folder no the another great so what does DevOps
against human societies it faced 90 per cent of everything is a jar full of spaghetti unknown but they're like spaghetti set up a
CFG set of conflict is a file where we can continue with our set up we can include their information meta metadata about the project and it can also serve as interface for configuring different command line tools for example we can conceive good here by test knows coverage and flakes apes I sort of things each of these tools could be configured in each uh on the separate air sea or in the file but we can choose to have 1 common interface In case of DevOps against humanity and we well and use set up configure to configure our tests
so 1st when we run our tests without and the configuration I just we run our own 8 tests and it will tell us that the past but we want to have something more verbose so we aren't some
integration and set of conflict in 1st part and say which tools you wants to configure it and with adults line we say the what should happen when we run just command so we want more publicity we want to and allow at the Barker we want to have shorter trace back and we want to always include that aid flakes and I search plug-ins the additionally in this fives we can also compute with our plug-ins for tests and we can add some style configuration for example here we say that we want to have longer lines with 96 hot characters and that we want to ignore some that errors so now when we run our
tests there are indeed more verbose a part of our 8 tests and by this to run for each of our home College violent also tests for it that ain't flakes and I sort checking whether our pilots correct In case of some of them style checking test to remembers what was the results and if the 5 didn't change since the last run the test is keep this is why some of the tests here are yellow and are marked as skipped so now as we country our test we deserve
another to it and we can give ourselves a sentence there was no good solution for if he always with fruit axis so we build our own the
another way of thinking editor conflict I want to have a consistent style guide in the project the we already sets that we can In and 4 is our style now with some tests configuration what we can do addition the so we can I use and its work on the additional config enables to create and maintain maintain style guides for projects we have that a configuration file . editor can't think and there we can put how we once the our different fighters to look like and the editor conduc provides also a large set of lines for different editors so they can read the configurations and actually automatically I'm confused words the format or applies in the desire with the desire and style guide surprise surprise the
next sentence is I made a new editor better than the men in most of the possible weights it's called Twitter Net next thing I
like I would like to have as I would like to my project run under different Python versions a tool that comes in handy here as pi and time and it's a tool that enables in studying and managing different Python visions on your computer you can configure its by setting environmental variables or also explicitly saying in . Python version the file which version unique in this case Python 3 point of the the 3 . 5 3 and 4 2 . 7 with the 1st being the default 1 and no Cochran use is how
I resolve all my marriage conflicts I don't know about you I don't it's apart on and
running our tests our project in different environments we may also want to tested under different environments and with different Python versions and a tool that can help us here is talks it talks is also an example 1 of the examples of tools that's cannot be configured In our set up con conflict it requires the pirates configuration file talks the need and here we see the an easy example home configuration in the 1st 2 lines it saves we environments we want to use and were free Python visions and in the 2nd part of its face what should happen in each of these environments so we want to in each of the environments we have 1 to installed style our dependencies which are defined and set up by and then in each of these environments we want to run test of coverage
so we run talks the then we expect that this beautiful picture of passing tests will appear on our screen but unfortunately it's
not what happens we get and error pattern 3 passes but vitamin 2 complains about some type error and indeed we in our culture we check what's happening and we go and we see that 1 of our tests is creating in memory file in memory C is defined and that's a problem and in Python stream and C is the requires file open under the 3 modes but in Python to it requires file open under a byte mode so we quickly in the
fix this issue of and ran our talks again and now all the tests are passing and talks is smiling at us of course it doesn't mean that our tests at that our project is 100 corrects as we already here paired in quite a few speeches during this conference but at least we know that the things that we tested that the way they were consistently uh and they're all this free environments and yeah I that's just save us from the pushing a bond you go to the repository so after this heavily dividing you agree that we deserve a treat and we get another sentence the
give you're writing and that that's Indian Ocean States yeah no the it's
time for our final file Max Make file on make fires in I will mimic fries are typically used in c and with the programs but make files can also make and the life of Python programmers easier and they provide a way to ultimate eyes some common and tasks so if I don't want to run long command or a long set of commands I can just write make file here in this example we have to make command for a running to tests for and coverage and foreign development installation of the project but but you can arts and anything think you imagine you can clear your pick fires you can clear your yield Phys you can run your server it's also provides and documentation for your project so I about most typical things you and you know you can you can do with that so that's the Makefile and to define a don't DevOps against humanity sentence is the
secure our next around the founding management states we need kill minus 9 tough 1 and ch
known to sum up if you are in a situation dots the you are dealing with many projects and you need to switch between them and there are some things that can come in handy you can use standards structure for your projects you can keep your repository clean and stay care that's an unnecessary it fires 1 be included in the repository you can take care of the style so the call to gets more readable you can't and forests have you good style with test configuration which we did in set up conflict and we you can also provides editor accounted for that you can use different environments and to use by and 4 . 2 which is configured and . Python version and you can use stocks for running test under different Python versions in you can out to mates common tasks for the project in the make file the examples of configuration and that they just show what is provided in my repository lender of the that alter dural DevOps against humanity in and if you are in such position and when you are happy with the structure of the project that you have and with the configuration you have then you can a good so next to the point where you can look at is cookie cutter and cookie cutter uh enables the creation of templates then you can then duplicates into into projects and that's
all for science I would like to thank him to develop present a pleasure to work with and some others that's inspired me on my way thank you very much for coming
few among the few but if you have any questions please raise your hand be but of yeah the I think that kid Dino website deep ignore built by you know that it's a perfect to reference instead of downloading the did not fast and you can just write what are using a product like bite undone go quite charm prevent that would lead to up what would automatically generate digit ignore 5 for you have you might be worth mentioning that nice so as again I then know that was the name of that'll get ignored but I 0 it so website and giving I O all the stocks find all the present versions very you know the tell who could you repeat what's the question about the talks what does it do or the holders of signs of Pisces versions of installed and whites together with from on and so there is no talks planned of target planning and so on this says how it finds the different versions so you can use by and have to install of different versions of vitamin and then talks will be and are able to find them any other questions and and yet hello could you go back to the talks Feeney you have on the slides this 0 so it's here so I think it's
not good refuse baps equals thought it best uh because what it does is it actually installs things before installing them package of your package but you should actually use extra so he calls best so it support appearing stocks 2 . 4 moms liable using extra and test is the name of my x and here I am installing the requirements for
extras that is called tests yeah sure sure that box since we're going to point 4 has a special setting called extras for just for this so of the update just doctors thinking yeah hi thank you for that is very informative talk that is quite useful for the pin project uh I wanted to ask if there is a way to condense information the in the last 5 or 0 youth there we should provide for example all the by the version in modern once rules for example in so that means that's the G and into the fire if there is a way they were right uh to have just 1 5 of above a reference for everything that and import does information from talks so long from stood up and so on so there are difference of opinion among developers whether should be a way to do that or the or the weather is more it's more pretty that each to his speech on the final and depends a bit on the people who provide a tool which ways of configuring the tool they provide some many tools that enable this set up con the configurations so you can and country where it's provided the configuration of different tools and this 1 file but there are some like talks that doesn't support that so then you need to to have separate place that would they want to don't want include 2 questions so it's not that possible to have 1 hard because desire pattern parse far uh and sometimes don't so there are some attempts to prepare something called the which will be in the common language and but I think by competent ago operators are working on that so I don't think will soon see that so soon do we have any more questions doesn't look so OK and thank you model on a piece of thank you to it
thanks so much and please don't forget to rate the stock in the app