📜 ⬆️ ⬇️

Manage Python packages with easy_install

The easy_install tool is a setuptools distutils extension kit module. According to official documentation, “Easy Install is a Python module (easy_install) that comes with the setuptools library, which allows you to automatically download, build, install, and manage Python packages.” Packages are called "eggs" and have the extension. Egg. As a rule, these packages are distributed in ZIP archive format.

Using easy_install


First, install the setuptools package for Python version 2.7:
$ wget pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
$ sudo sh setuptools-0.6c11-py2.7.egg


Now you can install any package located in the central repository of Python modules called PyPI (Python Package Index): pypi.python.org/pypi . Working with easy_install is reminiscent of working with package managers apt-get, rpm, yum and the like. For example, install the package containing the IPython shell:
sudo easy_install ipython
The argument is either the package name or the path to the .egg package located on the disk. Please note that the installation rights require superuser rights, since easy_install is installed and installs the packages in the global Python site-packages directory. Installing easy_install to your home directory is as follows: sh setuptools-0.6c11-py2.7.egg --prefix=~

Search for a package on a webpage:
easy_install -f code.google.com/p/liten liten
The first argument in this example is on which page to search, the second is what to look for.
The possibility of HTTP Basic authentication on sites is also provided:
easy_install -f user:password@example.com/path/

Installing an archive with source codes at the specified URL:
easy_install liten.googlecode.com/files/liten-0.1.5.tar.gz
As an argument, it is enough to pass the address of the archive, and easy_install automatically recognizes the archive and installs the distribution kit. In order for this method to work, the setup.py file must be in the root directory of the archive.

To upgrade the package, use the --upgrade key:
easy_install --upgrade PyProtocols

Also easy_install can slightly ease the installation of an unpacked distribution with source codes. Instead of the python setup.py install command sequence, just type easy_install , being in the source directory.
')
Change the active version of the installed package:
easy_install liten=0.1.3
In this case, the liten package is rolled back to version 0.1.3.

Convert a separate .py file to an .egg package

easy_install -f "http://some.example.com/downloads/foo.py#egg=foo-1.0" foo
This is useful when, for example, you need to provide access to a single file from anywhere in the file system. Alternatively, you can add the file path to the PYTHONPATH variable. In this example, #egg=foo-1.0 is the version of the package, and foo is its name.

Using configuration files

For experienced users and administrators, the ability to create configuration files is provided. The default parameter values ​​can be specified in the configuration file, which has an ini-file format. easy_install searches for the configuration file in the following order: current_dir / setup.cfg , ~ / .pydistutils.cfg and in the distutils.cfg file, in the distutils package directory.
An example of such a file:
[easy_install]

#
find_links = code.example.com/downloads

#
allow_hosts = *.example.com

# ( PYTHONPATH)
install_dir = /src/lib/python

Sources used:
peak.telecommunity.com/DevCenter/EasyInstall - official documentation
“Python in UNIX and Linux system administration”, by Noah Gift and Jeremy M. Jones

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


All Articles