33
44from __future__ import annotations
55
6+ import base64
7+ import csv
8+ import hashlib
69import os .path
710import shutil
811import subprocess
@@ -56,7 +59,7 @@ def build_sdist(sdist_directory: str, config_settings: dict[str, Any] | None = N
5659 sdist_name = setuptools .build_meta .build_sdist (sdist_directory , config_settings )
5760
5861 sdist_path = Path (sdist_directory ) / sdist_name
59- tarball_root_dir_name = "dev_cmd-{version}" . format ( version = __version__ )
62+ tarball_root_dir_name = f "dev_cmd-{ __version__ } "
6063
6164 with _build_dir ("sdist" ) as tmpdir :
6265 tarball_root_dir = tmpdir / tarball_root_dir_name
@@ -78,14 +81,24 @@ def build_wheel(
7881 )
7982
8083 wheel_path = Path (wheel_directory ) / wheel_name
81- dist_info_dir_name = "dev_cmd-{version }.dist-info" . format ( version = __version__ )
84+ dist_info_dir_name = f "dev_cmd-{ __version__ } .dist-info"
8285
8386 with _build_dir ("wheel" ) as tmpdir :
8487 with zipfile .ZipFile (wheel_path ) as zf :
8588 original_contents = zf .namelist ()
8689 zf .extractall (tmpdir )
90+
8791 pylock_toml = _add_lock (tmpdir / dist_info_dir_name / "pylock" )
92+ pylock_toml_data = pylock_toml .read_bytes ()
93+ fingerprint = base64 .urlsafe_b64encode (hashlib .sha256 (pylock_toml_data ).digest ()).rstrip (
94+ b"="
95+ )
8896 pylock_toml_dest : str | None = str (pylock_toml .relative_to (tmpdir ).as_posix ())
97+ with (tmpdir / dist_info_dir_name / "RECORD" ).open (mode = "a" ) as fp :
98+ csv .writer (fp ).writerow (
99+ (pylock_toml_dest , f"sha256={ fingerprint .decode ('ascii' )} " , len (pylock_toml_data ))
100+ )
101+
89102 with zipfile .ZipFile (wheel_path , "w" ) as zf :
90103 for path in original_contents :
91104 if (
0 commit comments