Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot substitute install_command from another section (regression in 3.21.0) #1777

Closed
vytas7 opened this issue Jan 8, 2021 · 7 comments · Fixed by #1801
Closed

Cannot substitute install_command from another section (regression in 3.21.0) #1777

vytas7 opened this issue Jan 8, 2021 · 7 comments · Fixed by #1801
Assignees
Labels
bug:normal affects many people or has quite an impact

Comments

@vytas7
Copy link

vytas7 commented Jan 8, 2021

Consider the following tox.ini in an otherwise empty directory:

[tox]
envlist = py38
skipsdist = True

[base]
install_command = python -m pip install {opts} {packages}

[testenv]
install_command = {[base]install_command}
commands =
    python -c 'print("Hi there ;-)")'
$ tox --version
3.21.0 imported from /tmp/venv/lib/python3.8/site-packages/tox/__init__.py

Observed result

Cannot substitute install_command from the [base] section:

$ tox -rvv
using tox.ini: /tmp/test/tox.ini (pid 8575)
  removing /tmp/test/.tox/log
Traceback (most recent call last):
  File "/tmp/venv/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/tmp/venv/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/tmp/venv/lib/python3.8/site-packages/tox/session/__init__.py", line 65, in main
    config = load_config(args)
  File "/tmp/venv/lib/python3.8/site-packages/tox/session/__init__.py", line 81, in load_config
    config = parseconfig(args)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 280, in parseconfig
    ParseIni(config, config_file, content)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1276, in __init__
    raise tox.exception.ConfigError(
tox.exception.ConfigError: ConfigError: py38 failed with ConfigError: substitution key 'opts' not found at Traceback (most recent call last):
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1252, in run
    results[name] = cur_self.make_envconfig(name, section, subs, config)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1407, in make_envconfig
    res = meth(env_attr.name, env_attr.default, replace=replace)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1716, in getargv_install_command
    return _ArgvlistReader.getargvlist(self, s, replace=replace, name=name)[0]
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1946, in getargvlist
    commands.extend(cls.getargvlist(reader, replaced, name=name))
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1948, in getargvlist
    commands.append(cls.processcommand(reader, current_command, replace, name=name))
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1974, in processcommand
    new_word = reader._replace(word, name=name)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1782, in _replace
    replaced = Replacer(self, crossonly=crossonly).do_replace(value)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1818, in do_replace
    expanded = substitute_once(value)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1816, in substitute_once
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1876, in _replace_match
    return self._replace_substitution(sub_value)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1911, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/tmp/venv/lib/python3.8/site-packages/tox/config/__init__.py", line 1906, in _substitute_from_other_section
    raise tox.exception.ConfigError("substitution key {!r} not found".format(key))
tox.exception.ConfigError: ConfigError: substitution key 'opts' not found

Expected result

$ tox --version
3.20.1 imported from /tmp/venv/lib/python3.8/site-packages/tox/__init__.py

$ tox -r
py38 recreate: /tmp/test/.tox/py38
py38 run-test-pre: PYTHONHASHSEED='1073641419'
py38 run-test: commands[0] | python -c 'print("Hi there ;-)")'
Hi there ;-)
___________________________________________________________________________ summary ____________________________________________________________________________
  py38: commands succeeded
  congratulations :)

@vytas7 vytas7 added the bug:normal affects many people or has quite an impact label Jan 8, 2021
@gaborbernat
Copy link
Member

Thanks for reporting it, if you have time feel free to open a PR fixing it 👍

@vytas7
Copy link
Author

vytas7 commented Jan 8, 2021

Heh, thanks for the invitation. And thanks for maintaining tox!
But I'm afraid I'm unable to spare the time right now.

@jayvdb
Copy link

jayvdb commented Jan 8, 2021

I'll take a look at this, as it looks like a bug in one of my changes.

kgriffs added a commit to kgriffs/falcon that referenced this issue Jan 9, 2021
kgriffs added a commit to kgriffs/falcon that referenced this issue Jan 9, 2021
vytas7 pushed a commit to falconry/falcon that referenced this issue Jan 9, 2021
@jayvdb
Copy link

jayvdb commented Jan 10, 2021

I've got a fix together - just needs a bit more polish. Will have it up today.

jayvdb added a commit to jayvdb/tox that referenced this issue Jan 11, 2021
jayvdb added a commit to jayvdb/tox that referenced this issue Jan 11, 2021
This was removed in e4d0d60, and replaced with a
neater approach, however the newer approach doesnt
work for replacements from other sections.

Fixes tox-dev#1777
jayvdb added a commit to jayvdb/tox that referenced this issue Jan 11, 2021
This was removed in e4d0d60, and replaced with a
neater approach, however the newer approach doesnt
work for replacements from other sections.

Fixes tox-dev#1777
@jayvdb jayvdb mentioned this issue Jan 11, 2021
6 tasks
@jayvdb jayvdb mentioned this issue Jan 11, 2021
6 tasks
@jayvdb
Copy link

jayvdb commented Jan 11, 2021

@gaborbernat , this should be closed now. Not sure why the commit message didnt auto-close it.

@jayvdb
Copy link

jayvdb commented Jan 11, 2021

Actually it looks like a force push has deleted that commit (da140fb) on master.

jayvdb added a commit to jayvdb/tox that referenced this issue Jan 11, 2021
jayvdb added a commit to jayvdb/tox that referenced this issue Jan 11, 2021
This was removed in e4d0d60, and replaced with a
neater approach, however the newer approach doesnt
work for replacements from other sections.

Fixes tox-dev#1777
gaborbernat pushed a commit that referenced this issue Jan 12, 2021
gaborbernat pushed a commit that referenced this issue Jan 12, 2021
This was removed in e4d0d60, and replaced with a
neater approach, however the newer approach doesnt
work for replacements from other sections.

Fixes #1777
@gaborbernat
Copy link
Member

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
ssbarnea pushed a commit to ssbarnea/tox that referenced this issue Apr 19, 2021
This was removed in e4d0d60, and replaced with a
neater approach, however the newer approach doesnt
work for replacements from other sections.

Fixes tox-dev#1777
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants