Parallel Pip install

后端 未结 6 568
时光取名叫无心
时光取名叫无心 2020-12-24 03:08

Our Django project is getting huge. We have hundreds of apps and use a ton of 3rd party python packages, many of which need to have C compiled. Our deployments are taking a

6条回答
  •  春和景丽
    2020-12-24 03:46

    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.

提交回复
热议问题