home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.68k stars 30.81k forks source link

conflicting requirements for pyobjc-core #82723

Closed jorhett closed 1 year ago

jorhett commented 1 year ago

The problem

Following the documentation at https://developers.home-assistant.io/docs/development_environment/ does not work.

Conflicting requirements in HEAD for pyobjc means that you cannot successfully setup a dev environment

Installing collected packages: homeassistant
  Attempting uninstall: homeassistant
    Found existing installation: homeassistant 2022.12.0.dev0
    Uninstalling homeassistant-2022.12.0.dev0:
      Successfully uninstalled homeassistant-2022.12.0.dev0
  Running setup.py develop for homeassistant
Successfully installed homeassistant

[notice] A new release of pip available: 22.2.2 -> 22.3.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 581, in _build_master
    ws.require(__requires__)
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 909, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 800, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pyobjc-core 8.5.1 (/Users/jorhett/src/ha/venv/lib/python3.10/site-packages), Requirement.parse('pyobjc-core>=9.0'), {'pyobjc-framework-Cocoa'})

What version of Home Assistant Core has the issue?

HEAD of dev

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

Conflicting requirements prevent the development startup script from operating:

Installing collected packages: homeassistant
  Attempting uninstall: homeassistant
    Found existing installation: homeassistant 2022.12.0.dev0
    Uninstalling homeassistant-2022.12.0.dev0:
      Successfully uninstalled homeassistant-2022.12.0.dev0
  Running setup.py develop for homeassistant
Successfully installed homeassistant

[notice] A new release of pip available: 22.2.2 -> 22.3.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 581, in _build_master
    ws.require(__requires__)
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 909, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/jorhett/src/ha/venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 800, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pyobjc-core 8.5.1 (/Users/jorhett/src/ha/venv/lib/python3.10/site-packages), Requirement.parse('pyobjc-core>=9.0'), {'pyobjc-framework-Cocoa'})

The reason is a fairly simple conflicting set of requirements. You can't ask for >= 8.5.1 < 9.0 and also >= 9.0

$ grep -rH pyobjc-core .
./venv/lib/python3.10/site-packages/pyobjc_core-8.5.1.dist-info/METADATA:Name: pyobjc-core
./venv/lib/python3.10/site-packages/bleak-0.19.2.dist-info/METADATA:Requires-Dist: pyobjc-core (>=8.5.1,<9.0.0); platform_system == "Darwin"
./venv/lib/python3.10/site-packages/pyobjc_framework_libdispatch-8.5.1.dist-info/METADATA:Requires-Dist: pyobjc-core (>=8.5.1)
./venv/lib/python3.10/site-packages/pyobjc_framework_Cocoa-9.0.dist-info/METADATA:Requires-Dist: pyobjc-core (>=9.0)

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

rrooggiieerr commented 1 year ago

Just want to confirm that I'm facing the exact same problem on MacOS

that1matt commented 1 year ago

Having the same issue, but found a work around to at least start getting my development env working.

I added

pyobjc-framework-Cocoa==8.5.1

to homeassistant/package_constraints.txt.

This is my first python experience, and with that I have no idea if this is ideal, or if it will cause issues. So far, everything is working locally on my M1 MacBook.

jorhett commented 1 year ago

Deeply concerning that a broken setup isn't worthy of their attention, nor are CI tests to ensure setup isn't broken for others.

rrooggiieerr commented 1 year ago

@jorhett I agree! Maybe create a pull request with the workaround?

home-assistant[bot] commented 1 year ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (bluetooth) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `bluetooth` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign bluetooth` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


bluetooth documentation bluetooth source (message by IssueLinks)

jorhett commented 1 year ago

@jorhett I agree! Maybe create a pull request with the workaround?

The problem is that every time I do this, I lose many hours fixing something and then it's broken again later. The problem isn't any specific issue, it's that there are non-stop issues that prevent developers moving forward. Some care about preventing breaking changes needs to be taken.

So I've submitted a fix for this one. It will likely be ignored just like all my previous developer-setup fixes have been.

thecode commented 1 year ago

I am not using MAC OS, but I would highly suggest setting up a dev container, this should have identical results on any OS, I don't remember I ever had a requirements conflict. Note that not only as a developer, once you use Python code directly on OS, you are on your own resolving conflicts, I agree there should not be any conflicts, but the fact that no one reply here is that most core developers use the container and doesn't experience any problem.

rrooggiieerr commented 1 year ago

@thecode the conflict actually happens if you follow the official instructions on how to setup the development environment on MacOS: https://developers.home-assistant.io/docs/development_environment#developing-on-macos

jorhett commented 1 year ago

I can't use the devcontainer because I work on private projects, and thus cannot use Docker Desktop on my machine without paying for a license for myself and more than a thousand others I support.

Even though VScode supports Podman and even documents how to use it, @frenck has refused to accept PRs which mention Podman, and also PRs which try to solve problems with devcontainer startup. So it doesn't work unless you have a machine you can setup without any private development projects on it so as to comply with the Docker licensing terms.

So this is the only documented method. I've gone through a number of attempts to suggest other development environments, and as always @frenck will be insulting and rude -- as he was with the PR I created for this. I'm unwilling to keep losing tens of hours maintaining my own container environments that exhibit problems different than what others see.

A consistent, well-behaving development environment is the bedrock of enabling contributions. But until @frenck stops insulting everyone who tries to improve it, HA just burns the goodwill of people who want to help.

thecode commented 1 year ago

Just saw you edited your comment and I think there was already an argument about Podman, so now you waisted my time trying to help after it was already discussed in the past. I also don't like forcing people into issues by @ing them unless it really needed. I am closing and locking this issue with understanding that you find me rude not helping you but I don't want this discussion to continue. Please understand that this is not something that core devs should support. There are other workarounds for your issue and I am sure you know them already.

jorhett commented 1 year ago

I would highly suggest setting up a dev container

A devcontainer helps you run it, but does nothing for helping you run the units tests? The bugs I'm trying to address are in the unit tests as well as the code. The unit tests currently pass, but the code fails #70572. Fixes to the code fail the unit tests. The bugs with test environment setup are visible in the devcontainer too