0. Origins
"Learn Python the hard" Exercise 46 requires four Python package pip, distribute, Nose, Virtualenv, (original book author Special reminder: do not just D Onwload these packages and install them by hand. Instead See how other people recommend you install these packages and use them for your particular system.) to complete the exercise.
0.1 Learning Goals
Study This example: 1) figure out what needs to be done in the book, 2) What should be done with the tool now.
1. What do these packages do?
This practice installs the package, builds a virtual environment for a project, and tests the project you built.
For the installation package (installing packages), you need to install PIP, setuptools (distribute upgrade replacement), and optionally (optionally) build a virtual environment virtualenv. See Glossary for terminology interpretation.
Watch out for the Python Packaging Authority (PYPA) and Python package Index (PyPI) in the terminology explained. The latter can find all of Python's packages and, of course, a detailed description of the 5 packages in the exercise.
What is 1.1 pip1.1.1?
1) Pip: The official recommended tools for installing Python packages (the Pypa recommended tool for installing Python packages.).
2) PIP supports version control (supports installing from PyPI, version control, local projects, and directly from distribution files).
3) Pip is something that installs the Python package on the computer (is a thing, installs packages, Pip itself is a, the someone might want to install, Especially if they ' re looking to run this get-pip.py script. PIP).
1.1.2 Installation Method
1) Download Get-pip.py,python get-pip.py
2) In contrast to sudo apt-get install Python-pip (Ubuntu) or sudo yum install Python-pip (fefora)
What is 1.2 setuptools1.2.1?
Setuptools allows packages to be downloaded, compiled (? ), install, upgrade, uninstall becomes easy (easily download, build, install, upgrade, and uninstall Python packages).
When installing PIP, if Setuptools is not installed, it will be installed automatically .
1.3 virtualenv
Virtualenv supports the installation of Python packages in a local environment without affecting the global environment.
Python "Virtual environments" Allow Python packages -to-be-installed in an isolated location for a particular APPL Ication, rather than being installed globally.
1.4. Nose
Nose Extended unit testing to simplify testing (extends the test loading and running features of unittest, making it easier to write, find and RU N Tests.).
So the thing that this exercise wants us to do is:
1) Install Pip (also automatically install setuptools);
2) Install virtualenv (the directory for project is not set as a virtual directory.) The virtual directory is not used in this example);
3) Install and test project with nose.
2. Exercise 2.1 Installation
1$sudoPython get-pip.py2[sudo] Password forFred:3The directory'/home/fred/.cache/pip/log'or its parent directory was not owned by the current user and the debug log have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.4The directory'/home/fred/.cache/pip/http'or its parent directory was not owned by the current user and the cache have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.5The directory'/home/fred/.cache/pip/http'or its parent directory was not owned by the current user and the cache have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.6 collecting Pip7Downloading pip-6.0.7-PY2.PY3-NONE-ANY.WHL (1. 3MB)8 -% |################################|1.3MB 31kb/s9[?25hCollecting SetuptoolsTenDownloading setuptools-12.0.5-py2.py3-none-ANY.WHL (502kB) One -% |################################| 503kB 27kb/s A[?25hInstalling collected Packages:setuptools, Pip - - theSuccessfully installed pip-6.0.7setuptools-12.0.5
Shell installs Pip and automatically installs Setuptools
1~$sudoPipInstallvirtualenv2[sudo] Password forFred:3The directory'/home/fred/.cache/pip/log'or its parent directory was not owned by the current user and the debug log have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.4The directory'/home/fred/.cache/pip/http'or its parent directory was not owned by the current user and the cache have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.5The directory'/home/fred/.cache/pip/http'or its parent directory was not owned by the current user and the cache have been disabled. Please check the permissions and owner for that directory. If executing PIP withsudo, may want the-H flag.6 collecting Virtualenv7Downloading virtualenv-12.0.6.Tar. GZ (1. 8MB)8 -% |################################|1.8MB 55kb/s9[?25hInstalling collected Packages:virtualenvTenRunning setup.pyInstall forvirtualenv OneInstalling Virtualenv Script to/usr/local/bin AInstalling virtualenv-2.7Script to/usr/local/bin -Successfully installed virtualenv-12.0.6
Shell Installation virtualenv
1~$sudo-H PIPInstallNose2[sudo] Password forFred:3 Collecting Nose4Downloading nose-1.3.4-py2-none-ANY.WHL (154kB)5 -% |################################| 155kB 600kb/s6[?25hInstalling collected Packages:nose7 8Successfully installed nose-1.3.4
Shell installation Nose2.2 Execution
1~/mystuff/myprojects/skeleton$ls-R2 .:3 bin Docs NAME setup.py tests4./Bin:5./docs:6./NAME:7 __init__.py __init__.pyc8./Tests:9 __init__.py __init__.pyc name_tests.py name_tests.pycTen[Email protected]:~/mystuff/myprojects/skeleton$ nosetests One . A---------------------------------------------------------------------- -Ran1Testinch 0. 009s -Ok
execute nosetests, attached to project directory structure3. Summary
Practice is complete.
Knowing that Pip, Setuptools, needs the Python package, know where to find it and find out how to install it.
Learned about Virtualenv, nosetests. How to use and continue to learn.
Learn Python the hard way--exercise 46