What's the problem this feature will solve?
Currently the --install-option
parameter allows passing arbitrary arguments to setup.py
for packages using the legacy-installation path. If any options/flags that control install location are passed, such as:
--exec-prefix
--home
--install-base
--install-data
--install-headers
--install-lib
--install-platlib
--install-purelib
--install-scripts
--prefix
--root
--user
then it causes issues. Not every package uses setup.py
, so in the general case this causes legacy packages to be installed with the the scheme provided in --install-option
and PEP 517/wheel packages to be installed with the scheme pip is aware of. This has already hit two users (#7253, #7240).
Pip knows how to use scheme information properly for PEP 517, wheel, and legacy installs. Enforcing that pip is the only one passing this kind of information will make the user experience more consistent.
Describe the solution you'd like
Explicitly fail pip install
if --install-option
includes any of the above arguments, whether provided on the command-line or in a requirements file.
In addition to the consistent user experience, this would also allow pip to pass the more explicit
--install-{purelib,platlib,headers,scripts,data}
(for install
)--install-dir
, --script-dir
(for install -e
)to setup.py
instead of the current --prefix
, --home
, --root
, --user
, and --install-headers
.
This may also be required to implement PEP 582 (__pypackages__
) since doing legacy installs to a plain lib
directory isn't possible with the current arguments being passed to setup.py
, and passing an explicit --install-lib
would break any usages of the other arguments in --install-option
.
IMO this could be implemented without deprecation because the current behavior demonstrated in #7253 and #7240 causes failures in non-obvious ways, and the remediation is simple in most cases - just pass the parameters to pip instead.
Alternative Solutions
--install-option
we will get more support tickets. These will taper off eventually as people stop using these flags in order to install non-legacy packages. We eventually forget that the user can pass these options, and implement new features without worrying about it.--install-option
- this defeats the purpose of having pip-level arguments--install-option
conflicts with the one specified at the pip level - this is more friendly, but I feel that it would also be more confusing and add to the implementation burden in pip (reconciling --install-option
across different packages in a requirements file)Additional context
--home
, --prefix
, --user
, and --root
to setup.pySounds like a good idea to me.
We'd have to go through a regular deprecation cycle here but I don't see any reason to not do this.
I would argue that this is an extension of #6606/fix for #7240, and thus doesn't require a deprecation cycle. As mentioned above, the current behavior when using these flags is broken unless all builds are going through the legacy code path.
nods
I don't think this is an extension of #6606 -- that PR changed when pip used PEP 517, which is something we're still working on. This, however, affects everyone on the legacy code path. We'd be removing functionality that user might depend on directly, so we should go through the deprecation cycle for it.
FWIW, I now know that basically any change in pip's build logic will affect someone (i.e. break their deployment / CI pipeline) and they're usually not happy about it. With the power of retrospect, I feel we should've gone for at least short deprecation cycle (1 release) for #6606 since that was a (minor) change in end-user-affecting behavior as well.
OK. After thinking on it more, we can communicate the workaround in the deprecation notice. Hopefully that means currently impacted users will not have to search the issue tracker when some packages are missing, so I don't mind that approach as much as I did initially. It might even be worth including in a fix release for 19.3? Then we could also close #7240.
Given that we've already closed that issue (which is a form of communication on our release processes), I'm inclined to say no -- but it's really an RM's decision so... pinging @xavfernandez! :P
FWIW, I'm in no hurry to close #7240 but yes, even the deprecation messaging is enough to justify closing it.
I'm on board with forbidding conflicting options in --install-options
and also in favor of a deprecation period.
Concerning a 19.3.2 release, it seems strange to make a patch release just to include a warning... but if everyone agrees (and if the patch is clean), why not :)
Note that #7002 (unreleased) will also break some usages of these options in --install-option
, since we only take into account the --user
, --prefix
, --target
, and --root
options explicitly passed to pip when determining whether to do a user install.
After talking this over with @pradyunsg, our conclusions are:
--install-option
into input for our scheme (potentially blocking if there is some conflict between --install-option
and arguments passed directly to pip), which would let us press forward with other refactoring that requires pip to have more control over the setuptools argumentsFor the more fine-grained option handling, I'm thinking the following:
if provided in any --install-option
, these options would be compared against all other requirements' --install-option
s and the options provided to pip itself. If the pip equivalents are unset then they would be set to the provided options and the options removed from --install-option
. If the pip equivalents are set to a different value, then we raise an error. If other requirements have a different value or do not have the same value in their --install-option
s then we raise an error.
--home
maps to --target
--prefix
maps to --prefix
--root
maps to --root
--user
maps to --user
If provided in any --install-option
, these options would be compared against all other requirements' --install-option
s. If the other requirements have a different value or do not have the same value in their --install-option
then we raise an error. If there are any pip-level location options then we raise an error. Otherwise we explicitly set the corresponding field on our install scheme after we generate the default one and remove the argument from --install-option
.
--install-data
--install-headers
--install-lib
--install-platlib
--install-purelib
--install-scripts
These options, which do not have an equivalent in the scheme that we install packages to, are unsupported and if they are provided in any --install-option
s then we raise an error
--exec-prefix
--install-base
I think this is the minimum (in terms of user-facing impact) we can do while still being able to move forward on creating an explicit scheme for install.
Just to reiterate why this is important: once the above is in place, we would be able to do the following:
Scheme
object in InstallCommand.run
Scheme
to instantiate a working setResolver
/RequirementPreparer
/InstallRequirement
in the process)Added to milestone 20.2.
Was a deprecation warning added in 19.3/20.2? Or is this an optimistic "we'll add the warning in 20.2"?
@pradyunsg There is a deprecation warning pointing to this issue, with gone_in="20.2". No feedback was reported here so I assume it's now appropriate to convert the warning into an error.
Awesome!
The relevant bit of code: https://github.com/pypa/pip/blob/4645ecbdb096373d6711406527b3b1fdc4fb785c/src/pip/_internal/commands/install.py#L635-L649
So, unfortunately, I didn't include --install-dir
and --script-dir
in the list of things to get checked. This is supported by its usage in this test, which started to fail when I refactored editable installation to explicitly pass --script-dir
to setup.py. These values are only relevant to editable installs.
As a result we can't do a full replacement now like I was intending. We can still take an approach like I described in #7309 (comment), and it should be quite a bit easier since there are only two values and they map directly to the scheme values we should use (overriding "scripts" and "lib_dir"). We could do that while waiting another 2 releases before disallowing --install-dir
and --script-dir
and still get the majority of the benefits.
@chrahunt I've been looking along this thread and haven't been able to find my answer, hopefuly you can give me an answer :)
I previously legeraged --install-option="--install-scripts=/custom/path/"
to deploy only scripts to a specific location but this is now rejected with the recents updates.
Is there still a way through pip to install scripts to a custom location without moving the whole package ?
Thank you
Hello! Do you mind creating a new issue with this question and maybe a few more details on your use case so we can provide better advice?
pip documentation still gives "--install-scripts" as a suggested use of "--install-option"
@nugend Would you mind opening a new issue for the documentation fix?
@chrahunt I've been looking along this thread and haven't been able to find my answer, hopefuly you can give me an answer :)
I previously legeraged--install-option="--install-scripts=/custom/path/"
to deploy only scripts to a specific location but this is now rejected with the recents updates.
Is there still a way through pip to install scripts to a custom location without moving the whole package ?Thank you
This is used by one of our repositories at work, to keep all scripts used at $dayJob
in the same location, and I haven't been able to find any way to get the behaviour with any new options yet. Any suggestions on how to get this behaviour in the new situation are much appreciated.
As stated above, please open a new issue. I think this fits well into the recent configurable install scheme discussion, but it should be discussed as a feature request on its own, not buried under a closed issue.
Most helpful comment
@chrahunt I've been looking along this thread and haven't been able to find my answer, hopefuly you can give me an answer :)
I previously legeraged
--install-option="--install-scripts=/custom/path/"
to deploy only scripts to a specific location but this is now rejected with the recents updates.Is there still a way through pip to install scripts to a custom location without moving the whole package ?
Thank you