.tox dir cannot be a symlink to a dir

Issue #178 on hold
Martin Dengler created an issue

A combination of tox/_cmdline.py's

config.logdir.ensure(dir=1)

and py/_path/local.py's

if kwargs.get('dir'), 0

(LocalPath.ensure) logic means that if .tox is a symlink, "python -m tox" will fail with:

Traceback (most recent call last):
  File "C:\python\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\python\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\python\lib\site-packages\tox\__main__.py", line 3, in <module>
    main()
  File "C:\python\lib\site-packages\tox\_cmdline.py", line 26, in main
    retcode = Session(config).runcommand()
  File "C:\python\lib\site-packages\tox\_cmdline.py", line 254, in __init__
    config.logdir.ensure(dir=1)
  File "C:\python\lib\site-packages\py\_path\local.py", line 481, in ensure
    return p._ensuredirs()
  File "C:\python\lib\site-packages\py\_path\local.py", line 463, in _ensuredirs
    parent._ensuredirs()
  File "C:\python\lib\site-packages\py\_path\local.py", line 466, in _ensuredirs
    self.mkdir()
  File "C:\python\lib\site-packages\py\_path\local.py", line 434, in mkdir
    py.error.checked_call(os.mkdir, getattr(p, "strpath", p))
  File "C:\python\lib\site-packages\py\_error.py", line 84, in checked_call
    raise cls("%s%r" % (func.__name__, args))
py.error.EEXIST: [File exists]: mkdir('<projectdir>\\.tox',)

Comments (4)

  1. Martin Dengler reporter

    I'm not sure where the best place for the fix is, otherwise I would've proposed a patch. If you have a preference I can certainly put something together.

  2. Martin Dengler reporter

    I should probably state I'm seeing this behaviour on windows, running under cygwin. The problem might be exacerbated by the strangeness of islink() in this situation:

    $ ls -la .tox
    lrwxrwxrwx 1 mdengler Domain Users 22 Jun  9 13:14 .tox -> /cygdrive/ramdisk/tox/project/
    $ python
    Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import py._path.local
    >>> p = py._path.local.LocalPath("C:\src\project\\.tox")
    >>> p.islink()
    False
    >>>
    
  3. Log in to comment