john-kurkowski/tldextract

version handling incompatible with `setuptools_scm` version 7

Closed this issue · 3 comments

pabs3 commented

The version handling in tldextract is no longer compatible with the default template for _version.py in setuptools_scm version 7, since it changed the default template from using version to __version__ in this commit:

pypa/setuptools-scm@b45e19f#diff-bdefa0298003efada7c465428643cc6d9c129168afb3eb5c551b40fcc77feac1

There are two ways you could handle this:

  • import __version__ when present or version otherwise
  • set the write_to_template parameter to setup() to use either version or __version__ and import that in the code

Personally I suggest the second one, since it is more future-proof.

pabs3 commented

Another option would be to not hard-code the version within _version.py but instead load it from the PEP-0566 metadata by using importlib:

https://github.com/pypa/setuptools_scm#retrieving-package-version-at-runtime

This is probably the best option.

How do you reproduce the incompatibility? Is it an uncaught error? For users? Contributors?

pabs3 commented

Sorry for the noise, looks like I misread the code and it is actually compatible, because setuptools_scm adds a backwards-compatibility variable. If it were actually incompatible, there would have been an uncaught error for users.

$ cat tldextract/_version.py 
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '3.3.1'
__version_tuple__ = version_tuple = (3, 3, 1)