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

[Feature] Add rez-pip extra args passthrough #827

Merged
merged 6 commits into from
Feb 4, 2020
Merged

[Feature] Add rez-pip extra args passthrough #827

merged 6 commits into from
Feb 4, 2020

Conversation

lambdaclan
Copy link
Contributor

@lambdaclan lambdaclan commented Dec 18, 2019

Description

closes #816

Enable users to customize the pip install command by explicitly defining additional settings to be passed to rez-pip in the form of extra options. Extra arguments can be defined either by using the new rez-pip cli argument [-e/--extra..] or by adding items to the new rezconfig entry pip_extra_args in the form of:

pip_extra_args: ["--no-compile", "--prefer-binary"]

Implementation is based on the ticket above and the discussion between JC, Thorsten and Allan up on slack.

Breakdown

  • Add new rez-pip argument -e/--extra to pass additional options to pip install command
  • Additional options can be defined in a rezconfig file entry pip_extra_args to ensure they are always applied
  • The command line argument -e/--extra overrides the configuration file options (if any)
  • Repeating options automatically override previous one by pip (without extra processing) only last one counts
  • Invalid options are handled by pip (no extra care was taken to prevent them)

Type of change

  • New feature (non-breaking change which adds functionality)

Possible issues

As discussed below regarding repeating options since through extra args the user can override the target and use pep517 options which are prerequisites for correct package install we will need to handle that scenario somehow.

The way I see it there are two methods:

a. Always ignore the target option and anything that can affect use pep517 such as no-binary etc
b. Have a list of allowed options that can be handled by extra args (filter out invalid ones)

Edit:

It has been agreed to assume user responsibility for overriding the wrong options. It needs to be made clear that extra args adds to or overrides the pre-configured args.

How Has This Been Tested?

  • Tried defining multiple option combinations between CLI and rezconfig
  • I will look into the test-suite and see if I can add tests if they already exist for other commands

Test Configuration:

  • Python version: 2.7.17, 3.8
  • OS: Linux, Windows 10
  • Toolchain: rez 2.50.0, pip 19.3.1

Demo

  • rez-pip cli -e --extra argument

pip_cli_extra_args_demo

  • rez-pip cli extra args via rezconfig

pip_cli_extra_args_conf_demo

Changelog

Point release

Source | Diff

Notes

Add rez-pip extra args passthrough

Merged pull requests:

Closed issues:

  • rez-pip creates .pyc files by default #816

src/rez/pip.py Outdated
@@ -249,13 +251,18 @@ def pip_install_package(source_name, pip_version=None, python_version=None,
context.print_info(buf)
_log(buf.getvalue())

# gather additional pip install options
pip_extra_opts = extra_args if extra_args else config.pip_extra_args

# Build pip commandline
cmd = [
py_exe, "-m", "pip", "install",
"--use-pep517",
"--target=%s" % destpath

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone specifies --target as an extra arg ? Or --user ? Should that be filtered out ?

Copy link
Contributor Author

@lambdaclan lambdaclan Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Johannes, as mentioned in the PR description:

Repeating options are automatically ignored by pip (without extra processing)

I also thought that some sort of filtering will be required but after a few tests I confirmed (via the --target option) that any repeating options simply override previous ones, only the last one is taken into account.

Saying that, allowing overriding target can break the installation so I guess it is better to always ignore it same goes for --no-binary since we want pep517 to be always on. That is the problem of allowing extra args, the user can break the rez package install if they override certain options.

I propose that we have a list of allowed options to be specified and only handle those.

I am waiting for Allan's feedback on this.

Thank you for pointing it out though, I will update the PR info to make it clear.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose that we have a list of allowed options to be specified and only handle those.

When we discussed about it, the conclusion was that if someone uses the extra args, he must know what he is doing. At least from what I remember. Instead of having a list of accepted arguments, I would more document which argument should not be specified in the extra args.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hell JC, thank you very much for your input. Any way is fine with me. Actually documenting it somewhere sounds like a good idea. I could even add it to the help text if it makes sense. I will see how I can make it apparent of what needs to be avoided when using extra args. A warning can also be shown if target or pep517 are overridden.

@nerdvegas
Copy link
Contributor

nerdvegas commented Jan 7, 2020 via email

@lambdaclan
Copy link
Contributor Author

Hello @nerdvegas when you get a chance can you please give me an update on the status of this PR? I did the changes as discussed above so if there are no other stoppers maybe we can merge?

Thank you 🙏

@nerdvegas
Copy link
Contributor

nerdvegas commented Feb 3, 2020 via email

@nerdvegas nerdvegas merged commit cbcdaf2 into AcademySoftwareFoundation:master Feb 4, 2020
@lambdaclan lambdaclan deleted the feature/rez-pip-extra-args-passthrough branch April 6, 2020 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rez-pip creates .pyc files by default
4 participants