Publish your code so others can use it in 5 easy steps

12 views

Formal Metadata

Title
Publish your code so others can use it in 5 easy steps
Title of Series
Part Number
46
Number of Parts
169
Author
Samastur, Marko
License
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.
DOI
Publisher
EuroPython
Release Date
2016
Language
English

Content Metadata

Subject Area
Abstract
Marko Samastur - Publish your code so others can use it in 5 easy steps As developers we all love well-documented, well-tested packages. If we do the same for our code it is easier for others to re-use our hard work, and maybe even contribute. We will take a quick look on how to do this using popular tools and only a small investment of time. With Github and some simple tools, setting up a well-groomed package doesn't have to be difficult. ----- Every Python open-source developer wants their software to be used. As developers, we trust software that is tested and well-documented. In this talk we'll go through 5 steps for how to do this for your own packages. We will take a quick look on how to do this using popular tools and small investment of time: - Write a setup.py script for a pure Python package - Set up py.test, tox and coverage to test our package with multiple versions of Python - Configure Github to use Travis CI & coveralls.io to automatically test our package every time we commit - Register and publish our package to PyPI - Setup our documentation on ReadTheDocs
Loading...
Ocean current Workload Goodness of fit Red Hat Computer animation Independence (probability theory) Information technology consulting
Slide rule Computer animation Scripting language Content (media) Code Coma Berenices Information HTTP cookie
Category of being Slide rule Computer animation Scripting language Multiplication sign Information HTTP cookie
Computer animation Root Code Multiplication sign Statement (computer science) Directory service Coefficient Power (physics)
Computer animation Software testing Directory service Limit (category theory)
Demon Information Divisor Computer file Set (mathematics) Element (mathematics) Sheaf (mathematics) .NET Framework Mereology Formal language Metadata Independence (probability theory) Computer animation Personal digital assistant Software testing Subtraction Descriptive statistics
Code Set (mathematics) Software developer Sheaf (mathematics) Online help Parameter (computer programming) .NET Framework Formal language Metadata Wave packet Independence (probability theory) Computer animation Hypermedia Personal digital assistant Operator (mathematics) Website Descriptive statistics
Point (geometry) Domain name Set (mathematics) Distribution (mathematics) 1 (number) Sheaf (mathematics) Electronic mailing list Unit testing .NET Framework Mereology Independence (probability theory) Revision control Computer animation Software testing Software testing Software framework Information security Task (computing)
Computer animation Computer file Software testing Software testing Right angle Functional (mathematics)
Revision control Default (computer science) Suite (music) Computer animation Inheritance (object-oriented programming) Personal digital assistant Code Software testing
Multiplication Computer file Inheritance (object-oriented programming) Software developer Sheaf (mathematics) Set (mathematics) Parameter (computer programming) Revision control Computer animation Integrated development environment Interpreter (computing) Configuration space Software testing Software testing Subtraction Resultant
Point (geometry) Computer animation Personal digital assistant Multiplication sign Internet service provider Variance Speech synthesis Software testing Software testing Event horizon
Computer animation Integrated development environment Ranking Software testing
Revision control Multiplication Mathematics Computer animation Multiplication sign Similarity (geometry) Software testing
Service (economics) Computer animation Open source Continuous integration Projective plane Website Continuous integration Cartesian coordinate system
Email Installation art Service (economics) Computer file Multiplication sign Mobile Web Sheaf (mathematics) Formal language Revision control Software testing Organic computing Subtraction Online help Coma Berenices Matrix (mathematics) Variable (mathematics) Formal language Inclusion map Computer animation Integrated development environment Repository (publishing) Interpreter (computing) Configuration space Software testing Computer-assisted translation
Inclusion map Installation art Computer animation Integrated development environment Scripting language Personal digital assistant Software testing Software testing Matrix (mathematics) Formal language
Web page Point (geometry) Touchscreen Computer file Sine State of matter Multiplication sign Software developer Projective plane Mathematics Computer animation Blog Moving average Software testing Pairwise comparison
Mathematics Computer animation Software Multiplication sign Noise Condition number
Service (economics) Touchscreen Computer animation Open source Projective plane Computer network Limit (category theory) Information Website Freeware Cartesian coordinate system
Manufacturing execution system Multiplication sign Uniform resource locator Sign (mathematics) Repository (publishing) Quantum Subtraction Condition number Data type Metropolitan area network Raw image format Electronic data interchange Process (computing) Touchscreen Information File format Projective plane Electronic mailing list Usability Coma Berenices Web 2.0 Computer configuration Computer animation Repository (publishing) Uniform resource name
Web page Electric generator View (database) Building Projective plane Information privacy Uniform resource locator Summation Computer animation Revision control Quicksort Condition number World Wide Web Consortium
Default (computer science) Installation art Computer animation View (database) Building Revision control Configuration space Energy level Mereology Condition number Maxima and minima
Revision control Electric generator Mathematics Computer animation Ext functor Extension (kinesiology) Condition number Extension (kinesiology)
Computer animation Bit rate Software testing
Computer animation
Point (geometry) Mathematics Computer animation Computer file Personal digital assistant Source code Distribution (mathematics) Set (mathematics) Login
Point (geometry) Revision control Computer animation Computer file Repository (publishing) Forcing (mathematics) Multiplication sign Physical law Line (geometry) Information security Data type Connected space
Computer animation Projective plane HTTP cookie Line (geometry) System call Template (C++)
Email Installation art Slide rule Computer file Scripting language Multiplication sign Boilerplate (text) Content (media) Code Coma Berenices Mereology Template (C++) Computer animation Repository (publishing) Personal digital assistant Revision control Right angle Information HTTP cookie HTTP cookie Reading (process)
Protein folding Computer animation Personal digital assistant Forcing (mathematics) Shared memory Configuration space Software testing
Game controller Kernel (computing) Torque Configuration space Software framework Software testing Mereology Units of measurement Theory
Computer animation Open source Direction (geometry) Sheaf (mathematics)
MKS system of units Red Hat Computer animation
you want to be in
thank
and so on yeah I might have unintended independence of of goods consultants and also have a few packages
from my PIN and this talk is an introduction to the current workload and I'll use out which both me and I think you can of for
most people and it's easy to change is needed before I go on I just want to this if you have additional resources that really important 1 important is the last of which is the name of the
song so every year other things I included immune to that 1 that's all you need so that the content of this talk is how to use
about something and we will look at your on because of the time and some this is mostly about things and I think that if you if you're going to publish quite a lot of which I think everyone
should know and there's something to contribute its things and did well which means that property tested and documented and things which so many and used by the home working baggage we can't really listen to think about in
their home and its power the 1st thing we need to which every time I it is the coefficients
can set up the which goes into the root directory next thing that we need is to put how cold some code we want to distribute come so my imaginary packages of that and the directly users by which is the same name that would be using what statements important that's you
big name well in that regard how you could probably differently but by computing come thing that I like to do is to separate testing the limitations of the directories
because that's where column there easy to find in there was easy included exclude from package as suited so was have
this is now we need to look at the outset of buying and house to the completion of
which is composed of 2 parts on the 1st part is metadata about how this itself and the other part is that information which was by and how to handle this is what you do it coupon bonds and things like that so the metadata section and highlighted here is mostly about what this package is what it does is it from the under what license and general those elements of different factors as explanatory so they're not going to do just but I like to point out the thing so that the 1st 1 is the long description how which in this case is included but my advice would be to put using external file it is that you can reuse the same description of how and by
media on behalf of have and how home you should go to school and so on you have also doesn't care about much which 1 to use what's being like 9 different formats but by behind so all right the description of the research text on the next thing
to think about our classifiers interview and how the half of the site home and those of you who made amends he's a impossible but also used by developers to use to quickly decided packages of interest and supported to keep updated and to think about what kind of things to do with the and the 3rd thing is license so well it's very wouldn't be 1 because this is broken mentioned having a total mathematical operations analyze and this means that in fact the copy so it's not no use to anybody else on except you and you need to give it a license to do and if you need help with this so you can talk to me later if you want otherwise have somebody without any legal training whatsoever and this is a metadata section and the next thing is to include the code itself so we do this with the packages of actually it's parameter which has used the relative fast to decode of packaged our case that's buy stock and in principle that could be everything you need but a lot of packages a lot of interesting packages also have some kind of an external dependencies and those are
handled with installed required
section you which is a list of all the external dependencies via the names of the same names as their use and by the ion and you can also specify version which really should so you can be limited to the matching ones that were not really good compatibility and also ideally is liberal enough that you can also the couple automatically and not fixed resource security fixes for dependencies so at this point we have a package and that's the that can be installed locally in but for which we don't actually know that if it works well and for that we need to and tests on the domain task here at the Conference in previous conferences about testing and from avoid going into like this is a good idea I think the probability that it is and by comes with many testing frameworks you're free to choose which everyone unit test is part of the distribution itself but neighbors have preferred to have by just because it's a really powerful and flexible framework for analyzing started on it's also
easy to set up it will find tests just about anywhere as long as the files that contain them start with test underscore and that's themselves are functions that have test on the score as well so I since started to and the right you
get this may be something similar to this
in this case there just to test for this column package parents yeah hopefully eventually you have you would have the full test suite covering because all the code but protests like this we only covered the In the problem with this ground by default and ideally we would also test with other Python versions of you want to support more of them and hopefully and for something and these might want you you start
so toxic is it to but
let's the development test due to different multiple testing environments with a different set of problems dependencies that defensive versions and tests run tests in all of them and collect results and display the speed does actually much more than this column but for what we need this is enough because we can think of Python interpreter version as this is just another package so it can be easily covered talks so they must be installed talks by the idea that we've installed talks and we need to also configured and do this with the things that are know I need configuration file is a simple 1 parents it contains
2 sections so the first one on is so talks well with some parameter and this we specify which environments we want to use the budgets of constant predefined home environment for all bicycle interesting
Python of variance saying this case we use Python 2 . 7 3 . 5 and by because define our own but most of the time we probably need to do that so With this research set up that he was tested in with with 2 . 7 and 3 . 5 and 5 points and then we also need to speak define colonies tests should be set up and run so we do this 1st by the columns listing dependencies
which in our case just please stop by just column and then we also need to specify how to understand which in the event of his his his providers and users do everything which magic so as we've done
this and running with the toxic meant that is very very similar to this 1 so we can see that in all
these the the country on these 3 environments rank test them and d and reported success In all of them so we have something that works pretty well locally
on tests inaudible from multiple Python versions and but it wouldn't be nice if the same time you could run tests automatically every time you make a change if you would like to keep and
for me this is kind of similar or more or less the same thing as I'm making polymer commits push to get become this that I intend to keep and we can achieve
this week by using an external service called 7 on which is a continuous integration services that is known also as a
hosted service EI or that site that allows open source public from projects to use it for free and to to use it we 1st need to create an account which we do by loving it with our and you have credentials are certainly if you have encountered we don't need to authorize application so
so he has access to our a repository so can read them and once you've done that you will get the best all of our repositories all we need to switch on those that's defined that we want to use with the Travis and after that we only need to know what we need to
consider it with the service configuration file which is the younger competition find which refers specified for each language we want to use nowadays Python and then we need to specify what the interpreter uh versions that we will be using charges In this section is slightly more complicated because on we can test and ideally we should just which Travis with different Python versions but we also using stocks for the same thing locally on so the way to handle this is to instruct Travis of reach python interpreter introduced with the Python work itself for example 2 . 7 and the instructor talks reach testing environment introduced the same time between the 2 talks environment environment variable column where we use the name of
environment so after we've done this we need to start whatever is needed to test our package in
our simple case this is just assigned thoughts which means of by and the the rest and then we need to also run the command that we need to run tests which is just executing talks so after we've done this we will get a pretty similar
to this 1 this is 1 of my projects where we see the status of the tests that around every time we push another change to get and we also get this up on the top of the screen if you taken this
we can get all embedded things and there is a snippet that can use to include it into our readme file on pages we can also 2 other developers call in what state of package right now is so at this point we have
something that works pretty well
on its whole protested that to meditate etc. time which changes but doesn't have a documentation and other conditions it's probably not
really inviting to others to use because how would we mean without some kind of noise how to use software it's probably less appealing than other potential packages that might have more modification so so writing the condition is important also for other reasons because of the conditions we can also also think about how the coach should be used and how should you work and it wasn't tell what it actually does for between writing the condition user told things which is the same
1 that a Python project uses and publish it on with adults network which is not a free service for open source work on that you can use again we need to create an account problem and we need to
authorize the axis which we do once we log by clicking on the screen and you have and again the same screened
for authorization and
afterwards column once you authorized we come back to the screen we need to import project that from a list of projects usually it's used for some reason is that when the the company's patent for the very 1st time empty so if you need to receive in announcing but there and afterwards you just click on the process of sign of the project to that you would like to add to 2 condition for so question than this you know you information about the project itself usually the difference of the fine as they are and their picked up from the top name and repository you can change the setting succumb if you don't like them if you do please use use the format of the the condition to things which because this is the 1 we actually use and question on all of this you
get to a page this that's the sort of status page you all for your
project which doesn't what's the status of the the condition of generation is on you and then you get a badge that you can use and you also have to show your answer
to can use to point to your documentation questions about so this is the only part and now we have to also set up you can decide on the nobody
so 1st we need to discuss things with things autumn and so on and then we moved to the the the condition for the week created before and runs things are start which will ask us a few is the ultimate questions or if you don't know the defaults then find and this would generate a configuration of fire in which we
might want to check the those 2 expenses are turned on the 1st extension of what a doctor who is used to to generate recommendation from docstrings which can be really useful for generating API conditions and the other 1 DTAs thinks his for if you want to link to documentation provided packages so once you have all this and once you also wrote some documentation structured text you can create and local very copy it makes its tomorrow and
browsing afterward so you don't need to check in because adults we automatically form changes from the top and built its own version anyway so now we have a package probably pretty good
tests as documentation just hasn't been published and so on
what in the rate has been because it's possible to started from the of directly but it's not very few flexible so as not very manageable for users and it's possibly more difficult to find so we should publish it to quantify the i which is a pythons
one-stop-shop for Python packages and to do this we already have everything maybe we need so we need to register assessment to create an account which we can do either on that what we can do it once
the resistor package itself so to register package how we would
run this command so by the set of the 5 set of log
file for package and the register command and it lost for credentials to buy the iron or if you don't have them said this point we can also create an account and everything else about the package would be red from the onset of the body itself so we don't have to do anything that so once you've done this we just need to push the package itself and we did this with 1 another set of the find command in which case it's pretty source distribution and distribution and uploaded to Commons the by the i read you might also want to do some of the changes
so you create by the idea official file you can specify populations that it's probably not a good idea to put that's they're you only you can but if you use all the version of Python that's before Python 2 . 7 . 9 it's a good idea to put that repository of this type of a repository of line inside because it's forces set up the fight use secure connection to pipeline and not explicit credentials neural versions of Python kind this automatically by the law the versions you to it's good idea to have that in so at this point we've done everything on the of package
getting tested as documentation you know how to punishment its 0 by and since when all of this it would be kind of silly if we had to do this every time want to create a new package
and publishing package it's better to automated and we can do this readers to Collins cookie
cutter that was is created created by all we're doing itself common line tool on for creating scaffolding call for a project from the project templates and audio-only provided a
great template for Python packages of so 1st
meeting start cookie cutter then we need to be pointed to the occasional from the template file In this case it it means it's on behalf of all the 3 repository could counterpart package comes into weeks from there and then the last as a bunch of questions that we are and so on so that's it confusing missing or unknown parts and afterwards you have and the scaffolding right from the whole package ready to go so we can just as the total and that the content at is needed so death and that's it we didn't have time to cover some reading we cannot go into depth about tools it are mentioned iron strongly urge you to
look at the documentation days every powerful and you can do much more sentences for each 1 of them so you for some reason you don't like like some of them you can easily replace them with a different to on the whole this works pretty well from you who knows you to thank you
few the the people of the K. thank you mark any questions the back this is the way that we the force but hello I wanted to ask you if it's possible to do the books configuration without using by just like using another does run like fold general test cases or share so
of so right here so I used by test but in principle we don't think you would need to change for everything to work is so In the top theory so use whatever the that's funny and has this framework on you want but then if if you wanted to keep everything as the same you just need to take the torques configuration scores by test and then run by just you need to change it to install your foot framework shouldn't installed it's not a unit and then you would need to change that the institutional part so that's instead of buying by test is wrong this 1 are you using and everything else was pretty much the same way all I think a lot of problems all good thank you thank you for question they
more questions the hello thank you for the so do you think the perp approach it should have some kernel for all medical quot control such as flight 8 from my avoid such so book yes they do so this talk
region you would also have a section on coverage which is not I think so on but to pointing to that direction so do you would try to automate everything you can so on the problem with running things manually is that you it's easy to forget and anything that can be automated is ideally should be automated so on there are a bunch of to solve their use free-to-use for open source on that you can use to integrate these things and this into your and join me
once again giving Marco big thanks
Loading...
Feedback

Timings

  690 ms - page object

Version

AV-Portal 3.9.2 (c7d7a940c57b22d0bc6d7f70d6f13fde2ef2d4b8)