Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of Python setuptools?

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.

like image 203
guagay_wk Avatar asked Dec 19 '16 06:12

guagay_wk


People also ask

What is setuptools Python used for?

Setuptools is a package development process library designed to facilitate packaging Python projects by enhancing the Python standard library distutils (distribution utilities). It includes: Python package and module definitions. Distribution package metadata.

Does Python include setuptools?

the setuptools is not part of the python vanilla codebase, hence not a vanilla modules. python.org installers or mac homebrew will install it for you, but if someone compile the python by himself or install it on some linux distribution he may not get it and will need to install it by himself.

What does Python setup py bdist_wheel do?

python setup.py bdist_wheel internally runs python setup.py install which in turn runs python setup.py build which compiles/builds the project into a temporary location inside build/ directory and then installs compiled project into another temporary location inside build/ directory.

How do I import setuptools in Python?

Follow the below steps to install the Setuptools package on Linux using the setup.py file: Step 1: Download the latest source package of Setuptools for Python3 from the website. Step 3: Go to the setuptools-60.5. 0 folder and enter the following command to install the package.

What is Setuptools in Python?

Setuptools is a package development process library designed to facilitate packaging Python projects by enhancing the Python standard library distutils (distribution utilities). Essentially, if you are working with creating and distributing Python packages, it is very helpful.

What is the difference between distutils and Setuptools in Python?

distutils is a very old packaging library provided since Python 2. It is included In the Python Standard Library under the Software Packaging and Distribution category. setuptools is a more recent module that provides package creation functionalities. However, it is not included in the Python Standard Library.

What is a setup py file used for?

Traditionally, the setup.py file was used in order to build packages, e.g. using the build command through the command line interface. In the example setup.py file demonstrated above, we’ve seen that most of the code is just about listing some options and metadata about the Python project.

Do I need to install Setuptools?

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.


1 Answers

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.

like image 195
Matteo Italia Avatar answered Sep 27 '22 19:09

Matteo Italia