Search code examples
pythonpipsetup.pypython-wheel

setup.py install_requires built-in package: include or omit?


I have a python package I made. It uses datetime in multiple places. I notice that on a brand-new python install, I can do import datetime without issue. Thus, python comes with datetime built-in.

If I put datetime in my setup.py as one of the items in install_requires, it appears to download the pypi package datetime, even though the builtin package is already available. In some cases, such as with multiprocessing, the pypi package might require extra things (in the case of the pypimultiprocessing, it requires gcc-c++ to be installed on my CentOS, while the builtin multiprocessing has no such requirements).

Questions:

  • Should I include builtin packages under install_requires if I use them?
  • Is there an easier way of seeing which packages are builtin and which aren't other than creating a new virtualenv and trying to import things?
  • Who owns the pypi versions of these builtin packages? Is it some random person, or are these vetted packages provided by the python core team? (I know arbitrary packages can be provided by random people, but I can't figure out if that's true for the builtin packages that are also available on pypi.)

Solution

  • it appears to download the pypi package datetime

    Not exactly. It downloads a package called DateTime with top-level name DateTime, not datetime.

    Should I include builtin packages under install_requires if I use them?

    No. install_requires is intended to list external, 3rd-party packages, not the builtin ones, not the standard ones.

    Is there an easier way of seeing which packages are builtin and which aren't?

    One is datetime, the other is DateTime.

    Who owns the pypi versions of these builtin packages?

    The page https://pypi.org/project/DateTime/ name the author: Zope Foundation and Contributors. And list the current maintainers. The homepage listed is https://github.com/zopefoundation/DateTime