Skip to content

Commit 4cab995

Browse files
committed
Fix patch_file and regex for ensurepip
1 parent c463361 commit 4cab995

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

relenv/build/common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,13 @@ def update_ensurepip(source_dir):
393393
# Update __init__.py
394394
init_file = source_dir / "Lib" / "ensurepip" / "__init__.py"
395395
# pip
396-
old = "^_PIP_VERSION.*$"
397-
new = f'_PIP_VERSION="{pip_version}"'
396+
old = "^_PIP_VERSION.*"
397+
new = f'_PIP_VERSION = "{pip_version}"'
398398
patch_file(path=init_file, old=old, new=new)
399399

400400
# setuptools
401-
old = "^_SETUPTOOLS_VERSION.*$"
402-
new = f'_SETUPTOOLS_VERSION="{setuptools_version}"'
401+
old = "^_SETUPTOOLS_VERSION.*"
402+
new = f'_SETUPTOOLS_VERSION = "{setuptools_version}"'
403403
patch_file(path=init_file, old=old, new=new)
404404

405405
log.debug("ensurepip __init__.py contents:")
@@ -424,8 +424,8 @@ def patch_file(path, old, new):
424424
content = fp.read()
425425
new_content = ""
426426
for line in content.splitlines():
427-
re.sub(old, new, line)
428-
new_content += line + "\n"
427+
line = re.sub(old, new, line)
428+
new_content += line + os.linesep
429429
with open(path, "w") as fp:
430430
fp.write(new_content)
431431

0 commit comments

Comments
 (0)