Pip: Check directory permissions before download: pip install

Created on 22 Jul 2019  ·  4Comments  ·  Source: pypa/pip

What's the problem this feature will solve?

Taking a long time to fail due to collection and downloading a package when pip install is targeting a directory the user doesn't have permissions to write to.

Describe the solution you'd like

Before pip begins collecting a package, check if the user running pip has permission to write to the target directory.

needs discussion enhancement

Most helpful comment

Some considerations:

  1. the target directory in question will vary based on --prefix, --root, --user, or the default (virtualenv or global).
  2. for most packages it's probably only the site-packages directory that matters, so only checking that should be OK IMO
  3. it might be worthwhile to check before getting the index, since that itself can take some time depending on network conditions

All 4 comments

I would be happy to write this feature as my first contribution to pip. New to python and curious if there's something naive about this enhancement proposal, I'll check out the code tonight.

Hello @tfolbrecht feel free to submit a PR :)
check_path_owner helper is likely to help.

Some considerations:

  1. the target directory in question will vary based on --prefix, --root, --user, or the default (virtualenv or global).
  2. for most packages it's probably only the site-packages directory that matters, so only checking that should be OK IMO
  3. it might be worthwhile to check before getting the index, since that itself can take some time depending on network conditions

Thank you all so much for the help.
Diving through the pip internals in my freetime has been a lot of fun.
I'm steadily getting there.

Was this page helpful?
0 / 5 - 0 ratings