HTML Diff
1 added 0 removed
Original 2026-01-01
Modified 2026-02-21
1 <p>You already know that package<strong>managers</strong>are often used to install, upgrade, and uninstall packages. We'll look at one such manager in this lesson, but first, let's talk a bit about the basics of Python's packaging system.</p>
1 <p>You already know that package<strong>managers</strong>are often used to install, upgrade, and uninstall packages. We'll look at one such manager in this lesson, but first, let's talk a bit about the basics of Python's packaging system.</p>
 
2 + <h2>Distutils and Setuptools Packages</h2>
2 <p>Python ships with the<strong>distutils</strong>package. It's responsible for creating<strong>distributions</strong>- code archives that people can unpack in the target environment and install so that the Python interpreter sees the unpacked code. When creating a package, the programmer goes to the root directory of the future package and creates a file called setup.py, in which he imports the setup function from the `distutils' module and calls it. So every package contains a program to check itself.</p>
3 <p>Python ships with the<strong>distutils</strong>package. It's responsible for creating<strong>distributions</strong>- code archives that people can unpack in the target environment and install so that the Python interpreter sees the unpacked code. When creating a package, the programmer goes to the root directory of the future package and creates a file called setup.py, in which he imports the setup function from the `distutils' module and calls it. So every package contains a program to check itself.</p>
3 <p>You can read more about how distutils works in<a>the package's official documentation</a>, but let's move on for now.</p>
4 <p>You can read more about how distutils works in<a>the package's official documentation</a>, but let's move on for now.</p>
4 <p>The distutils package has been around for quite some time and is no longer needed. Programmers use the<strong>Setuptools</strong>much more widely.</p>
5 <p>The distutils package has been around for quite some time and is no longer needed. Programmers use the<strong>Setuptools</strong>much more widely.</p>
5 <p>Packages built with Setuptools can provide metadata: description, version, and dependencies. It's hard to do without Setuptools, so it's worth learning how to use it. You can do this using the [documentation] (<a>https://setuptools.readthedocs.io</a>).</p>
6 <p>Packages built with Setuptools can provide metadata: description, version, and dependencies. It's hard to do without Setuptools, so it's worth learning how to use it. You can do this using the [documentation] (<a>https://setuptools.readthedocs.io</a>).</p>
6 <p>Later in this course, we'll look at<strong>Poetry</strong>- a lighter tool helping to create packages and upload them to the index.</p>
7 <p>Later in this course, we'll look at<strong>Poetry</strong>- a lighter tool helping to create packages and upload them to the index.</p>
7 <p>Once the package has been created and uploaded to the index, you can use it:</p>
8 <p>Once the package has been created and uploaded to the index, you can use it:</p>
8 <ul><li>Download it</li>
9 <ul><li>Download it</li>
9 <li>Unzip it to a temporary directory</li>
10 <li>Unzip it to a temporary directory</li>
10 <li>Run python3 setup.py install, and install the package that way</li>
11 <li>Run python3 setup.py install, and install the package that way</li>
11 </ul><p>But there is an easier way.</p>
12 </ul><p>But there is an easier way.</p>
12 <h2>The Python package installer</h2>
13 <h2>The Python package installer</h2>
13 <p>When we build the package and upload it to the index, we need to download and install it with all its dependencies. We can do it using a program called<strong>pip</strong>- the Python package installer.</p>
14 <p>When we build the package and upload it to the index, we need to download and install it with all its dependencies. We can do it using a program called<strong>pip</strong>- the Python package installer.</p>
14 <p>You can read about all the features of pip in the [documentation] (<a>https://pip.pypa.io</a>). We'll look at the most essential function of pip: installing packages. In the next lesson, we'll install pip to install the first package in the environment.</p>
15 <p>You can read about all the features of pip in the [documentation] (<a>https://pip.pypa.io</a>). We'll look at the most essential function of pip: installing packages. In the next lesson, we'll install pip to install the first package in the environment.</p>