Skip to content

Commit

Permalink
Add PROGRAM environment variables on Windows (#2383)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco authored Mar 22, 2022
1 parent eb1bd33 commit 00a9695
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Isaac Pedisich
Itxaka Serrano
Jake Windle
Jannis Leidel
Jason R. Coombs
Jesse Schwartzentruber
Joachim Brandon LeBlanc
Johannes Christ
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/2382.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On Windows ``PROGRAMFILES``, ``PROGRAMFILES(X86)``, and ``PROGRAMDATA`` environment variables are now passed through, unmasking system values necessary to locate resources such as a C compiler.
3 changes: 2 additions & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ Complete list of settings that you can put into ``testenv*`` sections:
``REQUESTS_CA_BUNDLE``, ``SSL_CERT_FILE``,
``HTTP_PROXY``, ``HTTPS_PROXY``, ``NO_PROXY``
* Windows: ``SYSTEMDRIVE``, ``SYSTEMROOT``, ``PATHEXT``, ``TEMP``, ``TMP``
``NUMBER_OF_PROCESSORS``, ``USERPROFILE``, ``MSYSTEM``
``NUMBER_OF_PROCESSORS``, ``USERPROFILE``, ``MSYSTEM``,
``PROGRAMFILES``, ``PROGRAMFILES(X86)``, ``PROGRAMDATA``
* Others (e.g. UNIX, macOS): ``TMPDIR``

You can override these variables with the ``setenv`` option.
Expand Down
4 changes: 4 additions & 0 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ def passenv(testenv_config, value):
passenv.add("PROCESSOR_ARCHITECTURE") # platform.machine()
passenv.add("USERPROFILE") # needed for `os.path.expanduser()`
passenv.add("MSYSTEM") # fixes #429
# PROGRAM* required for compiler tool discovery #2382
passenv.add("PROGRAMFILES")
passenv.add("PROGRAMFILES(X86)")
passenv.add("PROGRAMDATA")
else:
passenv.add("TMPDIR")

Expand Down
6 changes: 6 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,9 @@ def test_passenv_as_multiline_list(self, newconfig, monkeypatch, plat):
assert "PROCESSOR_ARCHITECTURE" in envconfig.passenv
assert "USERPROFILE" in envconfig.passenv
assert "MSYSTEM" in envconfig.passenv
assert "PROGRAMFILES" in envconfig.passenv
assert "PROGRAMFILES(X86)" in envconfig.passenv
assert "PROGRAMDATA" in envconfig.passenv
else:
assert "TMPDIR" in envconfig.passenv
if sys.platform != "win32":
Expand Down Expand Up @@ -1562,6 +1565,9 @@ def test_passenv_as_space_separated_list(self, newconfig, monkeypatch, plat):
assert "SYSTEMROOT" in envconfig.passenv
assert "TEMP" in envconfig.passenv
assert "TMP" in envconfig.passenv
assert "PROGRAMFILES" in envconfig.passenv
assert "PROGRAMFILES(X86)" in envconfig.passenv
assert "PROGRAMDATA" in envconfig.passenv
else:
assert "TMPDIR" in envconfig.passenv
assert "PATH" in envconfig.passenv
Expand Down

0 comments on commit 00a9695

Please sign in to comment.