简体   繁体   中英

Tox virtualenv confusion

Just starting out using tox for testing a library with Python 2.7 and 3.4. After using the following tox.ini file I had two questions:

[tox]
envlist = {py27,py3}
sitepackages = True

[testenv]
deps= -rrequirements.txt
commands = nosetests -w tests/ --with-coverage --cover-erase --cover-package=pyppa --with-xunit --xunit-file={toxinidir}/build/ppa-python-sdk_{envname}_unit_tests.xml
coverage xml -o {toxinidir}/build/{envname}_coverage.xml

After running tox I had the following questions:

  1. The project depends on numpy and scipy which are both installed in my global environment, I thought that using sitepackages = True in the tox.ini file would prevent tox from installing these in the virutalenvironment and force it to use those in the global environment but tox installed the latest versions in the .tox/ virtual environments for both 2.7 and 3. Am I misunderstanding the sitepackages directive?
  2. Looking underneath the .tox/ directory at the virtual environment directories I see the following (abbreviated) structure:

.

  .tox/
    py27/
      include/
        python2.7/
      lib
        python2.7/
      ...
    py3/
      include/
        python2.7/
      lib
        python2.7/
      ...

I assure you that this is not a typo. There are directories named python2.7 under the py3 virtual environment include and lib sub-directories and these are the only sub-directories in include and lib . Everything seems to work but I'm just curious as to why these directories are named this way. Can someone shed some light on this?

Thanks.

1) sitepackages isn't a global Tox setting. It's an environment setting, so put it under [testenv] .

2) py3 is not a predefined variant . Use py34 instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM