Pip install to custom target directory and exclude specific dependencies

前端 未结 3 1887
野的像风
野的像风 2021-02-07 03:12

I\'m looking for a method to use pip or similiar to install a list of python packages to a custom target directory (ex./mypath/python/pkgs/ ), but also exclude/blacklist

3条回答
  •  别跟我提以往
    2021-02-07 03:43

    An approach that takes into account sub-dependencies is to first install the exclude.txt environment, then the req.txt environment, then check the diff and finally install that into the target directory.

    Example using virtualenv that will work on GNU/Linux:

    virtualenv tmpenv
    source tmpenv/bin/activate
    
    pip install -r exclude.txt
    pip freeze > exclude-with-deps.txt
    pip install -r req.txt
    pip freeze > req-with-deps.txt
    comm -13 exclude-with-deps.txt req-with-deps.txt > final-req.txt
    
    pip install -r final-req.txt --no-deps -t pypkgs
    

提交回复
热议问题