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

Add support for user and constraints to pip module #33098

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
5 participants
@emonty
Contributor

emonty commented Nov 20, 2017

SUMMARY

pip supports a --user flag, which tells pip to install to the Python
user install directory. Add it as a boolean flag.

pip also supports a -c/--constraint option that can be used to supply a
file containing constraints to apply to how pip resolves dependencies.
Add a parameter allowing a user to provide a path to a constraints file.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/modules/packaging/language/pip.py

ADDITIONAL INFORMATION

Both of these can be put into extra_args of course, but it doing so in playbooks where they are optional parameters starts to get really awkward, while having them as parameters allows use of things like default(omit)

@ansibot

This comment has been minimized.

Contributor

ansibot commented Nov 20, 2017

@ansibot

This comment has been minimized.

Contributor

ansibot commented Nov 20, 2017

The test ansible-test sanity --test validate-modules [?] failed with the following error:

lib/ansible/modules/packaging/language/pip.py:0:0: E309 version_added for new option (constraints) should be 2.5. Currently 0.0

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Nov 20, 2017

@bcoca bcoca removed the needs_triage label Nov 20, 2017

@emonty emonty force-pushed the emonty:add-user-and-constraints branch Nov 20, 2017

@mattclay

This comment has been minimized.

Member

mattclay commented Nov 21, 2017

CI failure in integration tests:

{
    "assertion": "'Successfully installed iso8601-0.1.11' in req_installed.stdout_lines", 
    "changed": false, 
    "evaluated_to": false
}

openstack-gerrit pushed a commit to openstack-infra/zuul-jobs that referenced this pull request Nov 21, 2017

Add general sphinx and reno jobs and role
Sphinx jobs and reno jobs need basically the same thing for
dependencies. So make a new role, ensure-sphinx, which is
parameterizable enough that it can be used by both reno and sphinx jobs.

Make build jobs for both releasenotes and sphinx docs, as both of these
things are perfectly valid things to do in both OpenStack and
non-OpenStack contexts. We'll add an openstack specific job in
openstack-zuul-jobs that uses these as parents but adds the requirements
repo and constraints file settings.

Some of the pip commands here can be improved once
ansible/ansible#33098 lands and is released,
which would allow specifying --user and -c as parameters to the pip
module.

Change-Id: Idd7caf7d88b56d61872906027b4ce7d743572ded
Needed-By: I57de14580f39b9e1c11a587b51b44b61b02c84da
@robinro

Thanks for this PR.

It looks good overall and we should be able to merge it, once the tests are green.

test/integration/targets/pip/tasks/pip.yml Outdated
# Once it does/can, change this to verify using req_installed.version instead
# of looking in stdout_lines
- name: check that version of package was installed that we expect
assert:

This comment has been minimized.

@robinro

robinro Nov 22, 2017

Contributor

This check should be after the register task.

This comment has been minimized.

@emonty

emonty Nov 30, 2017

Contributor

Heh. Duh. Thanks.

test/integration/targets/pip/tasks/pip.yml Outdated
user: yes
# TODO pip module does not report back version in the return info.
# Once it does/can, change this to verify using req_installed.version instead

This comment has been minimized.

@robinro

robinro Nov 22, 2017

Contributor

Feel free to implement this :)
It shouldn't be too hard. We already return the version when given as input and the version is available in _is_present.

This comment has been minimized.

@emonty

emonty Nov 30, 2017

Contributor

Cool - I'll do that in a second PR.

@ansibot ansibot added the stale_ci label Nov 30, 2017

@emonty emonty force-pushed the emonty:add-user-and-constraints branch Nov 30, 2017

Add support for user and constraints to pip module
pip supports a --user flag, which tells pip to install to the Python
user install directory. Add it as a boolean flag.

pip also supports a -c/--constraint option that can be used to supply a
file containing constraints to apply to how pip resolves dependencies.
Add a parameter allowing a user to provide a path to a constraints file.

@emonty emonty force-pushed the emonty:add-user-and-constraints branch to fe0560d Nov 30, 2017

@mattclay

This comment has been minimized.

Member

mattclay commented Dec 1, 2017

CI failure in integration tests. Most of the errors appear to be: failure: :stderr: Usage: pip uninstall [options] <package> ... pip uninstall [options] -r <requirements file> ... no such option: --user

The RHEL 7.4 failure is unrelated to the PR and should be resolved when CI runs again.

@mattclay mattclay added the ci_verified label Dec 1, 2017

@ansibot ansibot added the stale_ci label Dec 9, 2017

@robinro

This comment has been minimized.

Contributor

robinro commented Dec 10, 2017

@emonty The tests are still not green. Can you have another look?
You can run the tests locally via e.g.
source hacking/env-setup; ansible-test integration --docker=ubuntu1604 pip

@ansibot ansibot added feature and removed feature_pull_request labels Mar 2, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Nov 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment