Skip to content

GH-129064: deprecate sysconfig.expand_makefile_vars #129082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/deprecations/pending-removal-in-3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Pending removal in Python 3.16
has been deprecated since Python 3.13.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.

* :mod:`sysconfig`:

* The ``~sysconfig.expand_makefile_vars`` function
has been deprecated since Python 3.14.
Use the ``vars`` argument of :func:`sysconfig.get_paths` instead.

* :mod:`tarfile`:

* The undocumented and unused :attr:`!TarFile.tarfile` attribute
Expand Down
9 changes: 9 additions & 0 deletions Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,15 @@ def expand_makefile_vars(s, vars):
variable expansions; if 'vars' is the output of 'parse_makefile()',
you're fine. Returns a variable-expanded version of 's'.
"""

import warnings
warnings.warn(
'sysconfig.expand_makefile_vars is deprecated and will be removed in '
'Python 3.16. Use sysconfig.get_paths(vars=...) instead.',
DeprecationWarning,
stacklevel=2,
)

import re

_findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)"
Expand Down
19 changes: 19 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,5 +711,24 @@ def test_parse_makefile(self):
})


class DeprecationTests(unittest.TestCase):
def deprecated(self, removal_version, deprecation_msg=None, attribute_msg=None):
if sys.version_info >= removal_version:
return self.assertRaises(AttributeError, msg=attribute_msg)
else:
return self.assertWarns(DeprecationWarning, msg=deprecation_msg)

def test_expand_makefile_vars(self):
with self.deprecated(
removal_version=(3, 16),
deprecation_msg=(
'sysconfig.expand_makefile_vars is deprecated and will be removed in '
'Python 3.16. Use sysconfig.get_paths(vars=...) instead.',
),
attribute_msg="module 'sysconfig' has no attribute 'expand_makefile_vars'",
):
sysconfig.expand_makefile_vars('', {})


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deprecate ``sysconfig.expand_makefile_vars``, in favor of using
:func:`sysconfig.get_paths` with the ``vars`` argument.
Loading