Using a package manager – pip and conda

All the packages we've introduced so far are publicly accessible for everyone via one of two package managers—pip and conda. The role of the package manager is to provide a unified interface to securely install, upgrade, and uninstall packages in a system. As most packages depend on other packages (usually specific versions), it is also the job of the package manager to resolve those dependencies—that is, to install packages that fit the version criteria for all installed packages that will depend on them. 

pip and conda are by far the two most popular package managers for Python. The first one is officially supported by the Python Software Foundation. It is the main Python package management, period.

Why do we use conda at all, then? Historically, pip and PyPI (a corresponding online service) did not support binaries as part of packages. Binaries have to be compiled for each OS separately, and they are (obviously) written in languages other than Python itself. Thus, providing support for binaries was considered too demanding. 

It turned out, however, that this is exactly what is required for fast numeric operations—as we've mentioned before, numpy, pandas, and sklearn all run C and even Fortran under the hood. For a long time, the lack of support meant that everyone had to compile binaries locally every time they installed those new packages. As such, the Python leadership offered to build a package manager that would support binaries—and conda was born. As an additional bonus, conda can also create separate virtual environments, so you can safely replicate a full Python environment from a shared .yaml file or have multiple versions of Python and packages at the same time.

Unfortunately, conda requires a bit more effort to work with, compared to pip. Most critically for us, it does not support the installation of packages from a Git repository (even a private one), while pip does. Another feature of pip is that it allows the installation of packages in editable mode—that is, with the code stored on a non-system path and ready to be edited. In this chapter, we will build a package targeted at pip.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset