[Distutils] deprecating pip install --target

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Mon Feb 29 11:00:36 EST 2016


On 17.02.2016 11:09, Paul Moore wrote:
> On 16 February 2016 at 22:52, Robert Collins <robertc at robertcollins.net> wrote:
>>> An alternative would be great, though I can probably fake things somehow for
>>> my purposes.
>>
>> Sounds similar to Daniel's need - and again, --prefix + setting PATH
>> and PYTHONPATH would be better.
>
> Note that if I read the help for --prefix correctly, "pip install
> --target x foo" puts foo in x, whereas "pip install --prefix x foo"
> puts foo in x/lib. So how would setting prefix allow me to put foo in
> x, and not in a subdirectory? That is specifically my requirement (and
> the vendoring requirement in general).

I just discovered a way that lets you do just that, but before using it 
for my own code I'd like to know whether you would consider it a weird 
hack that will probably not work in the future or something reasonable 
that could be used in production code? Here's the trick:

write a temporary distutils setup.cfg file in the current working 
directory with the content:

[install]
install-lib=abspath/to/target_dir

then run pip from that directory like so:

pip install packagexy --prefix abspath/to/target_dir

Of note, combining a local setup.cfg file and --prefix like this isn't 
documented and to me it wasn't even clear whether the file would be 
expected in the current working directory that pip gets run in or in the 
downloaded package.

What is more, the local setup.cfg file can also be used to specify a 
complete installation scheme for use without the --prefix option.

As I said I'm really interested in your opinions,
Wolfgang


More information about the Distutils-SIG mailing list