Skip to content

Commit

Permalink
Add more c-extension env-vars to default pass_env (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Jan 4, 2023
1 parent a906a2a commit 2ce4d89
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/changelog/2818.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add ``CC``, ``CFLAGS``, ``CCSHARED``, ``CXX``, ``CPPFLAGS``, ``LDFLAGS``, ``PKG_CONFIG`` and ``PKG_CONFIG_SYSROOT_DIR``
to the default passed through environment variables list as these are needed for building various C-extensions
- by :user:`gaborbernat`.
6 changes: 6 additions & 0 deletions src/tox/tox_env/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ def _default_pass_env(self) -> list[str]:
"LANGUAGE", # localization
"CURL_CA_BUNDLE", # curl certificates
"SSL_CERT_FILE", # https certificates
"CC", # C compiler command
"CFLAGS", # C compiler flags
"CCSHARED", # compiler flags used to build a shared library
"CXX", # C++ compiler command
"CPPFLAGS", # C++ compiler flags
"LD_LIBRARY_PATH", # location of libs
"LDFLAGS", # linker flags
]
if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM
env.append("TERM")
Expand Down
3 changes: 2 additions & 1 deletion src/tox/tox_env/python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def _default_pass_env(self) -> list[str]:
"NUMBER_OF_PROCESSORS", # multiprocessing.cpu_count()
],
)
env.extend(["PKG_CONFIG_PATH"]) # used by binary extensions during installation
binary_extension_build = ["PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
env.extend(binary_extension_build) # used by binary extensions during installation
env.extend(["REQUESTS_CA_BUNDLE"])
return env

Expand Down
7 changes: 4 additions & 3 deletions tests/session/cmd/test_show_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
pass_env = outcome.env_conf("py")["pass_env"]
is_win = sys.platform == "win32"
expected = (
(["COMSPEC"] if is_win else [])
+ ["CURL_CA_BUNDLE", "LANG", "LANGUAGE", "LD_LIBRARY_PATH"]
["CC", "CCSHARED", "CFLAGS"]
+ (["COMSPEC"] if is_win else [])
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"]
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
+ ["PIP_*", "PKG_CONFIG_PATH"]
+ ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
+ (["PROCESSOR_ARCHITECTURE"] if is_win else [])
+ (["PROGRAMDATA"] if is_win else [])
+ (["PROGRAMFILES"] if is_win else [])
Expand Down

0 comments on commit 2ce4d89

Please sign in to comment.