Skip to content

Commit 310c8a6

Browse files
charliermarshindygreg
authored andcommitted
windows: remove shared- prefix from Windows profiles
Closes #241. Closes #237. Since we no longer have static builds, it no longer makes sense to have `shared` in Windows triples. This commit removes them. We still publish the `shared` release artifacts for backwards compatibility.
1 parent ac4b74b commit 310c8a6

File tree

4 files changed

+46
-23
lines changed

4 files changed

+46
-23
lines changed

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- 'vcvars32.bat'
5353
- 'vcvars64.bat'
5454
profile:
55-
- 'shared-pgo'
55+
- 'pgo'
5656
needs: pythonbuild
5757
runs-on: 'windows-2019'
5858
steps:

cpython-windows/build.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ def hack_project_files(
605605
pass
606606

607607

608-
609608
PYPORT_EXPORT_SEARCH_39 = b"""
610609
#if defined(__CYGWIN__)
611610
# define HAVE_DECLSPEC_DLL
@@ -894,12 +893,11 @@ def build_openssl_for_arch(
894893
# uplink.c tries to find the OPENSSL_Applink function exported from the current
895894
# executable. However, it is exported from _ssl[_d].pyd in shared builds. So
896895
# update its sounce to look for it from there.
897-
if "shared" in profile:
898-
static_replace_in_file(
899-
source_root / "ms" / "uplink.c",
900-
b"((h = GetModuleHandle(NULL)) == NULL)",
901-
b'((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL)',
902-
)
896+
static_replace_in_file(
897+
source_root / "ms" / "uplink.c",
898+
b"((h = GetModuleHandle(NULL)) == NULL)",
899+
b'((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL)',
900+
)
903901

904902
if arch == "x86":
905903
configure = "VC-WIN32"
@@ -1189,7 +1187,6 @@ def collect_python_build_artifacts(
11891187

11901188
extension_projects.add(extension)
11911189

1192-
11931190
depends_projects |= {
11941191
"liblzma",
11951192
"sqlite3",
@@ -1313,9 +1310,7 @@ def find_additional_dependencies(project: pathlib.Path):
13131310
for obj in process_project(ext, dest_dir):
13141311
entry["objs"].append("build/extensions/%s/%s" % (ext, obj))
13151312

1316-
for lib in CONVERT_TO_BUILTIN_EXTENSIONS.get(ext, {}).get(
1317-
"shared_depends", []
1318-
):
1313+
for lib in CONVERT_TO_BUILTIN_EXTENSIONS.get(ext, {}).get("shared_depends", []):
13191314
entry["links"].append(
13201315
{"name": lib, "path_dynamic": "install/DLLs/%s.dll" % lib}
13211316
)
@@ -1389,8 +1384,8 @@ def build_cpython(
13891384
openssl_archive,
13901385
libffi_archive,
13911386
openssl_entry: str,
1392-
):
1393-
pgo = "-pgo" in profile
1387+
) -> pathlib.Path:
1388+
pgo = profile == "pgo"
13941389

13951390
msbuild = find_msbuild(msvc_version)
13961391
log("found MSBuild at %s" % msbuild)
@@ -1724,7 +1719,7 @@ def build_cpython(
17241719

17251720
crt_features = ["vcruntime:140"]
17261721

1727-
if "pgo" in profile:
1722+
if profile == "pgo":
17281723
optimizations = "pgo"
17291724
else:
17301725
optimizations = "noopt"
@@ -1817,7 +1812,7 @@ def fetch_strawberry_perl() -> pathlib.Path:
18171812
return strawberryperl
18181813

18191814

1820-
def main():
1815+
def main() -> None:
18211816
BUILD.mkdir(exist_ok=True)
18221817

18231818
parser = argparse.ArgumentParser()
@@ -1841,8 +1836,8 @@ def main():
18411836
)
18421837
parser.add_argument(
18431838
"--profile",
1844-
choices={"shared-noopt", "shared-pgo"},
1845-
default="shared-noopt",
1839+
choices={"noopt", "pgo"},
1840+
default="noopt",
18461841
help="How to compile Python",
18471842
)
18481843
parser.add_argument(
@@ -1920,12 +1915,23 @@ def main():
19201915
else:
19211916
release_tag = release_tag_from_git()
19221917

1923-
compress_python_archive(
1918+
# Create, e.g., `cpython-3.10.13+20240224-x86_64-pc-windows-msvc-pgo.tar.zst`.
1919+
dest_path = compress_python_archive(
19241920
tar_path,
19251921
DIST,
19261922
"%s-%s" % (tar_path.stem, release_tag),
19271923
)
19281924

1925+
# Copy to, e.g., `cpython-3.10.13+20240224-x86_64-pc-windows-msvc-shared-pgo.tar.zst`.
1926+
# The 'shared-' prefix is no longer needed, but we're double-publishing under
1927+
# both names during the transition period.
1928+
filename: str = dest_path.name
1929+
if not filename.endswith("-%s-%s.tar.zst" % (args.profile, release_tag)):
1930+
raise ValueError("expected filename to end with profile: %s" % filename)
1931+
filename = filename.removesuffix("-%s-%s.tar.zst" % (args.profile, release_tag))
1932+
filename = filename + "-shared-%s-%s.tar.zst" % (args.profile, release_tag)
1933+
shutil.copy2(dest_path, dest_path.with_name(filename))
1934+
19291935

19301936
if __name__ == "__main__":
19311937
sys.exit(main())

docs/building.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ If building CPython 3.8+, there are the following additional requirements:
9494

9595
To build a dynamically linked Python distribution for Windows x64::
9696

97-
$ py.exe build-windows.py --profile shared-noopt
97+
$ py.exe build-windows.py --profile noopt
9898

9999
It's also possible to build with optional PGO optimizations::
100100

101-
$ py.exe build-windows.py --profile shared-pgo
101+
$ py.exe build-windows.py --profile pgo
102102

103103
If building CPython 3.8+, you will need to specify the path to a
104104
``sh.exe`` installed from cygwin. e.g.
105105

106-
$ py.exe build-windows.py --python cpython-3.8 --sh c:\cygwin\bin\sh.exe --profile shared
106+
$ py.exe build-windows.py --python cpython-3.8 --sh c:\cygwin\bin\sh.exe --profile noopt
107107

108108
To build a 32-bit x86 binary, simply use an ``x86 Native Tools
109109
Command Prompt`` instead of ``x64``.

src/release.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,25 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
4747
);
4848

4949
// Windows.
50+
h.insert(
51+
"i686-pc-windows-msvc",
52+
TripleRelease {
53+
suffixes: vec!["pgo"],
54+
install_only_suffix: "pgo",
55+
python_version_requirement: None,
56+
},
57+
);
58+
h.insert(
59+
"x86_64-pc-windows-msvc",
60+
TripleRelease {
61+
suffixes: vec!["pgo"],
62+
install_only_suffix: "pgo",
63+
python_version_requirement: None,
64+
},
65+
);
5066

51-
// The -shared part of the triple is a lie. But the code handles it fine.
67+
// The 'shared-' prefix is no longer needed, but we're double-publishing under both names during
68+
// the transition period.
5269
h.insert(
5370
"i686-pc-windows-msvc-shared",
5471
TripleRelease {

0 commit comments

Comments
 (0)