Octoprint 1.11.7 upgrade, setuptools, pkg_resources and plugins

What is the problem?

Some plugins fail to load/work after an upgrade to 1.11.7, because setuptools is upgraded too (to 82.0.0)

What did you already try to solve it?

The pkg_resources package is not present anymore in setuptools 82.0.0 (it may have disappeared on an earlier release). So any plugin that still requires pkg_resource will fail to load.

Currently (as far as the plugins I use) :

  • PrintTimeGenius (solved with the 2.4.2 release)
  • ExcludeRegion (as an aside, is this plugin alive ?)

For ExcludeRegion, either disable the plugin, or patch it :

*** OctoPrint-ExcludeRegionPlugin-master/octoprint_excluderegion/__init__.py    2022-12-08 01:55:45.000000000 +0100
--- OctoPrint-ExcludeRegionPlugin-master.nv/octoprint_excluderegion/__init__.py 2026-02-24 23:07:54.504434800 +0100
***************
*** 38,45 ****
  import flask
  from flask_login import current_user
  
- import pkg_resources
- 
  import octoprint.plugin
  from octoprint.events import Events
  from octoprint.settings import settings
--- 38,43 ----
***************
*** 162,179 ****
  
      def get_assets(self):
          """Define the static assets the plugin offers."""
-         octoprintVersion = pkg_resources.parse_version(octoprint.__version__)
  
          jsFiles = ["js/excluderegion.js"]
  
-         # The modified gcode renderer is not needed for 1.3.10rc1 and above
-         if (octoprintVersion < pkg_resources.parse_version("1.3.10rc1")):
-             self._logger.info(
-                 "Octoprint {} is pre 1.3.10rc1, including renderer.js to override gcode viewer",
-                 octoprint.__display_version__
-             )
-             jsFiles.insert(0, "js/renderer.js")
- 
          return dict(
              js=jsFiles,
              css=["css/excluderegion.css"]
--- 160,168 ----

I also just pushed a new version of the octoprint_setuptools package that some plugins might have used as their build-time dependency and which still depended on pkg_resources. It's no longer recommended to use this build-time dependency, and it never looked like it was used a lot, but just in case, that's now fixed.

In any case, plugin maintainers need to maintain their plugins too. Including testing them regularly (manually or automatically through CI).

I cannot fix everything from within OctoPrint. pkg_resources has thrown deprecation warnings for a while which is why I threw all of that stuff out of core OctoPrint and bundled plugins a while ago. Pinning setuptools to a version still containing pkg_resources, as was suggested on Discord the other day, would only lead to tech debt on OctoPrint's end - and I'm actually trying to get rid of tech debt where I can, as it leads to a ton of overhead that I can no longer handle due to the speedup of Python's and its ecosystem's life cycle.