beeware / briefcase

Tools to support converting a Python project into a standalone native application.
https://briefcase.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.6k stars 365 forks source link

Regression: Briefcase 0.3.9 on Windows is not able to compile installer #837

Closed MosGeo closed 2 years ago

MosGeo commented 2 years ago

Describe the bug Briefcase is not able to generate the MSI for newly created project. Version 0.3.8 works but version 0.3.9 does not.

Briefcase Log:
[11:51:05] Briefcase is no longer using the data directory:                                                                                                              base.py:224
                                                                                                                                                                         base.py:224
               C:\Users\Mustafa\.briefcase                                                                                                                               base.py:224
                                                                                                                                                                         base.py:224
           This directory can be safely deleted.                                                                                                                         base.py:224
                                                                                                                                                                     __init__.py:114
           [test] Building MSI...                                                                                                                                    __init__.py:114
           Compiling application manifest...                                                                                                                         __init__.py:117
                                                                                                                                                                   subprocess.py:442
           >>> Running Command:                                                                                                                                    subprocess.py:443
           >>>     'C:\Users\Mustafa\AppData\Local\BeeWare\briefcase\Cache\tools\wix\heat.exe' dir src -nologo -gg -sfrag -sreg -srd -scom -dr test_ROOTDIR -cg    subprocess.py:444
           test_COMPONENTS -var var.SourceDir -out test-manifest.wxs                                                                                                                
           >>> Working Directory:                                                                                                                                  subprocess.py:451
           >>>     C:\Users\Mustafa\Desktop\briefcase_test\test\windows\app\test                                                                                   subprocess.py:452
[11:51:13] >>> Return code: 2148734720                                                                                                                             subprocess.py:479
           Compiling...                                                                                                                                              __init__.py:118
                                                                                                                                                                      __main__.py:22
           Unable to generate manifest for app test.                                                                                                                  __main__.py:23

╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────╮
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\platforms\windows\__init__.py:119 in package_app                                                       │
│                                                                                                                                                                                  │
│   116 │   │   try:                                                                                                                                                               │
│   117 │   │   │   self.logger.info("Compiling application manifest...")                                                                                                          │
│   118 │   │   │   with self.input.wait_bar("Compiling..."):                                                                                                                      │
│ ❱ 119 │   │   │   │   self.subprocess.run(                                                                                                                                       │
│   120 │   │   │   │   │   [                                                                                                                                                      │
│   121 │   │   │   │   │   │   self.wix.heat_exe,                                                                                                                                 │
│   122 │   │   │   │   │   │   "dir",                                                                                                                                             │
│                                                                                                                                                                                  │
│ ╭───────────────────────────────────────────── locals ─────────────────────────────────────────────╮                                                                             │
│ │    app = <com.example.test v0.0.1 AppConfig>                                                     │                                                                             │
│ │ kwargs = {'packaging_format': 'msi', 'sign_app': True, 'adhoc_sign': False, 'identity': None}    │                                                                             │
│ │   self = <briefcase.platforms.windows.app.WindowsAppPackageCommand object at 0x0000018C143E70D0> │                                                                             │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                             │
│                                                                                                                                                                                  │
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\integrations\subprocess.py:217 in run                                                                  │
│                                                                                                                                                                                  │
│   214 │   │   if stream_output or (                                                                                                                                              │
│   215 │   │   │   self.command.input.is_output_controlled and not is_output_redirected                                                                                           │
│   216 │   │   ):                                                                                                                                                                 │
│ ❱ 217 │   │   │   return self._run_and_stream_output(args, **kwargs)                                                                                                             │
│   218 │   │                                                                                                                                                                      │
│   219 │   │   # Otherwise, invoke run() normally.                                                                                                                                │
│   220 │   │   self._log_command(args)                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭────────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────────╮                                                  │
│ │                 args = [                                                                                                    │                                                  │
│ │                        │   WindowsPath('C:/Users/Mustafa/AppData/Local/BeeWare/briefcase/Cache/tools/wix/heat.exe'),        │                                                  │
│ │                        │   'dir',                                                                                           │                                                  │
│ │                        │   'src',                                                                                           │                                                  │
│ │                        │   '-nologo',                                                                                       │                                                  │
│ │                        │   '-gg',                                                                                           │                                                  │
│ │                        │   '-sfrag',                                                                                        │                                                  │
│ │                        │   '-sreg',                                                                                         │                                                  │
│ │                        │   '-srd',                                                                                          │                                                  │
│ │                        │   '-scom',                                                                                         │                                                  │
│ │                        │   '-dr',                                                                                           │                                                  │
│ │                        │   ... +7                                                                                           │                                                  │
│ │                        ]                                                                                                    │                                                  │
│ │ is_output_redirected = None                                                                                                 │                                                  │
│ │               kwargs = {'check': True, 'cwd': WindowsPath('C:/Users/Mustafa/Desktop/briefcase_test/test/windows/app/test')} │                                                  │
│ │                 self = <briefcase.integrations.subprocess.Subprocess object at 0x0000018C144EC8E0>                          │                                                  │
│ │        stream_output = False                                                                                                │                                                  │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                  │
│                                                                                                                                                                                  │
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\integrations\subprocess.py:283 in _run_and_stream_output                                               │
│                                                                                                                                                                                  │
│   280 │   │   self._log_return_code(return_code)                                                                                                                                 │
│   281 │   │                                                                                                                                                                      │
│   282 │   │   if check and return_code:                                                                                                                                          │
│ ❱ 283 │   │   │   raise subprocess.CalledProcessError(return_code, args, stderr=stderr)                                                                                          │
│   284 │   │                                                                                                                                                                      │
│   285 │   │   return subprocess.CompletedProcess(args, return_code, stderr=stderr)                                                                                               │
│   286                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────────────────╮                                │
│ │        args = [                                                                                                                               │                                │
│ │               │   WindowsPath('C:/Users/Mustafa/AppData/Local/BeeWare/briefcase/Cache/tools/wix/heat.exe'),                                   │                                │
│ │               │   'dir',                                                                                                                      │                                │
│ │               │   'src',                                                                                                                      │                                │
│ │               │   '-nologo',                                                                                                                  │                                │
│ │               │   '-gg',                                                                                                                      │                                │
│ │               │   '-sfrag',                                                                                                                   │                                │
│ │               │   '-sreg',                                                                                                                    │                                │
│ │               │   '-srd',                                                                                                                     │                                │
│ │               │   '-scom',                                                                                                                    │                                │
│ │               │   '-dr',                                                                                                                      │                                │
│ │               │   ... +7                                                                                                                      │                                │
│ │               ]                                                                                                                               │                                │
│ │       check = True                                                                                                                            │                                │
│ │      kwargs = {'cwd': WindowsPath('C:/Users/Mustafa/Desktop/briefcase_test/test/windows/app/test'), 'stdout': -1, 'stderr': -2, 'bufsize': 1} │                                │
│ │     process = <Popen: returncode: 2148734720 args: ['C:\\Users\\Mustafa\\AppData\\Local\\B...>                                                │                                │
│ │ return_code = 2148734720                                                                                                                      │                                │
│ │        self = <briefcase.integrations.subprocess.Subprocess object at 0x0000018C144EC8E0>                                                     │                                │
│ │      stderr = None                                                                                                                            │                                │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
CalledProcessError: Command '[WindowsPath('C:/Users/Mustafa/AppData/Local/BeeWare/briefcase/Cache/tools/wix/heat.exe'), 'dir', 'src', '-nologo', '-gg', '-sfrag', '-sreg', '-srd', '-scom', '-dr', 'test_ROOTDIR', '-cg', 'test_COMPONENTS', '-var', 'var.SourceDir', '-out', 'test-manifest.wxs']' returned non-zero exit status 2148734720.

The above exception was the direct cause of the following exception:

╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────╮
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\__main__.py:15 in main                                                                                 │
│                                                                                                                                                                                  │
│   12 │   │   command, options = parse_cmdline(sys.argv[1:])                                                                                                                      │
│   13 │   │   command.check_obsolete_data_dir()                                                                                                                                   │
│   14 │   │   command.parse_config("pyproject.toml")                                                                                                                              │
│ ❱ 15 │   │   command(**options)                                                                                                                                                  │
│   16 │   │   result = 0                                                                                                                                                          │
│   17 │   except HelpText as e:                                                                                                                                                   │
│   18 │   │   log.info()                                                                                                                                                          │
│                                                                                                                                                                                  │
│ ╭──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮                                                              │
│ │ command = <briefcase.platforms.windows.app.WindowsAppPackageCommand object at 0x0000018C143E70D0>               │                                                              │
│ │       e = BriefcaseCommandError('Unable to generate manifest for app test.')                                    │                                                              │
│ │     log = <briefcase.console.Log object at 0x0000018C117AD7B0>                                                  │                                                              │
│ │ options = {'update': False, 'packaging_format': 'msi', 'sign_app': True, 'adhoc_sign': False, 'identity': None} │                                                              │
│ │  result = 200                                                                                                   │                                                              │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                              │
│                                                                                                                                                                                  │
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\commands\package.py:106 in __call__                                                                    │
│                                                                                                                                                                                  │
│   103 │   │   else:                                                                                                                                                              │
│   104 │   │   │   state = None                                                                                                                                                   │
│   105 │   │   │   for app_name, app in sorted(self.apps.items()):                                                                                                                │
│ ❱ 106 │   │   │   │   state = self._package_app(                                                                                                                                 │
│   107 │   │   │   │   │   app, update=update, **full_options(state, options)                                                                                                     │
│   108 │   │   │   │   )                                                                                                                                                          │
│   109                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭────────────────────────────────────────────── locals ──────────────────────────────────────────────╮                                                                           │
│ │      app = <com.example.test v0.0.1 AppConfig>                                                     │                                                                           │
│ │ app_name = 'test'                                                                                  │                                                                           │
│ │  options = {'packaging_format': 'msi', 'sign_app': True, 'adhoc_sign': False, 'identity': None}    │                                                                           │
│ │     self = <briefcase.platforms.windows.app.WindowsAppPackageCommand object at 0x0000018C143E70D0> │                                                                           │
│ │    state = None                                                                                    │                                                                           │
│ │   update = False                                                                                   │                                                                           │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                           │
│                                                                                                                                                                                  │
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\commands\package.py:51 in _package_app                                                                 │
│                                                                                                                                                                                  │
│    48 │   │   else:                                                                                                                                                              │
│    49 │   │   │   state = None                                                                                                                                                   │
│    50 │   │                                                                                                                                                                      │
│ ❱  51 │   │   state = self.package_app(                                                                                                                                          │
│    52 │   │   │   app, packaging_format=packaging_format, **full_options(state, options)                                                                                         │
│    53 │   │   )                                                                                                                                                                  │
│    54                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────────────────── locals ───────────────────────────────────────────────────╮                                                                 │
│ │              app = <com.example.test v0.0.1 AppConfig>                                                       │                                                                 │
│ │      binary_file = WindowsPath('C:/Users/Mustafa/Desktop/briefcase_test/test/windows/app/test/src/test.exe') │                                                                 │
│ │          options = {'sign_app': True, 'adhoc_sign': False, 'identity': None}                                 │                                                                 │
│ │ packaging_format = 'msi'                                                                                     │                                                                 │
│ │             self = <briefcase.platforms.windows.app.WindowsAppPackageCommand object at 0x0000018C143E70D0>   │                                                                 │
│ │            state = None                                                                                      │                                                                 │
│ │    template_file = WindowsPath('C:/Users/Mustafa/Desktop/briefcase_test/test/windows/app/test')              │                                                                 │
│ │           update = False                                                                                     │                                                                 │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                 │
│                                                                                                                                                                                  │
│ C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\platforms\windows\__init__.py:143 in package_app                                                       │
│                                                                                                                                                                                  │
│   140 │   │   │   │   │   cwd=self.bundle_path(app),                                                                                                                             │
│   141 │   │   │   │   )                                                                                                                                                          │
│   142 │   │   except subprocess.CalledProcessError as e:                                                                                                                         │
│ ❱ 143 │   │   │   raise BriefcaseCommandError(                                                                                                                                   │
│   144 │   │   │   │   f"Unable to generate manifest for app {app.app_name}."                                                                                                     │
│   145 │   │   │   ) from e                                                                                                                                                       │
│   146                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭───────────────────────────────────────────── locals ─────────────────────────────────────────────╮                                                                             │
│ │    app = <com.example.test v0.0.1 AppConfig>                                                     │                                                                             │
│ │ kwargs = {'packaging_format': 'msi', 'sign_app': True, 'adhoc_sign': False, 'identity': None}    │                                                                             │
│ │   self = <briefcase.platforms.windows.app.WindowsAppPackageCommand object at 0x0000018C143E70D0> │                                                                             │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
BriefcaseCommandError: Unable to generate manifest for app test.

To Reproduce Steps to reproduce the behavior:

  1. Generate new briefcase project.
  2. Build it
  3. Package it.

Expected behavior MSI is generated without error.

Screenshots image

Environment:

Additional context Add any other context about the problem here.

freakboy3742 commented 2 years ago

Return code 2148734720 is a DLL loading issue; that suggests that you haven't got .NET Framework 3.5 installed on your machine, which is a requirement of WiX. Can you confirm that this is installed?

Also - if you're getting a dialog that says "do you want to view information about this issue"... can you provide the detail that is provided when you say "Yes"?

MosGeo commented 2 years ago

The 'Yes' does link to repairing of .NET framework (link below). I did that and nothing changed. Also, I am able to generate MSI with briefcase 0.3.8 with no issues (tried it before posing the issue). I am assuming that they use the same wix version. So I think .NET is ok.

I will test now with completely clean Windows (in Windows Sandbox) and report back.

https://docs.microsoft.com/en-us/dotnet/framework/install/application-not-started?version=(null)&processName=heat.exe&platform=0009&osver=6&isServer=0&shimver=4.0.30319.0

EDIT: @freakboy3742: So I did my test in windows sandbox (fresh machine basically). It worked without any issues. I still think something fishy is still going on as 0.3.8 is working without a hitch. I will investigate further and report back once I know the issue. I don't think anybody can help in this as the problem will not be reproducible by other people as far as I can see. Thanks!

MosGeo commented 2 years ago

@freakboy3742

I found the issue. It is related to the support package (mainly wix)

  1. On my machine: briefcase does not download the support package automatically to the new location even though the folder does not exist so it fails with the above message. Copying the support package from 0.3.8 to the required 0.3.9 location manually, it works.

  2. On fresh machine: briefcase notify the user about the changes and asks if they want the files to be redownloaded or moved manually. This happens everytime briefcase does not detect the support folder (e.g., if I delete it manually).

I still don't know why this is happening. I attempted to replicate my machine by installing and using 0.3.8 and then using 0.3.9 and it still worked as expected on the fresh machine.

I would note that the upgrade command does not work in both fresh or my old machine with this error but I don't think it is related.

Briefcase will upgrade the following tools:
 - rcedit
 - wix

Log saved to C:\Users\Mustafa\Desktop\briefcase_test\3.9 copy\briefcase.2022_08_23-08_06_22.upgrade.log

Traceback (most recent call last):                                                                                                                                   
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Mustafa\Desktop\briefcase_test\.venv\Scripts\briefcase.exe\__main__.py", line 7, in <module>
  File "C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\__main__.py", line 15, in main
    command(**options)
  File "C:\Users\Mustafa\Desktop\briefcase_test\.venv\lib\site-packages\briefcase\commands\upgrade.py", line 120, in __call__
    self.logger.info(f"Upgrading {tool.full_name}...", prefix=tool.name)
AttributeError: 'RCEdit' object has no attribute 'full_name'
freakboy3742 commented 2 years ago

The RCEdit problem is definitely a bug; I've addressed that in #843.

Could I ask you to please:

  1. Attach the full log file of a crash
  2. Try running briefcase upgrade wix to just upgrade WiX, and see if the problem persists.
freakboy3742 commented 2 years ago

Closing; The RCEdit issue has been resolved, and based on the other comments in the thread, it appears the issue may have been transient.