Pip installation into a custom target directory and exclude certain dependencies

I am looking for a method to use pip or similar to install a list of python packages in a custom target directory (ex./mypath/python/pkgs/), but also to exclude / blacklist specific strong dependencies.

I want to exclude certain dependencies, as they already occur from a different installation path (for example, installing anaconda). I don't have the privilege of adding packages to the default python installation (and I don't want to).

I am currently using the -r and -t options for pip. But they did not find a way to exclude certain packages.

A pip command like this would be ideal:

pip install --log pip.log -r req.txt -t /mypath/pypkgs/ --exclude exclude.txt

--no-deps not an option, as I need some of the dependencies.

I am currently using a python script to create packages that contain dependencies that I don't need:

pip install --log pip.log -r req.txt -t /mypath/python/pkgs/

and then (automatically) remove unnecessary dependencies after pip installation is complete.

I hope that some combination of pip commands can achieve what I'm looking for. I am using pip 7.1.2. Thanks!

Similarly, but I am not updating and want to specify the target path:

pip: service pack without updating a specific dependency

+4
source share
2 answers

I think this can essentially be achieved in a few steps if you use virtualenv or the like ...

  • If you first do the usual pip freeze > requirements.txt, you get all the transitive dependencies (for example, excluding nothing).

  • .txt, , ...

  • , pip install -r requirements.txt -t ... --no-deps. Voila: , .

+2

bash,

pip install $(cat requirements.txt | grep -ivE "pkg1|pkg2|pkg3")

pkg1 .. - .

+1

Source: https://habr.com/ru/post/1613871/


All Articles