Introduction to python packaging with `pipy`
Information
The estimated time to complete this training module is 4h.
The prerequisites to take this module are:
Contact Pierre Bellec if you have questions on this module, or if you want to check that you completed successfully all the exercises.
Resources
This module was presented by ValΓ©rie Hayot-Sasson during BrainHack School 2020. The slides are available here.
The video of the presentation is available below (57:51):
Exercice
- To run this exercise, you will need a small python module. You can create a toy python module by following this tutorial. It would be better to start creating one (or a couple of) module(s) for your project, so you work directly with a meaningful code base.
- Add your module to a new git repository under your personal account. This is not necessary, but putting code on git control should be second nature at this stage :) Note that the module will read in a folder inside the repository. The top level directory is for configuration files for the project, not the code itself.
- Create and populate a
README.md
file - Create and populate a
license.txt
file - Fill a
requirements.txt
file. Include everything needed for development, including e.g.jupyter-notebook
andpytest
. - Fill a
pyproject.toml
file. Start from a template. These two last steps are much more meaningful if you are working with a code base for your project, rather than a toy module with no depencies. - Configure the meta-data of your project with
setup.cfg
. Check the documentation of pypi for more info. - Add on
__init.py__
in your module folder. See this example - Try installing your package locally by running
pip install -e .
in your repository. - Optional: You can try to create the distribution files and publish this package on a test server of
pypi
. This step is described in this tutorial. The pypi test server is made to test how publishing a package works - so don't worry if this is just a test or if you make mistakes, the server exists for that purpose. If you upload the package on pipy itself, anybody will be able to install your software by typingpip install <my_package>
but beware!pipy
is a community resource, and you should only publish serious, well tested projects on there. - Follow up with Pierre Bellec to validate you completed the exercise correctly.
- π π π you completed this training module! π π π
More resources
- The official
pipy
packaging documentation. - The guidelines for modern packaging by Chris Markiewicz.