Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove shared- prefix from Windows profiles #241

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- 'vcvars32.bat'
- 'vcvars64.bat'
profile:
- 'shared-pgo'
- 'pgo'
charliermarsh marked this conversation as resolved.
Show resolved Hide resolved
needs: pythonbuild
runs-on: 'windows-2019'
steps:
Expand Down
42 changes: 24 additions & 18 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def hack_project_files(
pass



PYPORT_EXPORT_SEARCH_39 = b"""
#if defined(__CYGWIN__)
# define HAVE_DECLSPEC_DLL
Expand Down Expand Up @@ -894,12 +893,11 @@ def build_openssl_for_arch(
# uplink.c tries to find the OPENSSL_Applink function exported from the current
# executable. However, it is exported from _ssl[_d].pyd in shared builds. So
# update its sounce to look for it from there.
if "shared" in profile:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Always true. Should've been removed in the preceding PR.)

static_replace_in_file(
source_root / "ms" / "uplink.c",
b"((h = GetModuleHandle(NULL)) == NULL)",
b'((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL)',
)
static_replace_in_file(
source_root / "ms" / "uplink.c",
b"((h = GetModuleHandle(NULL)) == NULL)",
b'((h = GetModuleHandleA("_ssl.pyd")) == NULL) if ((h = GetModuleHandleA("_ssl_d.pyd")) == NULL) if ((h = GetModuleHandle(NULL)) == NULL)',
)

if arch == "x86":
configure = "VC-WIN32"
Expand Down Expand Up @@ -1189,7 +1187,6 @@ def collect_python_build_artifacts(

extension_projects.add(extension)


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

for lib in CONVERT_TO_BUILTIN_EXTENSIONS.get(ext, {}).get(
"shared_depends", []
):
for lib in CONVERT_TO_BUILTIN_EXTENSIONS.get(ext, {}).get("shared_depends", []):
entry["links"].append(
{"name": lib, "path_dynamic": "install/DLLs/%s.dll" % lib}
)
Expand Down Expand Up @@ -1389,8 +1384,8 @@ def build_cpython(
openssl_archive,
libffi_archive,
openssl_entry: str,
):
pgo = "-pgo" in profile
) -> pathlib.Path:
pgo = profile == "pgo"

msbuild = find_msbuild(msvc_version)
log("found MSBuild at %s" % msbuild)
Expand Down Expand Up @@ -1724,7 +1719,7 @@ def build_cpython(

crt_features = ["vcruntime:140"]

if "pgo" in profile:
if profile == "pgo":
optimizations = "pgo"
else:
optimizations = "noopt"
Expand Down Expand Up @@ -1817,7 +1812,7 @@ def fetch_strawberry_perl() -> pathlib.Path:
return strawberryperl


def main():
def main() -> None:
BUILD.mkdir(exist_ok=True)

parser = argparse.ArgumentParser()
Expand All @@ -1841,8 +1836,8 @@ def main():
)
parser.add_argument(
"--profile",
choices={"shared-noopt", "shared-pgo"},
default="shared-noopt",
choices={"noopt", "pgo"},
default="noopt",
help="How to compile Python",
)
parser.add_argument(
Expand Down Expand Up @@ -1920,12 +1915,23 @@ def main():
else:
release_tag = release_tag_from_git()

compress_python_archive(
# Create, e.g., `cpython-3.10.13+20240224-x86_64-pc-windows-msvc-pgo.tar.zst`.
dest_path = compress_python_archive(
tar_path,
DIST,
"%s-%s" % (tar_path.stem, release_tag),
)

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


if __name__ == "__main__":
sys.exit(main())
6 changes: 3 additions & 3 deletions docs/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ If building CPython 3.8+, there are the following additional requirements:

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

$ py.exe build-windows.py --profile shared-noopt
$ py.exe build-windows.py --profile noopt

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

$ py.exe build-windows.py --profile shared-pgo
$ py.exe build-windows.py --profile pgo

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

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

To build a 32-bit x86 binary, simply use an ``x86 Native Tools
Command Prompt`` instead of ``x64``.
Expand Down
19 changes: 18 additions & 1 deletion src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,25 @@ pub static RELEASE_TRIPLES: Lazy<BTreeMap<&'static str, TripleRelease>> = Lazy::
);

// Windows.
h.insert(
"i686-pc-windows-msvc",
TripleRelease {
suffixes: vec!["pgo"],
install_only_suffix: "pgo",
python_version_requirement: None,
},
);
h.insert(
"x86_64-pc-windows-msvc",
TripleRelease {
suffixes: vec!["pgo"],
install_only_suffix: "pgo",
python_version_requirement: None,
},
);

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