Hacks Visual Studio project files to work with our build.
(
td: pathlib.Path,
cpython_source_path: pathlib.Path,
build_directory: str,
python_version: str,
zlib_entry: str,
arch: str,
)
| 530 | |
| 531 | |
| 532 | def hack_project_files( |
| 533 | td: pathlib.Path, |
| 534 | cpython_source_path: pathlib.Path, |
| 535 | build_directory: str, |
| 536 | python_version: str, |
| 537 | zlib_entry: str, |
| 538 | arch: str, |
| 539 | ): |
| 540 | """Hacks Visual Studio project files to work with our build.""" |
| 541 | |
| 542 | pcbuild_path = cpython_source_path / "PCbuild" |
| 543 | |
| 544 | hack_props( |
| 545 | td, |
| 546 | pcbuild_path, |
| 547 | build_directory, |
| 548 | python_version, |
| 549 | zlib_entry, |
| 550 | ) |
| 551 | |
| 552 | # `--include-tcltk` is forced off on arm64, undo that |
| 553 | # See https://github.com/python/cpython/pull/132650 |
| 554 | try: |
| 555 | static_replace_in_file( |
| 556 | cpython_source_path / "PC" / "layout" / "main.py", |
| 557 | rb'if ns.arch in ("arm32", "arm64"):', |
| 558 | rb'if ns.arch == "arm32":', |
| 559 | ) |
| 560 | except NoSearchStringError: |
| 561 | pass |
| 562 | |
| 563 | # Our SQLite directory is named weirdly. This throws off version detection |
| 564 | # in the project file. Replace the parsing logic with a static string. |
| 565 | sqlite3_version = DOWNLOADS["sqlite"]["actual_version"].encode("ascii") |
| 566 | sqlite3_version_parts = sqlite3_version.split(b".") |
| 567 | sqlite3_path = pcbuild_path / "sqlite3.vcxproj" |
| 568 | static_replace_in_file( |
| 569 | sqlite3_path, |
| 570 | rb"<_SqliteVersion>$([System.Text.RegularExpressions.Regex]::Match(`$(sqlite3Dir)`, `((\d+)\.(\d+)\.(\d+)\.(\d+))\\?$`).Groups)</_SqliteVersion>", |
| 571 | rb"<_SqliteVersion>%s</_SqliteVersion>" % sqlite3_version, |
| 572 | ) |
| 573 | static_replace_in_file( |
| 574 | sqlite3_path, |
| 575 | rb"<SqliteVersion>$(_SqliteVersion.Split(`;`)[1])</SqliteVersion>", |
| 576 | rb"<SqliteVersion>%s</SqliteVersion>" % sqlite3_version, |
| 577 | ) |
| 578 | static_replace_in_file( |
| 579 | sqlite3_path, |
| 580 | rb"<SqliteMajorVersion>$(_SqliteVersion.Split(`;`)[2])</SqliteMajorVersion>", |
| 581 | rb"<SqliteMajorVersion>%s</SqliteMajorVersion>" % sqlite3_version_parts[0], |
| 582 | ) |
| 583 | static_replace_in_file( |
| 584 | sqlite3_path, |
| 585 | rb"<SqliteMinorVersion>$(_SqliteVersion.Split(`;`)[3])</SqliteMinorVersion>", |
| 586 | rb"<SqliteMinorVersion>%s</SqliteMinorVersion>" % sqlite3_version_parts[1], |
| 587 | ) |
| 588 | static_replace_in_file( |
| 589 | sqlite3_path, |
no test coverage detected