55import logging
66import re
77import shutil
8+ import sys
89import sysconfig
910import tempfile
1011from pathlib import Path
1112from subprocess import run
1213
13- import tomli_w
14+ IS_WINDOWS = sys .platform == "win32"
15+ if IS_WINDOWS :
16+ import tomli_w
17+ else :
18+ tomli_w = None # This file is only intended for Windows use
1419
1520from . import preconda
1621from .utils import DEFAULT_REVERSE_DOMAIN_ID , copy_conda_exe , filename_dist
@@ -100,6 +105,15 @@ def get_bundle_app_name(info, name):
100105 return bundle , app_name
101106
102107
108+ def get_license (info ):
109+ """Retrieve the specified license as a dict or return a placeholder if not set."""
110+
111+ if "license_file" in info :
112+ return {"file" : info ["license_file" ]}
113+ # We cannot return an empty string because that results in an exception on the briefcase side.
114+ return {"text" : "TODO" }
115+
116+
103117# Create a Briefcase configuration file. Using a full TOML writer rather than a Jinja
104118# template allows us to avoid escaping strings everywhere.
105119def write_pyproject_toml (tmp_dir , info ):
@@ -110,7 +124,7 @@ def write_pyproject_toml(tmp_dir, info):
110124 "project_name" : name ,
111125 "bundle" : bundle ,
112126 "version" : version ,
113- "license" : ({ "file" : info [ "license_file" ]} if "license_file" in info else { "text" : "" } ),
127+ "license" : get_license ( info ),
114128 "app" : {
115129 app_name : {
116130 "formal_name" : f"{ info ['name' ]} { info ['version' ]} " ,
@@ -130,6 +144,9 @@ def write_pyproject_toml(tmp_dir, info):
130144
131145
132146def create (info , verbose = False ):
147+ if not IS_WINDOWS :
148+ raise Exception (f"Invalid platform '{ sys .platform } '. Only Windows is supported." )
149+
133150 tmp_dir = Path (tempfile .mkdtemp ())
134151 write_pyproject_toml (tmp_dir , info )
135152
@@ -150,7 +167,6 @@ def create(info, verbose=False):
150167 raise FileNotFoundError (
151168 f"Dependency 'briefcase' does not seem to be installed.\n Tried: { briefcase } "
152169 )
153-
154170 logger .info ("Building installer" )
155171 run (
156172 [briefcase , "package" ] + (["-v" ] if verbose else []),
0 commit comments