Skip to content

Commit e067677

Browse files
committed
Save/restore distutils.sysconfig._config_vars
1 parent 1ef44f4 commit e067677

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_cppext.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
with warnings.catch_warnings():
1111
warnings.simplefilter('ignore', DeprecationWarning)
1212
from distutils.core import setup, Extension
13-
# Import sysconfig here to make the DeprecationWarning quiet
1413
import distutils.sysconfig
1514

1615

@@ -65,6 +64,12 @@ def restore_env(old_env):
6564
os.environ.update(old_env)
6665
self.addCleanup(restore_env, dict(os.environ))
6766

67+
def restore_sysconfig_vars(old_config_vars):
68+
distutils.sysconfig._config_vars.clear()
69+
distutils.sysconfig._config_vars.update(old_config_vars)
70+
self.addCleanup(restore_sysconfig_vars,
71+
dict(distutils.sysconfig._config_vars))
72+
6873
# Build in a temporary directory
6974
with os_helper.temp_cwd():
7075
self.build()

0 commit comments

Comments
 (0)