Issues

Issue #55 wontfix

FEATURE: Simple python2/python3 support for tox

jenisys
created an issue

tox needs a simple python2/python3 support. Yes, tox supports python2 and python3 tests in principle, but does not address 2to3/3to2 conversion issues of test directories, etc. All solutions that I have currently seen are more complicated than needed or not cross-platform independent. Supporting python3 often involves copying tests directories. etc. recursively and manually converting these directories with 2to3. This is unnecessary complicated for a task that tox tries to solve in a simple way.

NEEDED TASKS

  • Command: Copy a directory tree recursively to virtual-environment in a cross-plattform way
  • Apply 2to3/3to2 to a directory tree (can already be done, but w/ tox warnings because scripts are not installed in {envbindir} directory)
  • MAYBE: Install the sdist-package in the virtual-environment (as sources with tests)
  • Add a postenvsetup_command option or similar to apply commands to the virtual-environment before tests are run. This helps to avoid code-duplication between commands option in py2x/py3x testenvs.

BACKGROUND: Many projects use the {toxinidir} subdirectories directly (or by accident, issue #54). This is dangerous when 2to3 should be applied when running py2x/py3xtest environments because the development code is modified.

MINIMAL SOLUTION (as long as this feature is not provided): Several scenarios/examples how to really handle both python2 and python3 environments should be documented. AFAIK the simple examples in the documentation do not address realistic scenarios.

Comments (3)

  1. Chris Jerdonek

    I don't see why this isn't already supported via Distribute's use_2to3 keyword argument to setup(). If Distribute does the conversion from 2 to 3, then that automatically takes care of it for tox (at least the main use cases).

  2. jenisys reporter

    The problem is not the python package that gets packaged with setup.py and installed in the tox's virtual environment for this Python interpreter version. Therefore, this part is converted automatically with the 2to3 tool.

    The problem is the test suite that is colocated to the python package dir (which is often the case). Therefore, it will not get installed automatically into the virtual environment under site-packages/. In most cases the original test suite (outside of the virtual environment) is used to run the tests. This test suite depends on the fact if Python2 or Python3 is the primary supported version. Therefore, it will often fail for Python3 (in my cases). In addition, you don't want to modify it in its original location (with the 2to3 tool). Therefore, you need commands to copy the test suite into the virtual environment and apply the 2to3 tool to the copied dir-tree.

    This correlates with your suggestion in #83 when the sdist package is completely installed in the virtual environment. The only complexity that I see is that an unzipped sdist-package normally creates a versioned root directory. Therefore, you need to figure out in tox.ini what the name of the root directory is (for changedir or run args) or use placeholders (if that works).

  3. holger krekel repo owner

    given that nowadays single source is what is recommended for py2/py3 compatibility i am not going to work on making 2to3 easier unless there is a real need.

  4. Log in to comment