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 20.3+ compatibility: use wheelhouse versions on install #193

Merged
merged 2 commits into from
May 4, 2021

Conversation

ajkavanagh
Copy link
Contributor

pip 20.3.4 and higher fail to install the packages specified in the
wheelhouse if versions are not used directly. This patch uses the
'package==version' method of specifying a versio for a package when
installing the packages from the wheelhouse (which ought to be all of
them).

pip 20.3.4 and higher fail to install the packages specified in the
wheelhouse if versions are not used directly.  This patch uses the
'package==version' method of specifying a versio for a package when
installing the packages from the wheelhouse (which ought to be all of
them).
@ajkavanagh
Copy link
Contributor Author

I've tested this with the aodh and pacemaker-remote charms (built on xenial) on trusty, xenial, bionic, focal, groovy and hirsute.

@ajkavanagh ajkavanagh marked this pull request as ready for review April 11, 2021 17:18
Copy link

@lourot lourot left a comment

Choose a reason for hiding this comment

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

Thanks a lot! This looks functionally correct but I found it a bit hard to read. See my more-specific inline comments. Thanks!

return _s[:-len(ending)]
return _s

def _maybe_make_version(k):
Copy link

Choose a reason for hiding this comment

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

I don't understand why this is called "maybe"? Shouldn't it be called "add_version_remove_extension" or "enforce_with_version_without_extension" or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's called _maybe* as it might make the key k into a versioned package==version. However, I could probably do with better names.

return _s[:-len(ending)]
return _s

def _maybe_make_version(k):
Copy link

Choose a reason for hiding this comment

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

This is a bit hard to read on the overall, because of the one-char var names and the missing docstrings+types. I know docstrings aren't mandatory here but they would really help me and my weak brain.

So I think k is a package name that may or may not have an extension and may or may not have a version number, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sometimes a function can be a bit opaque. The function would be better named as _maybe_add_version_to_pkg as that is what it is doing (i.e. if the pkg has a version in the versions{} then it will add it, otherwise it will leave it alone.

@@ -278,6 +284,29 @@ def _load_wheelhouse_versions():
return versions


def _add_back_versions(pkgs, _versions):
Copy link

Choose a reason for hiding this comment

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

I think it would help to describe (e.g. with a docstring) that _versions is supposed to be a dictionary where the keys are elements of pkgs

Copy link
Contributor Author

@ajkavanagh ajkavanagh Apr 13, 2021

Choose a reason for hiding this comment

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

I'm a bit confused; the docstring is immediately below? Do you mean, list out the params and types in the docstring (which isn't currently the library's style)?

# <package_name>==<version>.
# This ensures that pip 20.3.4+ will install the packages from the
# wheelhouse without (erroneously) flagging an error.
pkgs = _add_back_versions(_pkgs, _versions)
Copy link

Choose a reason for hiding this comment

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

So apparently if I understand correctly this is not only adding the version back but also removing extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes; you can't ask pip install ==[.tar.gz|.zip] as it will throw an error. Unfortunately, LooseVersion() wrapping the version also includes the extension and so it needs to be removed.

@ajkavanagh
Copy link
Contributor Author

Thanks a lot! This looks functionally correct but I found it a bit hard to read. See my more-specific inline comments. Thanks!

Thanks for the review; I'll walk through the changes against your comments and then try to update the code to make more sense.

Copy link

@lourot lourot left a comment

Choose a reason for hiding this comment

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

This is way more clear now, thanks a lot!
The Travis failure seems to be an infra issue.
And finally it seems like I don't have merge permissions on this repo, sorry about that.

Copy link
Contributor

@gnuoy gnuoy left a comment

Choose a reason for hiding this comment

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

LGTM

@johnsca johnsca merged commit 673f7ad into canonical:master May 4, 2021
@ajkavanagh ajkavanagh deleted the install-direct-versions branch May 5, 2021 09:00
openstack-mirroring pushed a commit to openstack/charm-vault that referenced this pull request May 11, 2021
Fixes pip install wheelhouse failure on Hirsute.
canonical/layer-basic#193

Also pin ops!=1.2.0 due to that version of the ops (operator)
library not working with xenial [1].

[1] canonical/operator#517

Change-Id: Ia8194247d5d553e72e694b4e2c649bd418d2adf4
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request May 11, 2021
* Update charm-vault from branch 'master'
  to c4f0c880a3d11a860fb5f408e0ce1150e4426bdb
  - Merge "Rebuild for picking up layer-basic#193"
  - Rebuild for picking up layer-basic#193
    
    Fixes pip install wheelhouse failure on Hirsute.
    canonical/layer-basic#193
    
    Also pin ops!=1.2.0 due to that version of the ops (operator)
    library not working with xenial [1].
    
    [1] canonical/operator#517
    
    Change-Id: Ia8194247d5d553e72e694b4e2c649bd418d2adf4
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.

None yet

4 participants