[TIP] Tox and setup.py enforcing python version
Roy Wright
roy at wright.org
Tue Jun 2 16:22:16 PDT 2015
Thank you.
The [tox] section was from tox.ini.
I usually code for python2/3 compatibility but this app used a python3 only library. I just want the user to know that they need python3 for this utility.
Thank you!
A free society is a single class society where everyone has the same rights.
On Jun 2, 2015, at 2:25 PM, Florian Bruhin <me at the-compiler.org> wrote:
> * Roy Wright <roy at wright.org> [2015-06-02 14:14:54 -0500]:
>> Howdy,
>>
>> For my python3 apps I've been including the following to prevent them from being installed on python2:
>>
>> import sys
>> if sys.version_info < (3, 3):
>> print("appname requires python 3.3 or newer")
>> exit(-1)
>>
>> Now my system python is 2.7 (Ubuntu 14.04) so running tox will immediately fail even with:
>>
>> [tox]
>> envlist = py33,py34
>>
>> Removing the exit allows tox to run.
>
> Where did you add that? I guess to setup.py?
>
>> I'm just curious what is the best practice here? Run tox from python3 virtualenv? Let the user beware? Depend on classifiers?
>
> Being compatible with python3 only means you make life harder for
> contributors who are used to just being able to run 'tox'.
>
> I have some similar check, but at runtime[1]. This means installing
> will work, but at least when running it the user gets a clear error.
>
> Of course, this file must be python2 compatible, and everything
> imported/run before it at least not be a SyntaxError.
>
> [1] https://github.com/The-Compiler/qutebrowser/blob/master/qutebrowser/misc/checkpyver.py
>
> Florian
>
> --
> http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
> GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
> I love long mails! | http://email.is-not-s.ms/
More information about the testing-in-python
mailing list