Thursday, July 4, 2019

Test and Code: 80: From Python script to Maintainable Package

This episode is a story about packaging, and flit, tox, pytest, and coverage.
And an alternate solution to "using the src".

Python makes it easy to build simple tools for all kinds of tasks.
And it's great to be able to share small projects with others on your team, in your company, or with the world.

When you want to take a script from "just a script" to maintainable package, there are a few steps, but none of it's hard.

Also, the structure of the code layout changes to help with the growth and support.

Instead of just talking about this from memory, I thought it'd be fun to create a new project and walk through the steps, and report back in a kind of time lapse episode. It should be fun.

Here are the steps we walk through:

  • 0.1 Initial script and tests
  • 0.2 build wheel with flit
  • 0.3 build and test with tox
  • 0.4 move source module into a package directory
  • 0.5 move tests into tests directory

Sponsored By:

Support Test & Code - Python Testing & Development

Links:

<p>This episode is a story about packaging, and flit, tox, pytest, and coverage.<br> And an alternate solution to &quot;using the src&quot;.</p> <p>Python makes it easy to build simple tools for all kinds of tasks.<br> And it&#39;s great to be able to share small projects with others on your team, in your company, or with the world.</p> <p>When you want to take a script from &quot;just a script&quot; to maintainable package, there are a few steps, but none of it&#39;s hard.</p> <p>Also, the structure of the code layout changes to help with the growth and support.</p> <p>Instead of just talking about this from memory, I thought it&#39;d be fun to create a new project and walk through the steps, and report back in a kind of time lapse episode. It should be fun.</p> <p>Here are the steps we walk through:</p> <ul> <li>0.1 Initial script and tests</li> <li>0.2 build wheel with flit</li> <li>0.3 build and test with tox</li> <li>0.4 move source module into a package directory</li> <li>0.5 move tests into tests directory</li> </ul><p>Sponsored By:</p><ul><li><a href="https://ift.tt/2ISBu1u" rel="nofollow">Pantheon</a>: <a href="https://ift.tt/2ISBu1u" rel="nofollow">Pantheon makes building, managing, and optimizing websites simpler. Get started for free at pantheon.io/testandcode.</a></li></ul><p><a href="https://ift.tt/2tzXV5e" rel="payment">Support Test & Code - Python Testing & Development</a></p><p>Links:</p><ul><li><a href="https://ift.tt/2KWF7FQ" title="submark repo: A Subset of Markdown" rel="nofollow">submark repo: A Subset of Markdown</a></li><li><a href="https://ift.tt/2wlJRx1" title="Flit documentation" rel="nofollow">Flit documentation</a></li><li><a href="https://ift.tt/2KZfqEK" title="Coverage.py documentation" rel="nofollow">Coverage.py documentation</a></li><li><a href="https://ift.tt/1TCkOsM" title="tox documentation" rel="nofollow">tox documentation</a></li></ul>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...