- What is the difference between a Python library, package, and module?
- Library: A collection of code designed to solve a particular problem or perform a specific set of activities. A library is typically composed of one or more packages.
- Package:
A namespace that organizes one or more related modules to solve a specific problem. A package is essentially a directory containing an
__init__.pyfile and one or more module files. - Module: A single file that contains reusable Python code, such as functions or classes, which can be imported and used in other programs. May have multiple functions.
- What is the anathomy of Python packages and
pyproject.toml
project
|__ pyproject.toml
|__ package1
|__ __init__.py
|__ module.pysetuptools: make the dist fileswheel: make the dist filesbuild: build the ditribute binary files (.whland.tz)twine: publish to Pypi global repository
I had to replace the construction of the library using setup.py file to pyproject.toml and learn how to use the __init__.py file to index the imports of the packages.
Use the test environment in Pypi to publish my first package (if I make a mistake there is no problem in this environment)
️ Some tips before publish the package
- Make sure your package code is clean and maintainable.
- Extend the documentation in order to make the package easier to use.
- Choose an appropiate software licence before publish the package.
- Make managing package updates easy.
- Setup the
pyproject.tomlwith the needed configuration to publish in Pypi. For setting up the project we can follow the instruction in this oficial website python setting up pyproject.
- We shall choose a build back end to make the build. The most common options are
hatchlingorsetuptools, for this case we use the setuptools option