-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
[wip] Add environment variables to detect running from within tox (#847) #865
Conversation
Codecov Report
@@ Coverage Diff @@
## master #865 +/- ##
======================================
+ Coverage 92% 93% +<1%
======================================
Files 12 13 +1
Lines 2331 2344 +13
Branches 408 409 +1
======================================
+ Hits 2155 2169 +14
Misses 110 110
+ Partials 66 65 -1 |
Would it also make sense to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't read much after noticing this could be done today with setenv
.
another concern: there'd be no way to turn it off (?)
doc/overview.rst
Outdated
|
||
- ``TOX_WORK_DIR`` env var is set to the tox work directory | ||
- ``TOX_ENV_NAME`` is set to the current running tox environment name | ||
- ``TOX_ENV_DIR`` is set to the current tox environments working dir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make these consistent with the names that get substituted in the configuraiton? https://tox.readthedocs.io/en/latest/config.html?highlight=substitution#substitutions
particularly envname
but ENV_NAME
seems off to me
should we export all of these substitution parameters as well?
do we even need this feature? someone can setenv = TOX_ENV_NAME={envname}
already today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although one could do it partially with the setenv
as discussed in the related #847 it adds value to have a general env var name. This way the tools can use to detect if we're inside tox and users no longer need to keep copying around the same set env for their project.
Coming back to the setenv
I don't think that cuts it. Mostly because setenv is only applied to the current command. I think we want a higher level to be able to be detected by both the package builder and the installer. These are also tools which we invoke; we're not talking here just about commands. In light of this can you have another look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik setenv applies to all life cycles (I looked into this for tox-virtualenv-no-download)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, will double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's that analysis : asottile-archive/tox-virtualenv-no-download#4 (comment)
src/tox/config.py
Outdated
"LD_LIBRARY_PATH", | ||
"TOX_WORK_DIR", | ||
"TOX_ENV_NAME", | ||
"TOX_ENV_WORK_DIR", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, seems odd that they'd get whitelisted into passenv
as well -- I guess that's an order-of-operations issue probably? (depending on when the variables get set)
if we're going forward with this, can we make tox augment setenv
and then we don't need to worry about passenv
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I wanted these environment variables to be usable across the tool lifecycle, not just the commands section, I change the values in the os.environ
. As such in order for the commands to inherit it we need them to be in the whitelist.
@rpkilby I could see some people wanting the work dir too besides just are we inside tox (e.g. |
I definitely like the idea of doing this - I actually could swear that I opened an issue proposing this just after I joined the project but can't find it anymore ... Hi @gaborbernat I would really like to get my head around this PR first, so please wait for my feedback on this one. I would also propose not to add this to 3.1 yet. I think we have enough changes already to ship 3.1. We have some massive refactorings and there might be surprises, that are easier to catch, if we don't ship to many changes at once. |
Ok let's move it to 3.2. As such I'll delay working on this for later. |
Was there a problem with the changes? I did not get around to check this out yet. |
I did not get around to finish this. Will re-open later on; but given it's part of 3.2 can wait for now to fix the latest release. |
TOX_WORK_DIR
for session runs (only this set during packaging)TOX_ENV_NAME
andTOX_ENV_WORK_DIR
during the execution of a given virtual environmentResolves #847.