Skip to content

Fix Tox configuration issue #9844

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

Closed
wants to merge 1 commit into from
Closed

Fix Tox configuration issue #9844

wants to merge 1 commit into from

Conversation

agjohnson
Copy link
Contributor

@agjohnson agjohnson commented Dec 23, 2022

I was getting errors from Tox about base_path replacement not
existing. This was using inv docker.test, so I don't think this is
limited to me.

inv docker.test -a "-e py310 -- -k ProjectsEndpointTests"             
Traceback (most recent call last):
  File "/usr/local/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/usr/local/lib/python3.10/dist-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/usr/local/lib/python3.10/dist-packages/tox/session/__init__.py", line 65, in main
    config = load_config(args)
  File "/usr/local/lib/python3.10/dist-packages/tox/session/__init__.py", line 81, in load_config
    config = parseconfig(args)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 299, in parseconfig
    ParseIni(config, config_file, content)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1323, in __init__
    raise tox.exception.ConfigError(
tox.exception.ConfigError: ConfigError: migrations failed with ConfigError: substitution key 'base_python' not found at Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1299, in run
    results[name] = cur_self.make_envconfig(name, section, subs, config)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1475, in make_envconfig
    res = meth(env_attr.name, env_attr.default, replace=replace)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1772, in getargvlist
    return _ArgvlistReader.getargvlist(self, s, replace=replace, name=name)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 2036, in getargvlist
    commands.append(cls.processcommand(reader, current_command, replace, name=name))
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 2062, in processcommand
    new_word = reader._replace(word, name=name)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1857, in _replace
    replaced = Replacer(self, crossonly=crossonly).do_replace(value)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1893, in do_replace
    expanded = substitute_once(value)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1891, in substitute_once
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1964, in _replace_match
    return self._replace_substitution(sub_value)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1999, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/local/lib/python3.10/dist-packages/tox/config/__init__.py", line 1994, in _substitute_from_other_section
    raise tox.exception.ConfigError("substitution key {!r} not found".format(key))
tox.exception.ConfigError: ConfigError: substitution key 'base_python' not found

I was getting errors from Tox about `base_path` replacement not
existing. This was using `inv docker.test`, so I don't think this is
limited to me.
@agjohnson agjohnson requested a review from a team as a code owner December 23, 2022 21:57
@agjohnson agjohnson requested a review from stsewd December 23, 2022 21:57
@humitos
Copy link
Member

humitos commented Dec 24, 2022

I don't think this is
limited to me.

Yeah, I've also got this errors. However, I didn't debug it 😅 . I suppose your PR is fine 👍🏼

Copy link
Contributor

@benjaoming benjaoming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like another fall-out of the Tox 4 upgrade. I don't think it seems very well documented. In general, it seems like a lot of substitution variables with underscores _ have the underscore as an option but that the version without the underscore is the "main" documented variable name.

The Tox documentation does, however, still casually mention the "aliases" with underscores around in their docs.

https://tox.wiki/en/latest/config.html#python-options

https://tox.wiki/en/latest/faq.html#new-features-in-tox-4

It could appear like the base_python isn't set automatically anymore from the environment, but only basepython is... even though base_python is documented to resolve the same way.

@benjaoming
Copy link
Contributor

What made me suspicious that it's a Tox 4 regression is this entry in the release FAQ:

basepython is now a list, the first successfully detected python will be used to generate python environment.

@stsewd
Copy link
Member

stsewd commented Jan 3, 2023

Also, weird that this works on our CI, guess the update that @benjaoming mentioned, or you may need to rebuild your docker env to install the latest version of tox.

@agjohnson
Copy link
Contributor Author

or you may need to rebuild your docker env to install the latest version of tox.

These tests were in Docker, via inv docker.test, so it should be up to date, no?

@stsewd
Copy link
Member

stsewd commented Jan 3, 2023

These tests were in Docker, via inv docker.test, so it should be up to date, no?

That command makes use of the web container, after requirements are updated, you need to run inv docker.build. I run the command without this patch and it worked.

root@191d3c567ae8:/usr/src/app/checkouts/readthedocs.org# tox --version
4.0.14 from /usr/local/lib/python3.10/dist-packages/tox/__init__.py

@agjohnson
Copy link
Contributor Author

Confirmed, another rebuild does resolve the issue, without this PR.

I came across this in #9843, where I needed to docker.build no less than 5 times to get my environment working, so not sure why this was missing.

@agjohnson agjohnson closed this Jan 3, 2023
@benjaoming benjaoming deleted the agj/tox-more-fixes branch January 3, 2023 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants