[TIP] Tox and setup.py enforcing python version

Florian Bruhin me at the-compiler.org
Tue Jun 2 12:25:43 PDT 2015


* 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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150602/de20560f/attachment.pgp>


More information about the testing-in-python mailing list