Skip to content

Commit 2ce4d89

Browse files
authored
Add more c-extension env-vars to default pass_env (#2818)
1 parent a906a2a commit 2ce4d89

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

docs/changelog/2818.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add ``CC``, ``CFLAGS``, ``CCSHARED``, ``CXX``, ``CPPFLAGS``, ``LDFLAGS``, ``PKG_CONFIG`` and ``PKG_CONFIG_SYSROOT_DIR``
2+
to the default passed through environment variables list as these are needed for building various C-extensions
3+
- by :user:`gaborbernat`.

src/tox/tox_env/api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ def _default_pass_env(self) -> list[str]:
211211
"LANGUAGE", # localization
212212
"CURL_CA_BUNDLE", # curl certificates
213213
"SSL_CERT_FILE", # https certificates
214+
"CC", # C compiler command
215+
"CFLAGS", # C compiler flags
216+
"CCSHARED", # compiler flags used to build a shared library
217+
"CXX", # C++ compiler command
218+
"CPPFLAGS", # C++ compiler flags
214219
"LD_LIBRARY_PATH", # location of libs
220+
"LDFLAGS", # linker flags
215221
]
216222
if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM
217223
env.append("TERM")

src/tox/tox_env/python/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def _default_pass_env(self) -> list[str]:
118118
"NUMBER_OF_PROCESSORS", # multiprocessing.cpu_count()
119119
],
120120
)
121-
env.extend(["PKG_CONFIG_PATH"]) # used by binary extensions during installation
121+
binary_extension_build = ["PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
122+
env.extend(binary_extension_build) # used by binary extensions during installation
122123
env.extend(["REQUESTS_CA_BUNDLE"])
123124
return env
124125

tests/session/cmd/test_show_config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
115115
pass_env = outcome.env_conf("py")["pass_env"]
116116
is_win = sys.platform == "win32"
117117
expected = (
118-
(["COMSPEC"] if is_win else [])
119-
+ ["CURL_CA_BUNDLE", "LANG", "LANGUAGE", "LD_LIBRARY_PATH"]
118+
["CC", "CCSHARED", "CFLAGS"]
119+
+ (["COMSPEC"] if is_win else [])
120+
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"]
120121
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
121-
+ ["PIP_*", "PKG_CONFIG_PATH"]
122+
+ ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
122123
+ (["PROCESSOR_ARCHITECTURE"] if is_win else [])
123124
+ (["PROGRAMDATA"] if is_win else [])
124125
+ (["PROGRAMFILES"] if is_win else [])

0 commit comments

Comments
 (0)