Python package management tool quick start

Foreword

There are already many mature packages in the Python environment, and we can extend our program by installing these packages.

For example, many times Python developers go to the PyPI website to find the package they want to use and then install it. PyPI (Python Package Index) is a site that gets third-party Python packages to complement the standard library.

In the process of installing Python packages, distutils, setuptools, distribute, setup.py, easy_install, easy_install, and pip are often involved.

Suddenly, the package management of Python is messy. What are the relationship between these tools, and how should I choose to use them?

Here is a brief introduction to some of the Python package management related content.

Python package management tool

With so many Python package management tools, I just don't know how to choose when I first get into Python. In fact, after checking the official documentation of Python, I slowly clarified the relationship between these tools, and there is no such confusion.

The following is a brief introduction to the package management tools in Python.

Distutils

Distutils is part of the python standard library, which is designed to provide developers with a convenient way to package and provide a convenient installation for the user.

The setup.py we use often is based on distutils and can be packaged or installed via setup.py.

Looking at a simple example, look for a directory to create three files foo.py, bar.py, and setup.py, where setup.py reads as follows:

From distutils.core import setup setup( name='fooBar', version='1.0', author='Will', author_email='', url='http://', ​​py_modules=['foo', 'bar' ], )

Then, running python setup.py sdist in that directory will get the following output and a "fooBar-1.0.zip" package will be generated.

Python package management tool quick start

The user can unzip the package and execute python setup.py install to install it, then use the two modules foo and bar:

Python package management tool quick start

For more information on how to write setup.py, please refer to the setupscript section of the official Python documentation.

Setuptools and distribute

Setuptools is an enhancement to distutils, especially the introduction of package dependency management. We can install setuptools via ez_setup.py.

As for distribute, it is a branch version of setuptools. The reason for the branch is that some developers think that setuptools development is too slow. But now, the distribution is merged back into setuptools, so you can think of them as the same thing.

I saw that setup.py can create a tarball, and setuptools uses a new file format (.egg) to create an egg file for a Python package. Setuptools recognizes .egg files and parses and installs it

Easy_install

After installing setuptools/distribute, we can use the easy_install tool directly:

1. Install a package from PyPI: When using the easy_install package command, easy_install can automatically download the relevant package from PyPI and complete the installation and upgrade.

2. Download a package installation: You can install an already downloaded package via the easy_install package.tgz command.

3. Install the egg file: install an egg format file with easy_install package.egg

The help prompt related to this command can be obtained by the easy_install --help command:

Python package management tool quick start

Based on the above analysis, you can see the relationship between setuptools/distribute and easy_install:

*setuptools/distribute extends distutils to provide more functionality

*easy_install is a tool based on setuptools/distribute that facilitates package installation and provincial level

Pip

Pip is currently the most popular Python package management tool, and it is used as a replacement for easy_install, but there are still a lot of features built on top of setuptools.

There are a lot of deficiencies in easy_install: the installation transaction is a non-atomic operation, only svn is supported, no uninstall command is provided, and a script is required to install a series of packages. Pip solves the above problems and has become a new de facto standard.

The use of pip is very simple and supports installing Python packages from any address that can be accessed via VCS or a browser:

*Installation: pip install SomePackage

*Uninstall: pip uninstall SomePackage

The following part of the article focuses on the contents of pip.

Use pip

In everyone's use of Python, it is recommended to use pip for Python package management, pip installation and use are more convenient.

Pip installation

There are two common ways to install pip:

1. Download the get-pip.py file and execute python get-pip.py to install it (if you don't have setuptools installed, get-pip.py will help with the installation)

2. Now pip source package, then install through setup.py

Pip common command

For pip, the most common one is definitely pip --help. With the help documentation, you can probably know how to use commands and parameters.

Pip common command set:

to sum up

This article describes the relationship between the various package management tools of Python. I believe that through the introduction of this article, the distutils, setuptools, distribute, setup.py, easy_install, easy_install, and pip will no longer be confused.

With a general understanding of these Python package management tools, you should be aware of how to choose and use them.

This article does not cover how to make and publish a Python package. Interested students can check the Python official website.

Bluetooth Speaker

Bluetooth speaker:

Bluetooth speaker is a kind of speaker unit which is used for multimedia devices. They have loud sound, wide frequency response range and rich bass.

Our main Multimedia Speakers are full ranges speakers units:

1) From the diameter: we have speakers in 1" ~ 3".

2) From the power output, we have speakers of 2W ~ 15W.


multimedia speaker


multimedia speaker


FAQ

Q1. What is the MOQ?
XDEC: 2000pcs for one model.
Q2. What is the delivery lead time?
XDEC: 20 days for normal orders, 15 days for urgent orders.
Q3. What are the payment methods?
XDEC: T/T, PayPal, Western Union, Money Gram.
Q4. Can you offer samples for testing?
XDEC: Yes, we offer free samples.
Q5. How soon can you send samples?
XDEC: We can send samples in 3-5 days.

Portable Bluetooth Speaker,Mini Bluetooth Speaker,Waterproof Bluetooth Speaker,Lamp Bluetooth Speaker

Shenzhen Xuanda Electronics Co., Ltd. , https://www.xdecspeaker.com