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

Upgrade to newer Python pip>=21.0 #59769

Merged
merged 5 commits into from
Feb 7, 2022
Merged

Upgrade to newer Python pip>=21.0 #59769

merged 5 commits into from
Feb 7, 2022

Conversation

frenck
Copy link
Member

@frenck frenck commented Nov 16, 2021

Proposed change

We currently lock pip to <20.3.
This will work for a while and doesn't cause problems right now. But in the long run, will become problematic. This PR serves as a draft to monitor progress towards getting it upgraded.

ℹ️ We now have a pip-check script in CI in place to protect us against creating more conflicts.
We are currently down to 11 conflicts (some have a PR open, others will probably end up being disabled as an integration).

⚠️ I've adjusted this PR to use the legacy resolver, this gives us an upgrade path for now, and will help with Python 3.10 handling as well (#59729).

Todo:

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: closes Support pip 20.3+ #45444
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant probot-home-assistant bot added core dependency small-pr PRs with less than 30 lines. labels Nov 16, 2021
This was referenced Nov 16, 2021
@Shutgun Shutgun mentioned this pull request Nov 19, 2021
22 tasks
@RicArch97 RicArch97 mentioned this pull request Nov 27, 2021
22 tasks
@scop
Copy link
Member

scop commented Dec 14, 2021

Updated missing statuses in the list, filed a few PR's. The only fixable one without a PR or issue report at the moment is pyicloud (click>=6.0,<=7.1.1, might need some knowledge and a bit of work to fix).

@balloob
Copy link
Member

balloob commented Jan 12, 2022

Since we can still use the legacy resolver with the latest pip, can we update to this PR, add command line flag for legacy resolver and make sure we block any 22+ versions?

@cdce8p
Copy link
Member

cdce8p commented Jan 12, 2022

Since we can still use the legacy resolver with the latest pip, can we update to this PR, add command line flag for legacy resolver and make sure we block any 22+ versions?

That would work. According to the documentation, the old resolver hasn't yet been removed. Although there are no guarantees that it will continue to work for each new release. It might be removed even in the next minor release.

I do think however that the original intent for this PR was to track the issues which need to be addressed for the resolver change. Adding the legacy flag will only push that down the line.

There is another reason to use --use-deprecated=legacy-resolver though. The current pip version has a bug which prevents the install of Python 3.10 wheels even if they have been uploaded to PyPI. The fix was included in 21.3.2. This would definitely and allow some users to start using 3.10 even if not officially supported yet (#59729). Especially if the resolver change still needs some more time. I would suggest pinning 21.3.4 in that case.

@frenck
Copy link
Member Author

frenck commented Jan 12, 2022

do think however that the original intent for this PR was to track the issues which need to be addressed for the resolver change.

Yeah regular rebase and see what it spits out and try to resolve.

The current pip version has a bug which prevents the install of Python 3.10 wheels even if they have been uploaded to PyPI. The fix was included in 21.3.2. This would definitely and allow some users to start using 3.10 even if not officially supported yet

That is not blocking at this point.
People have been using Python 3.10 and it's not blocking our upgrade path.

That said, yeah using the legacy flag will do for now. I Will index all the locations that need updating (wheels, Dev containers, CI and a couple of spots more).

@cdce8p
Copy link
Member

cdce8p commented Jan 12, 2022

That is not blocking at this point. People have been using Python 3.10 and it's not blocking our upgrade path.

True. Although it's much more convenient to use prebuild wheels.

That said, yeah using the legacy flag will do for now. I Will index all the locations that need updating (wheels, Dev containers, CI and a couple of spots more).

👍🏻 One issue we should be aware of. Using the flag on <20.3 seems to be an error. It might be necessary to check the version before adding it to the install command, since we support a pretty large dependency range for pip atm.

option --use-deprecated: invalid choice: 'legacy-resolver' (choose from )

@cdce8p
Copy link
Member

cdce8p commented Jan 29, 2022

Something more for the Todo list. Pip 21.3 supports editable installs with just build-backends. Thus we could remove setup.py completely. #65154 (comment)

https://pip.pypa.io/en/stable/news/#v21-3

@frenck frenck marked this pull request as ready for review February 7, 2022 12:47
@frenck frenck changed the title Upgrade to newer Python pip Upgrade to newer Python pip>=21.0 Feb 7, 2022
@cdce8p
Copy link
Member

cdce8p commented Feb 7, 2022

Github doesn't work, I can't leave review comments it seems 😞

Some notes here instead:

  • I would suggest setting an upper limit. According to the deprecation timeline, the legacy-resolver option should have been removed already. It isn't yet, but that doesn't mean it will still be there in the next release.
pip>=21.0,<21.1
  • Should the subprocess commands be updated too? Probably enough to search for "pip".
    args = [sys.executable, "-m", "pip", "install", "--quiet", package]

@frenck
Copy link
Member Author

frenck commented Feb 7, 2022

I would suggest setting an upper limit.

Agreed but let's make it pip>=21.0,<22.1 😉

Should the subprocess commands be updated too?

I skipped that one, as that prevents e.g., custom integrations to make a mess?
For our full distribution, it matters, as it installs "everything". But I don't think it should be a problem after that. In my point of view: I rather add that one if we learn it is problematic,

@cdce8p
Copy link
Member

cdce8p commented Feb 7, 2022

Should the subprocess commands be updated too?

I skipped that one, as that prevents e.g., custom integrations to make a mess? For our full distribution, it matters, as it installs "everything". But I don't think it should be a problem after that. In my point of view: I rather add that one if we learn it is problematic,

I wasn't sure about that myself. AFAIK and if it hasn't changed since, the dependency resolver doesn't take the installed packages into account. So it would not even change much.? To have a fully deterministic build, we would probably need to add every requirement to the constraints file, but that will surely impact custom integrations.

For the full distribution, I agree. There it's necessary.

--
As I'm writing this, could we add the constraints option to the subprocess calls? Without it, custom integrations might be able to overwrite core dependencies.

@frenck
Copy link
Member Author

frenck commented Feb 7, 2022

As I'm writing this, could we add the constraints option to the subprocess calls?

Yeah, that has crossed my mind a couple of times as well, but that is kinda "meh".
Ideally, you would constrain it to all packages currently installed/in use (e.g., requirements_all.txt`) or create a pip freeze on build and use that one (which would only apply to container distributed versions).

Nevertheless, it doesn't have to be problematic if a custom integration replaces a dependency of an integration that isn't used by the end-user either...

So a choice between evils probably? 🙈 🙉 🙊

PS: Let's not put these things in this upgrade path 😉

@cdce8p
Copy link
Member

cdce8p commented Feb 7, 2022

Nevertheless, it doesn't have to be problematic if a custom integration replaces a dependency of an integration that isn't used by the end-user either...

So a choice between evils probably? 🙈 🙉 🙊

True. We could also argue that if a custom integration breaks Home Assistant, it's the responsibility of the integration author to fix it. So maybe we don't need to change anything for the time being.

PS: Let's not put these things in this upgrade path 😉

😄

Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

LGTM!

@frenck frenck merged commit da3024e into dev Feb 7, 2022
@frenck frenck deleted the frenck-2021-3016 branch February 7, 2022 14:12
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pip 20.3+
5 participants