How to limit my Anki add-on Version Support

I am new to writing add-ons.
How would I go about limiting my add-on, to say, Anki version 2.1.35 and have it not function on newer versions?

Thanks!

One way to do this is to use anki.version:

from anki import version

p = int(version.split(".")[-1])
if p > 35:
	# not supported
else:
	# do something

Or, If you’re distributing the add-on as a .ankiaddon file, you can use the min_point_version key in the manifest file to make Anki refuse to install the add-on altogether on incompatible versions and notify the user.
See https://github.com/ankitects/anki/blob/56ac71ffb62cbf2a9ca5613415341716c75c99aa/qt/aqt/addons.py#L161

AnkiWeb also provides a way to set the minimum version (I think it results in the same behavior as installing from .ankiaddon files though I’m not sure.)

5 Likes

Thank you for the quick answer, much appreciated!