Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip install with target doesn't work for optional sub-packages #4230

Closed
matham opened this issue Jan 14, 2017 · 11 comments
Closed

pip install with target doesn't work for optional sub-packages #4230

matham opened this issue Jan 14, 2017 · 11 comments
Labels
C: target pip install's --target option's behaviour handling state: needs reproducer Need to reproduce issue

Comments

@matham
Copy link
Contributor

matham commented Jan 14, 2017

  • Pip version: 9.0.1
  • Python version: 2.7-x64
  • Operating System: Win10

Currently, when using the target option, --target, if a directory/file already exists and would be overwritten it errors out requesting the you use upgrade. However, that is impossible when trying to install an optional sub-package to a package that was also installed to a different location with --target.

Imagine you have the package foo installed and it has its __init__.py and other modules. Now I would like to install foo.bar to foo (i.e. sub-package bar in the foo directory). When installing to site-packages, like normal, it works and pip doesn't care that foo directory already exists (in fact it doesn't seem to care even if foo.bar exists as long as the *.dist_info for foo.bar is removed). The point is that pip is happy to overwrite files.

Now imagine foo was installed elsewhere with --target. Now I'd like to install foo.bar also to the other location. But now pip errors out saying Target directory foo already exists. Specify --upgrade to force replacement. --upgrade would not work here is at would just delete the previous contents of foo messing up the main package.

This change happened in #2007, while I see that there were issues that required this, these changes made sub-packages impossible with --target.

Would perhaps a --overwrite option be in order? And maybe the --overwrite option should be automatically set to be in line with current pip behavior when installing to site-packages?

@lmazuel
Copy link

lmazuel commented Mar 23, 2017

+1 got the same problem and was looking to open an issue and found this one.

This is EXACTLY our situation.

FYI @brettcannon @annatisch

@pradyunsg
Copy link
Member

I'm not sure what we want to do here. Maybe other @pypa/pip-committers have inputs on this?

@pradyunsg pradyunsg added C: target pip install's --target option's behaviour handling S: awaiting response Waiting for a response/more information labels Mar 5, 2018
@tlelson
Copy link

tlelson commented Mar 25, 2018

Also have the exact problem.

This kind of local install is only getting more popular with increasing use of such things as AWS lambda and GCP AppEngine.

@automartin5000
Copy link

automartin5000 commented Apr 12, 2018

I think I have the same problem? I actually thought #2007 might fix the problem, but I guess not. I posted on SO just to confirm

@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label May 11, 2018
@pradyunsg
Copy link
Member

Could someone provide a reproduction case for this?

@peacepirate
Copy link

Sounds like an issue similar to what I ran into. My issue was trying to install subpackages under a common package hierarchy that already exists at the time of installation. example package names: dog.german, dog.british. I added a temporary fix for my use case: using --root [location] instead of -t to install in a predetermined location. This creates the sites-package sub directories, but that location is static and I copy over the dir from final location for further use.

@chrahunt chrahunt added the state: needs reproducer Need to reproduce issue label Jul 21, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Jul 21, 2019
@chrahunt chrahunt removed the S: awaiting response Waiting for a response/more information label Sep 1, 2019
@mehmetfazil
Copy link

I am currently trying to build a deployment package for AWS Lambda, with using amazonlinux image and python3-pip, having this issue as well. Has not find any workarounds yet.

@pfmoore
Copy link
Member

pfmoore commented Nov 12, 2019

As @pradyunsg said, we'll need a reproduction case for this. I'd also add that I would want to see more context on what the logic is for doing this and why it's a reasonable behaviour to rely on (descriptions involving artificial packages like foo.bar are great for explaining the problem, but not so good for explaining why you want to do things in the first place).

My inclination is to say that you shouldn't be trying to do this, as it's not how I'd expect --target to be used, which is why I want to better understand what you're trying to achieve here.

@mojganaz
Copy link

@pfmoore one usecase for this is when you'd want to ship multiple python packages to your spark application. You'd pip install with -t option into a folder. Zip the folder and pass it to spark-submit using --py-files option.

@pfmoore
Copy link
Member

pfmoore commented Mar 12, 2020

@mojganaz Thanks for the example, but I don't really see why you couldn't just pip install everything, submit the zipped folder, and then remove the folder. Next time you want to submit, do the same. What's the requirement for doing pip install -t into an existing, non-empty folder in this scenario?

Sorry if the answer is something straightforward about how spark works, I'm not at all familiar with spark, so feel free to explain in idiot-level terms 🙂

@pradyunsg
Copy link
Member

Closing this because no one has provided a reproducer for this, and there has been no activity on this for two years now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: target pip install's --target option's behaviour handling state: needs reproducer Need to reproduce issue
Projects
None yet
Development

No branches or pull requests

10 participants