pip-tools icon indicating copy to clipboard operation
pip-tools copied to clipboard

Support for Installation to a Different Directory

Open kevjumba opened this issue 5 years ago • 5 comments

What's the problem this feature will solve?

I'm trying to install python libraries to a specific folder in my repository (not the system-packages folder that pip/pip-tools) usually installs to). More specifically, python pip supports a --target option that adds all of the downloaded python packages to the target directory specified. I would like pip-tools to also have this option.

Describe the solution you'd like

Instead of having pip-sync install to a site-packages folder in the virtual environment, I would like to give it a --target argument to install/perform all of the sync tasks in a different folder of my choosing. Currently I can install to a specific folder like lib but pip-sync doesn't actually try to ascertain what libraries are in lib and what need to be upgraded.

Google App Engine uses a system where python libraries are vendored in their sandbox by adding the path of a directory that contains all of the specific python libraries that are installed. Users are instructed to run pip install -r requirements.txt --target lib and then add lib to a configuration path in the application config.

Alternative Solutions

I've been looking around and there don't seem to be other tools available. I'm happy for suggestions though.

kevjumba avatar Aug 21 '20 23:08 kevjumba

Hello @kevjumba,

There is --pip-args option in pip-sync so that you can pass any options to pip install ..., for example:

$ pip-sync --pip-args="--target=/tmp/foo"

atugushev avatar Aug 22 '20 01:08 atugushev

@atugushev hello, this works for actual installation but I want to have the full suite of pip-sync tools also available on the target directory. More specifically, when I install some libraries, if I want to upgrade a singular library to a later version, pip-sync doesn't check in the target directory when it calculates which libraries to install/uninstall. Instead, I just get the same options I get when using pip install, aka that some of the libraries already exist and if I want to upgrade them use pip install --upgrade.

What I think is happening is that the pip-sync tool is looking in the .venv/python/system-packages directory when it tries to find what is installed and what is not.

Please let me know if any interpretation is incorrect.

kevjumba avatar Aug 22 '20 01:08 kevjumba

Aw, I see your point. pip-tools is pretty tight to the virtual environment. Unfortunately, I'm not aware of how Google App Engine works with python packaging, so can't help much with this.

atugushev avatar Aug 23 '20 07:08 atugushev

I haven't used GAE, but could something like this work?

$ python -m venv venv
$ ln -s $PWD/venv/lib/python*/site-packages lib
$ . ./venv/bin/activate
$ pip install -U pip pip-tools

AndydeCleyre avatar Nov 06 '20 04:11 AndydeCleyre

@kevjumba

Have you been able to give that a try?

AndydeCleyre avatar Mar 21 '22 17:03 AndydeCleyre