Publishing well-formed Python packages
|Countdown link||Open timer|
Most of us have written python programs. Many have written modules. Some have packaged and uploaded them to servers for distribution. And a significant portion of these packages could be made better.
I propose a talk expressing the need for these tools and the advantage of using them with a toy python program for Nim.
Most of the well established projects follow some practices and has some mechanism in place to ensure better maintainability.
But we can find a good number of packages online which are being developed without an equivalent mechanism.
In this talk, I will mention some tools, which when used, can lay the foundation for a well formed package.<h4>Well-formed package</h4>
A package whose source has some structure which makes testing and development more efficient and less error-prone.
Such a package also makes working with its source a more pleasant experience.
A well-formed package makes things easier for both the developer and the user.
But it is easier to get started with a structure than to maintain that form. Which calls for a mechanism to maintain that structure.<h4>How</h4>
The source code should adopt a style and stick with it. A linting tool like pylint can help with it. Or you could use black.
Use type annotations along with tools like mypy.
Eliminate unused code with
Add tests to be sure that the different functionalities work as intended using tools like pytest or the built-in unittest. This will be extremely useful to be sure that further modifications do not break existing code.
Ensure proper test coverage with coverage.py After all, adding tests isn't everything. One got to make sure it reaches every nook and corner.
Automate tests with tox, nox, etc.
Package the project in tune with the future of packaging. setuptools, flit or poetry
And add some CI/CD.
Other tools like pre-commit, bumpversion, etc may also be used.<h4>Intended audience</h4>
People who create and publish python packages. The presentation is from the package developer's perspective and not exactly about the innards of the different python packaging tools.<h4>Pre-requisites</h4>
Basic Python programming. Git
Tentative talk outline
- Type checking
- Eliminating dead code
- Test coverage
- Test automation
- Other tools
- Future of packaging
Using Python for 5 years. Interested in text processing.
Published a few packages to PyPI using different packaging tools.
The proposed talk is derived from experience of creating them.
Working with Python for around 5 years.
Likes text processing.