[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to determine lowest version of Python 3 to run?

On Thu, Oct 5, 2017 at 1:23 PM, Christopher Reimer
<christopher_reimer at icloud.com> wrote:
> Greetings,
> I've always installed the latest and greatest version of Python 3 to develop my own programs. I'm planning to release a program to the public. I could toss in a note that the program runs on the latest version of Python 3.6 but I haven't tested on earlier versions (i.e., 3.4 and 3.5). AFAIK, I haven't written any version-specific code.
> How do I determine the lowest version of Python to run?
> I'm leaning towards installing the latest minor version of each available major version, running tox to run the unit tests against each one, and seeing what blows up.

By "major" and "minor", do you mean that you're testing on the latest
"3.5" (currently 3.5.4)? Usually a three-part version number is
described as "Major.Minor.Revision" [1], so you're working with the
single major version "3".

My recommendation is to quote only two-part version numbers. Test on
the last few, then say "Requires Python 3.4 or greater" if that's how
far back you tested. Generally, you won't have to test on multiple
revisions of the same minor version; if it runs on 3.5.2, it should
run on 3.5.3 and 3.5.1, unless you depend on some specific bug that
got fixed.

And how many versions back should you test? If you want to be
thorough, look at which versions are still in support - either with
your OS repositories or at Python.org - and test on all of those. If
you're like me, though, just test on whichever ones you happen to have
around, and then quote that :)

You can shortcut this whole process, though, if you know for certain
that you've used a newly-added feature. For example, if your code
depends on the order of arguments in **kwargs, don't bother testing on
3.5 and getting flaky results - that changed in 3.6, so just quote
that you need 3.6+. If you use the matrix multiplication operator "@",
test on 3.5 and 3.6 and that's it. Obviously this only helps if you
KNOW about a new feature, but I've had a number of projects where I
get all excited about a flashy new feature and immediately start using
it... :)

Hope that helps!


[1] The music nerd in me wants "minor" to be lower-cased, but I told
me to shut up.