| 291 | |
| 292 | |
| 293 | def _build_choco_packages(): |
| 294 | build_version_urlsafe = props.get_version(install=False, url_safe=True) |
| 295 | base_url = ( |
| 296 | "https://github.com/pyrevitlabs/pyRevit/" |
| 297 | f"releases/download/v{build_version_urlsafe}/" |
| 298 | ) |
| 299 | install_version = props.get_version(install=True) |
| 300 | pyrevit_cli_admin_installer = ( |
| 301 | configs.PYREVIT_CLI_ADMIN_INSTALLER_NAME.format(version=install_version) |
| 302 | + ".exe" |
| 303 | ) |
| 304 | |
| 305 | download_url = base_url + pyrevit_cli_admin_installer |
| 306 | sha256_hash = hashlib.sha256() |
| 307 | installer_file = op.join( |
| 308 | configs.DISTRIBUTE_PATH, pyrevit_cli_admin_installer |
| 309 | ) |
| 310 | with open(installer_file, "rb") as f: |
| 311 | # read and update hash string value in blocks of 4K |
| 312 | for byte_block in iter(lambda: f.read(4096), b""): |
| 313 | sha256_hash.update(byte_block) |
| 314 | sha256_hash = str(sha256_hash.hexdigest()).upper() |
| 315 | |
| 316 | contents = [] |
| 317 | url_finder = re.compile(r"\$url64\s+=") |
| 318 | checksum64_finder = re.compile(r" checksum64\s+=") |
| 319 | with open(configs.PYREVIT_CHOCO_INSTALL_FILE, "r") as cifile: |
| 320 | for cline in cifile.readlines(): |
| 321 | if url_finder.match(cline): |
| 322 | contents.append(f"$url64 = '{download_url}'\n") |
| 323 | elif checksum64_finder.match(cline): |
| 324 | contents.append(f" checksum64 = '{sha256_hash}'\n") |
| 325 | else: |
| 326 | contents.append(cline) |
| 327 | |
| 328 | with open(configs.PYREVIT_CHOCO_INSTALL_FILE, "w") as cifile: |
| 329 | cifile.writelines(contents) |
| 330 | |
| 331 | print("Building choco package...") |
| 332 | utils.system( |
| 333 | [ |
| 334 | install.get_tool("choco"), |
| 335 | "pack", |
| 336 | configs.PYREVIT_CHOCO_NUSPEC_FILE, |
| 337 | "--outdir", |
| 338 | "dist", |
| 339 | ], |
| 340 | dump_stdout=True, |
| 341 | ) |
| 342 | |
| 343 | |
| 344 | def build_installers(_: Dict[str, str]): |