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

envbindir substitution key not found #246

Closed
pytoxbot opened this Issue Sep 17, 2016 · 8 comments

Comments

Projects
None yet
1 participant
@pytoxbot

pytoxbot commented Sep 17, 2016

If tox.ini has {envbindir} you get an exception
tox.ConfigError: ConfigError: substitution key 'envbindir' not found

{envbindir} works with tox<2.0 and it's in the docs:
http://tox.readthedocs.org/en/latest/config.html#substitutions-for-virtualenv-related-sections

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @hpk42

mention of fix issue246: fix regression in config parsing by reordering
such that {envbindir} can be used again in tox.ini. Thanks Olli Walsh.

→ <<cset 7e30b4b4591b>>

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @hpk42

Reorder the processing of testenv options. Fixes issue #246

→ <>

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by olliewalsh

Fixed in pull request #167

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @The-Compiler

I don't really know how to fix this, as I don't fully understand the change in 7f1bcc9.

I tried this, but it broke pretty much everything ;)

diff -r 6d4378ce9062 tox/config.py
--- a/tox/config.py     Mon Jun 15 14:36:26 2015 +0200
+++ b/tox/config.py     Mon Jun 15 17:21:55 2015 +0200
@@ -682,6 +682,8 @@
         vc = TestenvConfig(config=config, envname=name, factors=factors, reader=reader)
         reader.addsubstitutions(**subs)
         reader.addsubstitutions(envname=name)
+        reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython,
+                                envsitepackagesdir=vc.envsitepackagesdir)

         for env_attr in config._testenv_attr:
             atype = env_attr.type
@@ -702,9 +704,6 @@
             if atype == "path":
                 reader.addsubstitutions(**{env_attr.name: res})

-            if env_attr.name == "install_command":
-                reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython,
-                                        envsitepackagesdir=vc.envsitepackagesdir)
         return vc

     def _getenvdata(self, reader):

I also have a test case for this bug, which passes with 1.9.2 and fails with 2.0.x:

diff -r 6d4378ce9062 tests/test_config.py  
--- a/tests/test_config.py      Mon Jun 15 14:36:26 2015 +0200  
+++ b/tests/test_config.py      Mon Jun 15 17:00:22 2015 +0200
@@ -864,6 +864,18 @@
         assert argv[7][0] == config.homedir.join(".tox", "distshare")
         assert argv[8][0] == conf.envlogdir

+    def test_substitution_notfound_issue246(tmpdir, newconfig):  
+        config = newconfig("""
+            [testenv:py27]
+            setenv =  
+                FOO={envbindir}  
+                BAR={envsitepackagesdir}
+        """)
+        conf = config.envconfigs['py27']
+        env = conf.setenv
+        assert 'FOO' in env
+        assert 'BAR' in env
+
     def test_substitution_positional(self, newconfig):
         inisource = """
             [testenv:py27] 
@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @The-Compiler

This is caused by the changes in 7f1bcc9.

I might give fixing this a try later this or next week, but I'm a bit busy right now - so I hope someone else will have the time to look at it :)

@pytoxbot pytoxbot closed this Sep 17, 2016

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @bukzor

This prevents me from using tox>=2 whatsoever.

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @The-Compiler

I can confirm. I currently use {envdir}/Lib/site-packages instead because I only need it to set an environment variable which is only needed on Windows.

@pytoxbot

This comment has been minimized.

pytoxbot commented Sep 17, 2016

Original comment by @bukzor

{envsitepackagesdir} has the same problem. It's almost certainly the same bug.

#!python

| setenv =
|     TOP={toxinidir}
|     PROJECT={[tox]project}
|     SITEPACKAGES={envsitepackagesdir}
#!python

$ tox -l
Traceback (most recent call last):
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/session.py", line 38, in main
    config = prepare(args)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/session.py", line 26, in prepare
    config = parseconfig(args)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 219, in parseconfig
    parseini(config, inipath)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 661, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 689, in make_envconfig
    res = meth(env_attr.name, env_attr.default)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 822, in getdict
    s = self.getstring(name, None)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 876, in getstring
    x = self._replace(x)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 972, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 968, in _replace_match
    return handler(match)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 938, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/config.py", line 932, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'envsitepackagesdir' not found

$ tox --version
2.0.1 imported from /nail/home/buck/trees/yelp/venv-update/venv-venv_update/lib/python2.7/site-packages/tox/__init__.pyc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment