Skip to content

Commit

Permalink
Add workaround to recognize escaped newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
manicmaniac committed Jan 8, 2024
1 parent 436b475 commit 5b6a34f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Package/Tests/Fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
try:
from sysconfig import _parse_makefile as parse_makefile
except ImportError:
from distutils.sysconfig import parse_makefile
from functools import cached_property
import pathlib
import shlex

try:
from distutils.sysconfig import parse_makefile
except ImportError:
from sysconfig import _parse_makefile
from tempfile import NamedTemporaryFile

# https://github.com/python/cpython/blob/v3.11.7/Lib/distutils/sysconfig.py#L72
def parse_makefile(fn, g=None):
with open(fn, mode='rb') as src, NamedTemporaryFile() as dest:
data = src.read()
# `distutils.sysconfig.parse_makefile` understands escaped newlines
# but `sysconfig._parse_makefile` does not.
# The next line fills the gap by just replacing escaped newlines.
dest.write(data.replace(b'\\\n', b' '))
dest.seek(0)
return _parse_makefile(dest.name, g)

_script_path = pathlib.Path(__file__)

Expand Down

0 comments on commit 5b6a34f

Please sign in to comment.