Skip to content

Commit

Permalink
Save/restore distutils.sysconfig._config_vars
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed May 2, 2022
1 parent 1ef44f4 commit e067677
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Lib/test/test_cppext.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
from distutils.core import setup, Extension
# Import sysconfig here to make the DeprecationWarning quiet
import distutils.sysconfig


Expand Down Expand Up @@ -65,6 +64,12 @@ def restore_env(old_env):
os.environ.update(old_env)
self.addCleanup(restore_env, dict(os.environ))

def restore_sysconfig_vars(old_config_vars):
distutils.sysconfig._config_vars.clear()
distutils.sysconfig._config_vars.update(old_config_vars)
self.addCleanup(restore_sysconfig_vars,
dict(distutils.sysconfig._config_vars))

# Build in a temporary directory
with os_helper.temp_cwd():
self.build()
Expand Down

0 comments on commit e067677

Please sign in to comment.