Parallel pip installation
This example uses xargs to parallelize the build process by approximately 4x. You can increase the parallelization factor with max-procs below (keep it approximately equal to your number of cores).
If you're trying to e.g. speed up an imaging process that you're doing over and over, it might be easier and definitely lower bandwidth consumption to just image directly on the result rather than do this each time, or build your image using pip -t or virtualenv.
Download and install packages in parallel, four at a time:
xargs --max-args=1 --max-procs=4 sudo pip install < requires.txt
Note: xargs has different parameter names on different Linux distributions. Check your distribution's man page for specifics.
Same thing inlined using a here-doc:
cat << EOF | xargs --max-args=1 --max-procs=4 sudo pip install
awscli
bottle
paste
boto
wheel
twine
markdown
python-slugify
python-bcrypt
arrow
redis
psutil
requests
requests-aws
EOF
Warning: there is a remote possibility that the speed of this method might confuse package manifests (depending on your distribution) if multiple pip's try to install the same dependency at exactly the same time, but it's very unlikely if you're only doing 4 at a time. It could be fixed pretty easily by pip install --uninstall depname
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…