Upgrading pip in Python V2 plugin

Hello,

I’m trying to upgrade Pip during the snapcraft build stage of the Python plugin in Core 20. Specifically, I’d like to make use of the new dependency resolver in the newer versions of Pip.

The source implies that it might be possible to upgrade Pip, infact it even by default adds Pip as a default package to be upgraded, however based on what I’m seeing and reading, whilst Pip would be upgraded if passed as package, it’s effectively useless because the original Pip will be what’s used to continue the rest of the process and the newer Pip is essentially unused. Furthermore I think if you define any single extra package, it replaces the defaults rather than appends to them anyway, meaning users would have to manually specify pip to benefit from this if they made use of python-packages itself.

I’d like to avoid over complicating the Snapcraft.yaml such as by using override-build, but at this point I’m lead to believe that this would involve patching the plugin itself, e.g., adding an option where Pip/setuptools/wheel are upgraded first, and then the rest of the users packages are done as a second invocation afterwards.

Am I being an idiot here and missing something obvious?

Thanks in advance!

I will look into fixing this

1 Like

I’ve submitted a PR on this, it looks simple enough but feel free to leave some feedback.

Edit:

After reviewing it in the Github thread, the preferred method for the Python plugin is to use the requirements.txt functionality and use the python-modules attribute to upgrade PIP (and anything else required), and then rely on the bootstrapped pip to manage the requirements file itself.