talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
427 stars 97 forks source link

Fix pypi wheel build (incorrect version of `opencv`) #1719

Closed roomrys closed 5 months ago

roomrys commented 6 months ago

With some changes to our dependencies from this commit (PR #1623), we now have less restrictions on the version/flavor of opencv that is pulled in from our dependencies. Which is great!

For example, before freeing up the version/flavor of opencv, we needed to do this weird work-around to develop the multiview GUI (which depends on sleap-anipose which depends on aniposelib with also depends on a pinned version/flavor of opencv). The hope is that #1623 will allow us to pin the version/flavor to opencv-contrib-python<4.7.0 without issue. https://github.com/talmolab/sleap/blob/0230a97d677be8429fa7c1ccb43de31284c6f28b/environment.yml#L50-L51

But, with great power comes great responsibility - and the dependency range on opencv is now giving pypi too much freedom/power to decide which version of opencv to use. In fact, now we run into errors when just trying to import opencv!

The problem here could be two things:

  1. The range of versions we pin for opencv is wrong and we need to specify opencv-contrib-python<4.7.0 in the pypi requirments. https://github.com/talmolab/sleap/blob/eb147646a79d057b508d7cbfa8f4c5e158601104/pypi_requirements.txt#L14
  2. One of our dependencies (or dependencies of dependencies) also depends on opencv and pins the wrong (or too broad) range for opencv.

The solution would be to first try pinning the desired version of opencv-contrib-python<4.7.0 in our pypi_requirements.txt and see if the building the pypi wheel now works (checkout how we build it in our actions to test it yourself manually). If that doesn't work, it's going to get messy - we need to find which one of our dependencies requires a conflicting version of opencv and basically figure out a way around this.

talmo commented 5 months ago

This is now resolved with #1724 + #1726 + https://github.com/talmolab/conda_packages/pull/2, which combined allow us to use the conda-forge::opencv package up to 4.8.x. In addition to getting rid of the PyPI version of opencv-python, this conda package also ships with ffmpeg and contrib. It also shims opencv-python, opencv-python-headless and the contrib variants so the PyPI versions don't get pulled in.

Note: We still need to move the new sleap::tensorflow package from sleap/label/dev to sleap/label/main when we release 1.4.0, but for now, this new setup works like this using the current environment.yml.