Package creation documentation?

Thomas Jollans tjol at tjol.eu
Tue Oct 16 11:34:46 EDT 2018


On 2018-10-16 17:15, Spencer Graves wrote:
>       Where can I find a reasonable tutorial on how to create a Python
> package?
> 
> 
>       I've not created a Python package before, and I want to. Sadly,
> I'm having trouble finding reasonable documentation on how to do so.
> 
> 
>       According to the Python 3 Glossary, "a package is a Python module
> with an __path__ attribute."[1]

Never mind that. Pay attention to the next line:

    See also regular package and namespace package.

A regular package is just a directory with an __init__.py file in it
(and normally some submodules).

Generally you should only create a package if your codebase has multiple
somewhat independent but related bits, or is to large or complex to be
maintainable as a single module (.py file).

Now, if you want to package (verb) your module (noun) or package (noun)
into a package (different noun) that others can install, you want to
read the setuptools documentation.

https://setuptools.readthedocs.io/en/latest/

The overloading of the term "package" is a bit unfortunate, but most of
the time we don't notice since most packages contain packages, and most
packages come in packages. Some packages just contain modules, and some
packages are not packaged, though.

I would like to apologize for the previous paragraph.

-- Thomas



More information about the Python-list mailing list