Consider normalizing path separators in setenv for PATH variables

Issue #344 on hold
Łukasz Rogalski created an issue

Consider following extract from tox.ini:

setenv =

Path separator used for PYTHONPATH (and PATH variables) is platform specific - so invocation above would work on Windows but would not on POSIX system. While usually it's solved via testing matrix, I'm not sure if that's a correct approach here. User intention is to add multiple paths to environment variable, and copy-pasting same path list and changing only their separator is a clear violation of DRY.

I was thinking about few strategies:

  • always normalizing separators in PATH and PYTHONPATH variables (from colon or semicolon to os.pathsep). I'm not sure if it's smart to maintain any kind of whitelist in docs. Also, explicit is better than implicit, and here conversion would be performed implicitly.
  • export {os.pathsep} as possible substitute - explicit, easy, but results in kind of ugly looking tox.ini
  • add optional field in tox.ini env_path_vars = PATH,PYTHONPATH - normalization would be performed only for explicitly selected environment variables. It looks clean, but adds additional config parameter.

I'd be happy to implement any of these (if proposal will be accepted) - the question is, which proposal do you like the most?

Regards, Lukasz

Comments (6)

  1. Łukasz Rogalski reporter

    Hello, Any feedback on this proposal? Or should I just implement it, send pull request and wait for review?

  2. Holger Krekel repo owner

    Hey @rogalski -- only seeing it now, along with your PR.

    out of the three your third suggestion as implemented in the PR currently makes most sense to me.

    What do you think about a fourth option that directly introduces a new syntax to setenv? Maybe like PATH ~= {env:PATH}:{envbindir}, i.e. using ~= to indicate that the right hand side is using ":" as a separator and that it should be normalized to the platform. This is just a little addition to the docs and we have no "edge cases" like specification of variables that does not exist, things getting out of sync between env_path_vars and setenv because of different authors working on tox.ini etc.

    Wouldn't mind getting some feedback from @RonnyPfannschmidt @obestwalter or others as well.

  3. Łukasz Rogalski reporter

    I'm not sure if ~= is very intuitive. I think it would raise a lot of wtf? reactions, or maybe well, it's just one of those quirks you have to know about working with tox in a best case. And that just does not sound right...

    Let's wait for input from mentioned guys. I won't work on this PR till the end on September anyway.

    @hpk42 Thanks for comment!

  4. Log in to comment