Manage Python packages with easy_install

    The easy_install tool is a module of a set of extensions to distutils of the Python language - setuptools. According to the official documentation, “Easy Install is a Python module (easy_install) that comes with the setuptools library, which allows you to automatically download, compile, install, and manage Python packages.” The packages are called "eggs" and have the extension .egg. Typically, these packages are distributed in a ZIP archive format.

    Using easy_install

    First, install the setuptools package for Python version 2.7: Now you can install any package located in the central Python module repository called PyPI (Python Package Index): . Working with easy_install resembles working with the package managers apt-get, rpm, yum and the like. For example, install a package containing the IPython shell: Either the name of the package or the path to the .egg package located on disk is specified as an argument. Please note that installation requires superuser privileges, since easy_install is installed and installs packages into the site-packages global directory for Python. Installing easy_install in your home directory is as follows: Search for a package on a web page:
    $ wget
    $ sudo sh setuptools-0.6c11-py2.7.egg

    sudo easy_install ipython
    sh setuptools-0.6c11-py2.7.egg --prefix=~

    easy_install -f liten
    The first argument in this example is which page to look for, the second - what to look for.
    The possibility of HTTP Basic authentication on sites is also provided:
    easy_install -f

    Installing the archive with source codes at the specified URL:
    As an argument, just pass the address of the archive, and easy_install will automatically recognize the archive and install the distribution. For this method to work, the file must be in the root directory of the archive.

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

    Also, easy_install can make installation of the unpacked distribution package with source codes a little easier. Instead of a sequence of commands python install, just enter easy_installin the directory with the sources.

    Changing the active version of an installed package:
    easy_install liten=0.1.3
    In this case, the liten package is rolled back to version 0.1.3.

    Convert a single .py file to a .egg package

    easy_install -f "" 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 variable PYTHONPATH. In this example #egg=foo-1.0, this is the version of the package, and foois its name.

    Using configuration files

    Experienced users and administrators can create configuration files. Default parameter values ​​can be set in the configuration file, which has the ini-file format. easy_install searches the configuration file in the following order: current_directory / setup.cfg , ~ / .pydistutils.cfg and in the distutils.cfg file , in the distutils package directory.
    An example of such a file: Sources used: - official documentation "Python in UNIX and Linux system administration", Noah Gift and Jeremy M. Jones

    # где искать пакеты
    find_links =

    # ограничить поиск по доменам
    allow_hosts = *

    # куда устанавливать пакеты (каталог должен находиться в переменной окружения PYTHONPATH)
    install_dir = /src/lib/python

    Also popular now: