[TIP] Tox and setup.py enforcing python version

Florian Bruhin me at the-compiler.org
Wed Jun 3 11:28:50 PDT 2015


* Barry Warsaw <barry at python.org> [2015-06-03 14:01:46 -0400]:
> On Jun 03, 2015, at 08:12 AM, Florian Bruhin wrote:
> 
> >Note only the setup.py has to be syntax-compatible!
> 
> Why should that matter?  I'm asking philosophically, since a project's
> setup.py *should* be independent of whatever Python the tox application is
> invoked with.

Well, mainly because it *doesn't work* if a python2 tox is running ;)

It runs the setup.py with python2 (at least on the version shipped
with Ubuntu Trusty):


=== setup.py ===
#!/usr/bin/python3

from setuptools import setup
import platform

with open('setup_ver', 'w') as f:
    f.write("setup.py: %s\n" % platform.python_version())

setup(
    name='testver',
    py_modules=['testver'],
    entry_points={'testver': ['testver = testver']},
)


=== tox.ini ===
[tox]
envlist = py34

[testenv]
commands = {envpython} printver.py


=== printver.py ===
import platform
print(platform.python_version())


=== terminal session ===
$ tox --version
1.6.0 imported from /usr/lib/python2.7/dist-packages/tox/__init__.pyc

$ tox
GLOB sdist-make: /home/florian/tm/setup.py
py34 inst-nodeps: /home/florian/tm/.tox/dist/testver-0.0.0.zip
py34 runtests: commands[0] | /home/florian/tm/.tox/py34/bin/python printver.py
3.4.0
______________________ summary ______________________
  py34: commands succeeded
  congratulations :)

$ cat setup_ver
setup.py: 2.7.6



Am I missing something? At least for my project, tox failed on Ubuntu Trusty
because of that.

> >Note neither Debian nor Ubuntu have a package for a python3 tox:
> 
> Correct.  We don't package tox as a library so we don't have Python 2 and 3
> versions of it.  It's a leaf application so the shebang *should* be
> independent of whatever Python versions it supports.  We shebang /usr/bin/tox
> to Python 3.

Oh, I wasn't aware of that - seems it's only Trusty which is actually using
python 2 for it.

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/20150603/d437f436/attachment.pgp>


More information about the testing-in-python mailing list