Pinning package versions

Hi, I have a snap that is producing an obsolescence warning:

UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

Does anyone know of the best way to a). pin the version in my snapcraft.yaml file and b). suppress the warning?

Thanks.

Hi @mikecw!

Are you able to share the project? If not, what language is the project and are you able to send a sanitized project file?

Yeah sure, it doesn’t even need to be sanitised. It’s the Landscape Client Snap - we recently migrated it from using distutils to setuptools in order to build the Core24 based version. That’s what then brought up the message about pinning versions.

The preferred solution would be to remove the Zope dependency but that’s a bit of a bigger task…

Anyway… GitHub - canonical/landscape-client: The Landscape Client is the agent which communicates with the Landscape service.

Thanks

Is this a build-time or run-time warning for you?

If the error message is coming from Zope, I think your best option is to silence the warning where it surfaces with something like contextlib.suppress or warnings.simplefilter. That deprecation came in Python 3.12, which is almost certainly going to be at least as big of a headache to change as removing the dependency would be.

I don’t believe there’s anything unique to Snapcraft that could work around this, unfortunately.

It’s a runtime warning. Thanks anyway, I suspected there may not be a mechanism to deal with the message. We need to remove Zope as soon as we can though… it’s one of those “on the list” jobs.