tox icon indicating copy to clipboard operation
tox copied to clipboard

`get_python_info` didn't follow symlink

Open symwell opened this issue 3 years ago • 0 comments

tox broke a few times when get_python_info was passed a path that was a symbolic link (symlink).

https://github.com/tox-dev/tox/blob/717b7644a2376c0178ad293c41c76ff6631bdc46/src/tox/logs/env.py#L17

https://github.com/tox-dev/tox/blob/7aa130318d168ccc476d856ff7b1531bdaf263cc/src/tox/interpreters/via_path.py#L57

$ poetry run tox
python_executable is /home/test/src/appmap-python/.tox/.package/bin/python
{'executable': '/home/test/src/appmap-python/.tox/.package/bin/python', 'implementation': 'CPython', 'version_info': [3, 9, 14, 'final', 0], 'version': '3.9.14 (main, Sep 16 2022, 08:19:05) \n[GCC 9.4.0]', 'is_64': True, 'sysplatform': 'linux', 'os_sep': '/', 'extra_version_info': None}
python_executable is /home/test/src/appmap-python/.tox/py39-django32/bin/python
None
___________________________________________________________________________________ summary ____________________________________________________________________________________
  py39-django32: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "/home/test/.pyenv/versions/3.9.14/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/session/__init__.py", line 69, in main
    exit_code = session.runcommand()
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/session/__init__.py", line 197, in runcommand
    return self.subcommand_test()
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/session/__init__.py", line 225, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/session/commands/run/sequential.py", line 9, in run_sequential
    if venv.setupenv():
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/venv.py", line 677, in setupenv
    envlog.set_python_info(command_path)
  File "/home/test/.pyenv/versions/3.9.14/lib/python3.9/site-packages/tox/logs/env.py", line 20, in set_python_info
    answer["executable"] = python_executable
TypeError: 'NoneType' object does not support item assignment
ls -la /home/test/src/appmap-python/.tox/.package/bin/python 
lrwxrwxrwx 1 test test 47 Sep 20 12:28 /home/test/src/appmap-python/.tox/.package/bin/python -> /home/test/.pyenv/versions/3.9.14/bin/python3.9

To work around it I edited set_python_info and hardcoded the value of python_executable to the executable /home/test/.pyenv/versions/3.9.14/bin/python3.9.

symwell avatar Sep 21 '22 16:09 symwell