Feature Request: Copy an installed package to a specified directory

(Moved from pypa/pip#6744)

I realize this is something similar to, but not exactly the same as PEP 582.

This proposal is more about distribution than it is about packaging. I’m not sure why we don’t have a separate channel for distribution.


A typical python development workflow involves creating a virtualenv, and then using pip to install dependencies @ the site-packages of the virutalenv.

This proposal should allow users to move any installed package (from virtualenv) to a folder of their choice.

What’s the problem this feature will solve?

Allow users to package their dependencies in a zipfile, or some other format while ensuring that dependencies are the exact ones they were using in development.

This would also ensure that minor modifications made to the dependencies, using the code editor (presumably, using goto definition), are preserved in production. (without the need to create a separate private repository, or submit a pull request to the original author – both of which are quite tedious tasks.)

Current Solutions

The current standard way is to use --target for storing dependencies in a folder, and then packaging them into a zip for distribution. (using tools like PEX/shiv/zipapp)

While sufficient for most trivial tasks, I personally experienced some problems with this approach, that I think this proposal can solve.

  1. The dependencies may not be the exact ones that were being used in development.
  2. --target doesn’t behave well with --editable
  3. It re-installs dependencies, which consumes unnecessary resources, for files that in theory, already exist on the user’s machine.

I don’t have much to say about the implementation details for this proposal, but it seems doable to me.

I’m willing to pitch in the hours myself if someone experienced is willing show me the starting point.

If this requires too much work or is technically impossible with the current architecture, I’m sorry for wasting your time.

For context, as noted on the pip tracker this feature is largely unrelated to pip’s functionality (it’s in essence about relocating an already-installed package) and so would be better handled as a new project, implementing a standalone tool that did this. There’s some more detail on the pip issue, for anyone interested in implementing such a tool.

Points 1 and 3 are conflicting. Either you can bring your own matching dependencies, or you risk having them not match.

Point 2 doesn’t make sense - --editable doesn’t behave well with distributing a packaged app at all, regardless of how you package the app. You’ll want to install it properly into your to-be-packaged directory before zipping it up.

Packaging is also likely the final step, separate from development, so copying the contents of your venv is a bad move.

pip install --target has always worked fine for the cases that I’ve dealt with. You haven’t made it at all clear why it’s not working for you.