4

In the Python ecosystem, there are two related but distinct concepts called "package":

  1. A "dotted module name", represented in its source as a directory with an __init__ module (i.e. an __init__.py file) (+ usually more modules/*.py files and sometimes nested packages) in it
  2. A software unit distributed via PyPI - the Python Package Index and installable with pip

In most conversations, it's clear from the context what kind of package one refers to when just saying "package" or "python package". In some other conversations, the distinction doesn't even matter.

But sometimes the distinctions wouldn't be clear but does matter:

"The [type 2] package Jinja2 is written with a capital 'J', but the [type 1] package jinja2 it provides is written all-lower-case. With SciPy and NumPy however, while the project names are written in camel-case, both the [type 2] packages and the [type 1] packages are written all-lower-case and numpy is usually imported as just np."

In these situations, I've begun to call the second type "PyPI package" (pronounced [ˈpaɪpiaɪ pækɪdʒ] to distinguish it from "PyPy" ([ˈpaɪpaɪ])). However, I'm unsure how to call packages of the first type.

Is there some established convention on how to call each package type when they must be distinguished?

1

There are packages (your type 1), and packages with added files (setup.py) in order to distribute through PyPI (your type 2).

Both are packages and should follow the naming convention for packages, meaning lower-case for the package name.

About the Jinja2 example: the file name on PyPI for Jinja2 starts with a capital: "Jinja2-2.8.tar.gz". But after downloading and extracting the file, there is a subfolder named "jinja2", and this folder has a init file, so it is to be considered the real pacakage, and it is written in lowercase.

So there appears to be no naming convention for compressed files and project names, it can be what you want it to be. Only package names follow the lowercase convention.

But to answer the question: i'm not aware of any difference in name for the type 1 and type 2.

Type 1 refers to a Python package, while type 2 is a (compressed) folder that contains a Python package.

  • It doesn't seem to be just the "file name on PyPI". It's also how to generally refer to the package when requesting it from PyPI, e.g. by installing it with pip. I've edited the question to reflect that. Though, it might be that my claim that the concepts are distinct is not as well-founded as I thought it was. – das-g Jul 10 '16 at 21:20
  • i use pip install followed by a lower case name, so i never noticed that it might also work with a capital. Well, then i learned something... . – Rolf Schorpion Jul 10 '16 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.