##// END OF EJS Templates
packaging: use PyOxidizer for producing WiX MSI installer...
Gregory Szorc -
r47981:73f1a103 default
parent child Browse files
Show More
@@ -12,6 +12,7 b' import pathlib'
12 12 import shutil
13 13 import subprocess
14 14 import sys
15 import typing
15 16
16 17 from .downloads import download_entry
17 18 from .util import (
@@ -69,7 +70,11 b' def build_docs_html(source_dir: pathlib.'
69 70
70 71
71 72 def run_pyoxidizer(
72 source_dir: pathlib.Path, build_dir: pathlib.Path, target_triple: str,
73 source_dir: pathlib.Path,
74 build_dir: pathlib.Path,
75 target_triple: str,
76 build_vars: typing.Optional[typing.Dict[str, str]] = None,
77 target: typing.Optional[str] = None,
73 78 ) -> pathlib.Path:
74 79 """Run `pyoxidizer` in an environment with access to build dependencies.
75 80
@@ -77,6 +82,8 b' def run_pyoxidizer('
77 82 artifacts. Actual build artifacts are likely in a sub-directory with the
78 83 name of the pyoxidizer build target that was built.
79 84 """
85 build_vars = build_vars or {}
86
80 87 # We need to make gettext binaries available for compiling i18n files.
81 88 gettext_pkg, gettext_entry = download_entry('gettext', build_dir)
82 89 gettext_dep_pkg = download_entry('gettext-dep', build_dir)[0]
@@ -104,6 +111,12 b' def run_pyoxidizer('
104 111 target_triple,
105 112 ]
106 113
114 for k, v in sorted(build_vars.items()):
115 args.extend(["--var", k, v])
116
117 if target:
118 args.append(target)
119
107 120 subprocess.run(args, env=env, check=True)
108 121
109 122 return source_dir / "build" / "pyoxidizer" / target_triple / "release"
@@ -22,7 +22,11 b' from .py2exe import ('
22 22 build_py2exe,
23 23 stage_install,
24 24 )
25 from .pyoxidizer import create_pyoxidizer_install_layout
25 from .pyoxidizer import (
26 build_docs_html,
27 create_pyoxidizer_install_layout,
28 run_pyoxidizer,
29 )
26 30 from .util import (
27 31 extract_zip_to_directory,
28 32 normalize_windows_version,
@@ -386,37 +390,65 b' def build_installer_pyoxidizer('
386 390 """Build a WiX MSI installer using PyOxidizer."""
387 391 hg_build_dir = source_dir / "build"
388 392 build_dir = hg_build_dir / ("wix-%s" % target_triple)
389 staging_dir = build_dir / "stage"
390
391 arch = "x64" if "x86_64" in target_triple else "x86"
392 393
393 394 build_dir.mkdir(parents=True, exist_ok=True)
394 create_pyoxidizer_install_layout(
395 source_dir, build_dir, staging_dir, target_triple
395
396 # Need to ensure docs HTML is built because this isn't done as part of
397 # `pip install Mercurial`.
398 build_docs_html(source_dir)
399
400 build_vars = {}
401
402 if msi_name:
403 build_vars["MSI_NAME"] = msi_name
404
405 if version:
406 build_vars["VERSION"] = version
407
408 if extra_features:
409 build_vars["EXTRA_MSI_FEATURES"] = ";".join(extra_features)
410
411 if signing_info:
412 if signing_info["cert_path"]:
413 build_vars["SIGNING_PFX_PATH"] = signing_info["cert_path"]
414 if signing_info["cert_password"]:
415 build_vars["SIGNING_PFX_PASSWORD"] = signing_info["cert_password"]
416 if signing_info["subject_name"]:
417 build_vars["SIGNING_SUBJECT_NAME"] = signing_info["subject_name"]
418 if signing_info["timestamp_url"]:
419 build_vars["TIME_STAMP_SERVER_URL"] = signing_info["timestamp_url"]
420
421 if extra_wxs:
422 raise Exception(
423 "support for extra .wxs files has been temporarily dropped"
424 )
425
426 out_dir = run_pyoxidizer(
427 source_dir,
428 build_dir,
429 target_triple,
430 build_vars=build_vars,
431 target="msi",
396 432 )
397 433
398 # We also install some extra files.
399 process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir)
434 msi_dir = out_dir / "msi"
435 msi_files = [f for f in os.listdir(msi_dir) if f.endswith(".msi")]
400 436
401 # And remove some files we don't want.
402 for f in STAGING_REMOVE_FILES:
403 p = staging_dir / f
404 if p.exists():
405 print('removing %s' % p)
406 p.unlink()
437 if len(msi_files) != 1:
438 raise Exception("expected exactly 1 .msi file; got %d" % len(msi_files))
439
440 msi_filename = msi_files[0]
407 441
408 return run_wix_packaging(
409 source_dir,
410 build_dir,
411 staging_dir,
412 arch,
413 version,
414 python2=False,
415 msi_name=msi_name,
416 extra_wxs=extra_wxs,
417 extra_features=extra_features,
418 signing_info=signing_info,
419 )
442 msi_path = msi_dir / msi_filename
443 dist_path = source_dir / "dist" / msi_filename
444
445 dist_path.parent.mkdir(parents=True, exist_ok=True)
446
447 shutil.copyfile(msi_path, dist_path)
448
449 return {
450 "msi_path": dist_path,
451 }
420 452
421 453
422 454 def run_wix_packaging(
General Comments 0
You need to be logged in to leave comments. Login now