31

What is the purpose of setuptools in Python? What if I do not have setuptools or never upgrade setuptools?

I read the documentation, but I cannot get the answer.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
  • 3
    https://setuptools.readthedocs.io/en/latest/setuptools.html – Harsha Biyani Dec 19 '16 at 06:30
  • 9
    Generally they are useful to create confusion between them, easy_install, distutils, distutils2, pip, wheels and some others I'm now forgetting. Sometimes they also generate some fun compiler errors to keep you entertained, although the best is when they add stuff to pth files and screw search paths behind your back. – Matteo Italia Dec 19 '16 at 06:53

2 Answers2

39

setuptools is a package used by many other packages to handle their installation from source code (and tasks related to it).

It is generally used extensively for non-pure-Python packages, which need some compilation/installation step before being usable (think packages containing extensions written in C); setuptools factors away some of the most common operations used in this process (compiling C files with options compatible with the current Python installation, running Cython if required, provide some vaguely coherent set of commands/options for setup.py files, ...) as well as providing some tools used during Python packages development.

There is some kind of overlap with distutils, distutils2 (?) and some of the other packages setup tools that I never actually managed to understand; honestly, it's a part of the Python ecosystem that is quite a big mess.

The point is, if you:

  • don't develop Python packages;
  • install only binary or pure Python packages;
  • install packages only through high level installers (pip, easy_install, your distribution's package manager) and you are really lucky

you generally don't need to worry about setuptools - either it isn't really needed, or the high-level installers will make sure you have a recent enough version installed; in this last case, as long as the operations they have to do are simple enough generally they won't fail.

Otherwise, unfortunately you are going to spend some fun hours trying to understand who on earth between setup.py and the compiler is adding command line switches that make the compilation fail, or screw up the include paths, or expect libraries to be in a different path, or misdetect the compiler, or try to install stuff into the wrong paths or any combination of the above.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
0

Setuptools is a package development process library designed to facilitate packaging Python projects by enhancing the Python standard library distutils (distribution utilities).

Wikipedia

Essentially, if you are working with creating and distributing Python packages, it is very helpful.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2ps
  • 15,099
  • 2
  • 27
  • 47