Skip to content

Commit 1fd7e6f

Browse files
committed
Stabilize Windows builds and automate dependency management
- Implement OpenSSL 3.6.1 source builds via MSVC (nmake) to replace unreliable pre-built binary dependencies. - Add architecture isolation for Windows externals, mapping 'x86' to 'win32' to satisfy CPython's MSBuild expectations and prevent include path collisions. - Automate discovery and management of portable Strawberry Perl and NASM in relenv/pyversions.py. - Fix metadata generation for krb5 (major.minor pathing) and zlib (migration to GitHub releases for reliability). - Resolve link failures by ensuring applink.c is present in include/ and patching openssl.props for correct DLL suffixes (-3 vs -3-x64). - Disable SBOM generation for Python 3.12+ to avoid build-time issues. - Force UTF-8 encoding in pre-commit hooks to prevent crashes on Windows. - Clean up build-system merge artifacts and fix logging type errors.
1 parent 12306c3 commit 1fd7e6f

File tree

8 files changed

+974
-333
lines changed

8 files changed

+974
-333
lines changed

.pre-commit-hooks/copyright_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
def check_copyright(files):
2222
for file in files:
23-
contents = file.read_text()
23+
contents = file.read_text(encoding="utf-8")
2424
if not contents.strip():
2525
# Don't add headers to empty files
2626
continue
@@ -42,7 +42,7 @@ def check_copyright(files):
4242
if not contents.endswith("\n"):
4343
contents += "\n"
4444
if original_contents != contents:
45-
file.write_text(contents)
45+
file.write_text(contents, encoding="utf-8")
4646

4747

4848
def inject_copyright_header(contents):

relenv/build/common/builder.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,13 @@ def run(
409409
root_log = logging.getLogger(None)
410410
if sys.platform == "win32":
411411
if not show_ui:
412-
handler = logging.StreamHandler()
413-
handler.setLevel(logging.getLevelName(log_level))
414-
root_log.addHandler(handler)
415-
416-
for handler in root_log.handlers:
417-
if isinstance(handler, logging.StreamHandler):
418-
handler.setFormatter(
419-
logging.Formatter(f"%(asctime)s {name} %(message)s")
420-
)
412+
stream_handler = logging.StreamHandler()
413+
stream_handler.setLevel(logging.getLevelName(log_level))
414+
root_log.addHandler(stream_handler)
415+
416+
for h in root_log.handlers:
417+
if isinstance(h, logging.StreamHandler):
418+
h.setFormatter(logging.Formatter(f"%(asctime)s {name} %(message)s"))
421419

422420
if not self.dirs.build.exists():
423421
os.makedirs(self.dirs.build, exist_ok=True)
@@ -431,8 +429,8 @@ def run(
431429
time.sleep(0.3)
432430

433431
logfp = io.open(os.path.join(dirs.logs, "{}.log".format(name)), "w")
434-
handler = logging.FileHandler(dirs.logs / f"{name}.log")
435-
root_log.addHandler(handler)
432+
file_handler = logging.FileHandler(dirs.logs / f"{name}.log")
433+
root_log.addHandler(file_handler)
436434
root_log.setLevel(logging.NOTSET)
437435

438436
# Add line count handler if tracking is enabled
@@ -497,7 +495,7 @@ def run(
497495
os.chdir(cwd)
498496
if line_count_handler is not None:
499497
root_log.removeHandler(line_count_handler)
500-
root_log.removeHandler(handler)
498+
root_log.removeHandler(file_handler)
501499
logfp.close()
502500

503501
def cleanup(self) -> None:

relenv/build/common/install.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,24 @@
5757

5858
def patch_file(path: PathLike, old: str, new: str) -> None:
5959
"""
60-
Search a file line by line for a string to replace.
60+
Search a file for a string to replace.
6161
6262
:param path: Location of the file to search
6363
:type path: str
64-
:param old: The value that will be replaced
65-
:type path: str
64+
:param old: The value that will be replaced (regex)
65+
:type old: str
6666
:param new: The value that will replace the 'old' value.
6767
:type path: str
6868
"""
6969
log.debug("Patching file: %s", path)
70-
with open(path, "r") as fp:
71-
content = fp.read()
72-
new_content = ""
73-
for line in content.splitlines():
74-
line = re.sub(old, new, line)
75-
new_content += line + "\n"
76-
with open(path, "w") as fp:
77-
fp.write(new_content)
70+
path = pathlib.Path(path)
71+
if not path.exists():
72+
log.warning("File not found for patching: %s", path)
73+
return
74+
75+
content = path.read_text(encoding="utf-8")
76+
new_content = re.sub(old, new, content, flags=re.IGNORECASE | re.MULTILINE)
77+
path.write_text(new_content, encoding="utf-8")
7878

7979

8080
def update_sbom_checksums(

0 commit comments

Comments
 (0)