(
dist_dir: Path,
*additional_dist_formats: Format,
verbosity: int = 0,
embed_docs: bool = False,
clean_docs: bool = False,
pex_output_file: Optional[Path] = None,
scie_choice: ScieChoice | None = None,
markdown_hash_table_file: Optional[Path] = None,
serve: bool = False
)
| 285 | |
| 286 | |
| 287 | def main( |
| 288 | dist_dir: Path, |
| 289 | *additional_dist_formats: Format, |
| 290 | verbosity: int = 0, |
| 291 | embed_docs: bool = False, |
| 292 | clean_docs: bool = False, |
| 293 | pex_output_file: Optional[Path] = None, |
| 294 | scie_choice: ScieChoice | None = None, |
| 295 | markdown_hash_table_file: Optional[Path] = None, |
| 296 | serve: bool = False |
| 297 | ) -> None: |
| 298 | env = os.environ.copy() |
| 299 | if embed_docs: |
| 300 | env.update(__PEX_BUILD_INCLUDE_DOCS__="1") |
| 301 | |
| 302 | hash_table: dict[Path, tuple[str, int]] = {} |
| 303 | if pex_output_file: |
| 304 | print(f"Building Pex PEX to `{pex_output_file}` ...") |
| 305 | build_pex_pex(pex_output_file, verbosity, env=env) |
| 306 | |
| 307 | rev = describe_rev() |
| 308 | sha256, size = describe_file(pex_output_file) |
| 309 | with (pex_output_file.parent / f"{pex_output_file.name}.sha256").open("w") as fp: |
| 310 | fp.write(f"{sha256} *{pex_output_file.name}") |
| 311 | hash_table[pex_output_file] = sha256, size |
| 312 | print(f"Built Pex PEX @ {rev}:") |
| 313 | print(f"sha256: {sha256}") |
| 314 | print(f" size: {size}") |
| 315 | |
| 316 | if scie_choice: |
| 317 | scies = "scies" if scie_choice is ScieChoice.ALL else "scie" |
| 318 | print(f"Building Pex {scies} to `{dist_dir}` ...") |
| 319 | for scie, platform in build_pex_scies(dist_dir, scie_choice, verbosity, env=env): |
| 320 | hash_table[scie] = describe_file(scie) |
| 321 | print(f" Built Pex scie for {platform.name} at `{scie}`") |
| 322 | |
| 323 | if markdown_hash_table_file and hash_table: |
| 324 | with markdown_hash_table_file.open(mode="w") as fp: |
| 325 | print("|file|sha256|size|", file=fp) |
| 326 | print("|----|------|----|", file=fp) |
| 327 | for file, (sha256, size) in sorted(hash_table.items()): |
| 328 | print(f"|{file.name}|{sha256}|{size}|", file=fp) |
| 329 | |
| 330 | print(f"Generated markdown table of Pex sizes & hashes at `{markdown_hash_table_file}`") |
| 331 | |
| 332 | if additional_dist_formats: |
| 333 | print( |
| 334 | f"Building additional distribution formats to `{dist_dir}`: " |
| 335 | f'{", ".join(f"{i + 1}.) {fmt}" for i, fmt in enumerate(additional_dist_formats))} ...' |
| 336 | ) |
| 337 | built = list( |
| 338 | build_pex_dists( |
| 339 | dist_dir, |
| 340 | additional_dist_formats[0], |
| 341 | *additional_dist_formats[1:], |
| 342 | verbose=verbosity > 0, |
| 343 | env=env |
| 344 | ) |
no test coverage detected