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

install --target should offer option to supplement existing packages #4116

Closed
jaraco opened this issue Nov 16, 2016 · 11 comments
Closed

install --target should offer option to supplement existing packages #4116

jaraco opened this issue Nov 16, 2016 · 11 comments
Labels
C: target pip install's --target option's behaviour handling type: enhancement Improvements to functionality

Comments

@jaraco
Copy link
Member

jaraco commented Nov 16, 2016

I'd like to replace the Setuptools setup_requires and tests_requires dependency resolution with something that relies on pip. To this end, I've created rwt, which relies heavily on pip install --target to install the requisite packages.

One major difference between Setuptools setup_requires behavior and pip install --target is that pip install --target installs all requirements unconditionally while easy_install will only install those packages not already satisfied by the current environment (working set).

For the purposes of rwt and probably other use cases, if pip had a similar option for --target that would only install those packages not already satisfied by the current environment, that would be preferable, especially in cases where one is seeking to augment or override a small number of packages from an otherwise large set already mostly available.

@jaraco
Copy link
Member Author

jaraco commented Nov 16, 2016

Consider this simple case:

$ python -m pip install requests
Collecting requests
  Downloading requests-2.12.1-py2.py3-none-any.whl (574kB)
    100% |████████████████████████████████| 583kB 2.1MB/s 
Installing collected packages: requests
Successfully installed requests-2.12.1
$ python -m pip install -t tmp requests_toolbelt
Collecting requests_toolbelt
  Using cached requests_toolbelt-0.7.0-py2.py3-none-any.whl
Collecting requests<3.0.0,>=2.0.1 (from requests_toolbelt)
  Using cached requests-2.12.1-py2.py3-none-any.whl
Installing collected packages: requests, requests-toolbelt
Successfully installed requests-2.12.1 requests-toolbelt-0.7.0
$ PYTHONPATH=tmp python
Python 3.6.0b3 (v3.6.0b3:8345e066c0ed, Oct 31 2016, 18:05:23) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__file__
'/Users/jaraco/tmp/requests/__init__.py'

Requests is installed in system site-packages, then installed again in ./tmp, even though the version in system site packages is sufficient for the purposes of this invocation.

@jaraco
Copy link
Member Author

jaraco commented Nov 16, 2016

The requested behavior would be particularly useful in cases where the dependencies are already satisfied and thus would require no work to satisfy the install operation.

@chrahunt
Copy link
Member

@jaraco, do you still need this post-PEP 517? Maybe something different?

@chrahunt chrahunt added the state: needs discussion This needs some more discussion label Jul 25, 2019
@bloer
Copy link

bloer commented Oct 1, 2019

I just ran into this and was about to submit a new issue. Based on #4389, it seems the intent of --target is to have a fully standalone directory with all dependencies. It seems that similar behavior can be obtained via either --prefix and --root, which handle the dependencies in the requested way.

Maybe all this could be solved by adding some documentation for how those three options differ, and what are the intended use cases?

@jaraco
Copy link
Member Author

jaraco commented Oct 27, 2019

I could still use this functionality. pip-run (formerly rwt) does still wish to only install the packages not already satisfied. Currently, pip-run uses a rough heuristic to determine which packages are already installed and strip those out of the command-line (but not from requirements.txt), which sort-of works but isn't very reliable. Better would be for pip to do its usual resolution and only install the dependencies not already met.

It seems that similar behavior can be obtained via either --prefix and --root.

I seem to think I tried that, but it doesn't behave like --target. In particular, --prefix adds lib/python3.8/site-packages/ (or similar) to the target... and --root adds Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ (or similar).

Additionally, I notice that when a package is upgraded, either due to -U --upgrade-strategy=eager or because a more specific version is indicated, --prefix and --root invocations will uninstall the non-satisfying package, which is undesirable.

What I really want is something like --target, which installs the packages and their metadata in one nice, flat directory with all of the dependency resolution that a normal install provides.

@jaraco
Copy link
Member Author

jaraco commented Oct 27, 2019

I should say, though, the importance of this case is substantially diminished now that pip-run is no longer trying to fulfill the setup_requires case. At this point, it's a nice-to-have.

@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label Feb 6, 2020
@pradyunsg pradyunsg added C: target pip install's --target option's behaviour handling and removed state: needs discussion This needs some more discussion labels Jul 2, 2021
@pradyunsg
Copy link
Member

pradyunsg commented Jul 2, 2021

At this point, it's a nice-to-have.

Given the lack of activity here, I'm gonna go ahead and close this off for now. While this would be nice-to-have; there's not enough interest in actually doing this (based on the lack of responses here and that there's alternatives) but if folks feel like that this is still relevant, please do say so. :)

@uranusjr
Copy link
Member

uranusjr commented Jul 2, 2021

Actually, is #10110 basically the same thing?

@pradyunsg
Copy link
Member

Yup.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
@jaraco
Copy link
Member Author

jaraco commented Nov 19, 2022

This issue is still needed and still a blocker to remove the suboptimal hack in pip-run that attempts to do the same thing (jaraco/pip-run#51). Is there a reason the duplicate is left open while this report is closed? It makes it more difficult to track if the issue is a moving target.

@pradyunsg
Copy link
Member

@jaraco please don't comment on locked issues in this issue tracker, which you're able to do due to being an admin on the pypa organisation.

@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Mar 17, 2023
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 type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

6 participants