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

tox {[section]name} substitution does not work in general #97

Closed
pytoxbot opened this issue Sep 17, 2016 · 7 comments
Closed

tox {[section]name} substitution does not work in general #97

pytoxbot opened this issue Sep 17, 2016 · 7 comments

Comments

@pytoxbot
Copy link

@pytoxbot pytoxbot commented Sep 17, 2016

I am trying to reuse tox.ini with minimal changes between projects/packages - the only variation is in deps and the project/package name (see package section below). I want commands to be the same, so I tried to define an ini variable for package name and reference it from commands without success:

#!ini

[package]

name = whatever
deps =
    # package specific dependencies


[tox]

envlist = py27


[testenv]

deps =
    {[package]deps}

    # needed by commands
    nose
    coverage
    pep8
    pyflakes

commands =
    coverage erase
    coverage run {envbindir}/nosetests
    coverage report --show-missing --include={[package]name}/*
    pyflakes {[package]name}
    pep8 {[package]name}

I get tox.ConfigError: ConfigError: substitution key '[package]name' not found with this config.

It looks like the ini reading is restricted to known keys only ({[package]deps} in [testenv]deps works!), so it is currently not possible to introduce & reference new, unknown-to-tox, keys.

A potentially related issue is #38 {[section]name} subsitution does not work for commands

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @hpk42

Issue #38 was marked as a duplicate of this issue.

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @hpk42

Fix issue #97 {[section]name} substitution does not work in general

→ <<cset 5603e77786d8>>

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @e3krisztian

Sure, I have a working version, will request a review soon.

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @hpk42

yes, the config parsing needs to be generalized. Do you feel like giving it a stab?

@pytoxbot pytoxbot closed this Sep 17, 2016
@TheFriendlyCoder
Copy link

@TheFriendlyCoder TheFriendlyCoder commented Jun 28, 2017

I'm not sure if this improvement was completed or not, however in case anyone is interested I found a simple workaround to this limitation - at least for the limited use case described here. Consider the following snippet:

[testenv]
setenv = TOX_PACKAGE_NAME=mypackage
commands = pylint {env:TOX_PACKAGE_NAME}

By defining your desired parameters as environment variables, taking care to name them such that they don't conflict with any other vars in your build environment, you can then use the TOX environment variable substitution to refer to the values.

This might not work for the general case but should be workable for those simple cases like this one.

@obestwalter
Copy link
Member

@obestwalter obestwalter commented Aug 26, 2017

This should be kept open until configuration parsing is generalized (or we decide to leave it that way and then document the limitations).

@obestwalter obestwalter reopened this Aug 26, 2017
@obestwalter obestwalter changed the title tox 1.4.3 {[section]name} substitution does not work in general tox {[section]name} substitution does not work in general Aug 26, 2017
@gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented May 2, 2019

I think we fixed this now.

@gaborbernat gaborbernat closed this May 2, 2019
@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants