What is construction and installation?

This is probably a question that has a very simple and clear answer, however, despite several years of programming, for some reason I still do not quite understand what it means to "build" and then install. "I know, how to use them and used them a lot, but I have no idea about the exact processes that occur in the background ...

I looked through the Internet, Wikipedia, etc., but there is no simple answer to it, and I can not find it here.

A good example I was trying to figure out is adding new modules in python: http://docs.python.org/2/install/index.html#how-installation-works

It states that "the build team is responsible for installing files in the build directory

And then for the installation command: "After running the build command (regardless of whether you execute it explicitly or the install command does it for you), the installation command works relatively simple: all it needs to do is copy everything to build / lib (or build / lib.plat) to your installation folder.

So, essentially, it says: 1. Copy everything to the assembly directory, and then ... 2. Copy everything to the installation directory

There must be some process missing in the explanation ... complilation?

I would understand some simple, not too technical answer, but as detailed as possible :)

I hope I'm not the only one who does not know the detailed answer to this question ...

Thanks!

Aivoric

+6
source share
3 answers

Building means compiling the source code into a binary file in an isolated environment, where it will not affect your system if something goes wrong, like the build subdirectory inside the source code directory.

Installation means copying embedded binaries from the build subdirectory to a location in your system path where they become easily accessible. This is rarely done with the direct copy command, and it is often done with some kind of package manager that can track created files and easily delete them later.

Usually, the build team does all the necessary compilation and bindings, but Python is an interpreted language, so if there are only pure Python files in the library, there is no compilation step in the assembly. Indeed, everything is copied to the assembly directory, and then copied again to the final location. Only if the library depends on code written in other languages ​​that need to be compiled will you have a compilation stage.

+6
source

You need a new chair for your living room, and you want to do it yourself. You browse the catalog and order a bunch of parts. When they arrive at your door, you cannot immediately use them. You must build a chair in your workshop. After a little elbow-fat, you can sit in it. After that, you will install a chair in your living room, in a convenient place to sit.

The chair is the program you want to use. It comes to your home as source code. You create it by compiling it into an executable program. You install it, simplifying its use.

+5
source

The build and install commands that you reference come from the setup.py file correctly?

Setup.py ( http://docs.python.org/2/distutils/setupscript.html )

This file is created by third-party Python applications / extensions. They are not part of:

  • Python source code (a bunch of c files, etc.)
  • Python libraries shipped with Python

When a developer creates a library for python that he wants to share with the world, he creates a setup.py file so that the library can be installed on any python machine. Maybe it's MISSING STEP

Setup.py sdist

This creates a python module (tar.gz files). This makes copying all files used by the python library to a folder. Creates a setup.py file for the module and archives everything so that the library can be built somewhere else.

Setup.py build

This returns the python module back to the library (ESPECIALLY FOR THIS OS).

As you know, the computer from which the python library originally belonged will be different from the library you are installing on.

  • It may have a different version of python
  • It may have a different operating system.
  • It may have a different processor / motherboard / etc

For all the reasons listed above, the code will not work on another computer. Thus, setup.py sdist creates a module with only the source files needed to rebuild the library on another computer.

What setup.py does is exactly what the make file will do. It compiles sources / creates all libraries.

Now we have a copy of all the files that we need in the library, and they will work on our computer / operating system.

Install Setup.py

We have all the necessary files. But they will not work. What for? Well, they should be added to Python, why. Here is the installation. Now that we have a local copy of the library, we need to install it in python so that you can use it like this:

 import mycustomlibrary 

To do this, we need to do several things, including:

  • Copy files to your library folders in our python version.
  • Verify that the library can be imported using the import command
  • Run any special installation instructions for this library. (setting paths, etc.)

This is the hardest part of the task. What if our library uses BeautifulSoup? This is not part of the Python library. We must install it so that our library and other users can use BeautifulSoup without interfering with each other.

So what if python was installed somewhere else? What if it was installed on a server with many users?

Set all these problems transparently. What it does is to make the library that we just created capable of working. All you have to do is use the import command, install all the others.

+1
source

Source: https://habr.com/ru/post/957283/


All Articles