Skip to content

Commit ad8791d

Browse files
committed
Add tests
1 parent a2caeec commit ad8791d

File tree

31 files changed

+226
-53
lines changed

31 files changed

+226
-53
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
run: conda list
135135
- name: conda config
136136
run: conda config --show-sources
137+
137138
- name: Run unit tests
138139
run: |
139140
pytest -vv --cov=constructor --cov-branch tests/ -m "not examples"
@@ -152,6 +153,7 @@ jobs:
152153
AZURE_SIGNTOOL_KEY_VAULT_URL: ${{ secrets.AZURE_SIGNTOOL_KEY_VAULT_URL }}
153154
CONSTRUCTOR_EXAMPLES_KEEP_ARTIFACTS: "${{ runner.temp }}/examples_artifacts"
154155
CONSTRUCTOR_SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x86/signtool.exe"
156+
CONSTRUCTOR_VERBOSE: 1
155157
run: |
156158
rm -rf coverage.json
157159
pytest -vv --cov=constructor --cov-branch tests/test_examples.py

constructor/briefcase.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
import logging
66
import re
77
import shutil
8+
import sys
89
import sysconfig
910
import tempfile
1011
from pathlib import Path
1112
from 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

1520
from . import preconda
1621
from .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.
105119
def 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

132146
def 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.\nTried: {briefcase}"
152169
)
153-
154170
logger.info("Building installer")
155171
run(
156172
[briefcase, "package"] + (["-v"] if verbose else []),
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
set PREFIX=%cd%
2-
_conda constructor --prefix %PREFIX% --extract-conda-pkgs
1+
set "PREFIX=%cd%"
2+
_conda constructor --prefix "%PREFIX%" --extract-conda-pkgs
33

44
set CONDA_PROTECT_FROZEN_ENVS=0
55
set CONDA_ROOT_PREFIX=%PREFIX%
66
set CONDA_SAFETY_CHECKS=disabled
77
set CONDA_EXTRA_SAFETY_CHECKS=no
88
set CONDA_PKGS_DIRS=%PREFIX%\pkgs
99

10-
_conda install --offline --file %PREFIX%\conda-meta\initial-state.explicit.txt -yp %PREFIX%
10+
_conda install --offline --file "%PREFIX%\conda-meta\initial-state.explicit.txt" -yp "%PREFIX%"

examples/azure_signtool/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: Signed_AzureSignTool
5-
version: X
5+
version: 1.0.0
66
installer_type: exe
77
channels:
88
- https://repo.anaconda.com/pkgs/main/

examples/custom_nsis_template/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: custom
5-
version: X
5+
version: 1.0.0
66
ignore_duplicate_files: True
77
installer_filename: {{ name }}-installer.exe
88
installer_type: exe

examples/customize_controls/construct.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: NoCondaOptions
5-
version: X
6-
installer_type: all
5+
version: 1.0.0
6+
installer_type: {{ "exe" if os.name == "nt" else "all" }}
77

88
channels:
99
- https://repo.anaconda.com/pkgs/main/

examples/customized_welcome_conclusion/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: CustomizedWelcomeConclusion
5-
version: X
5+
version: 1.0.0
66
installer_type: all
77
channels:
88
- https://repo.anaconda.com/pkgs/main/

examples/exe_extra_pages/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% set name = "extraPageSingle" %}
88
{% endif %}
99
name: {{ name }}
10-
version: X
10+
version: 1.0.0
1111
installer_type: all
1212
channels:
1313
- https://repo.anaconda.com/pkgs/main/

examples/extra_envs/construct.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: ExtraEnvs
5-
version: X
6-
installer_type: all
5+
version: 1.0.0
6+
installer_type: {{ "exe" if os.name == "nt" else "all" }}
77
channels:
88
- https://conda.anaconda.org/conda-forge
99
specs:

examples/extra_files/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../../constructor/data/construct.schema.json"
33

44
name: ExtraFiles
5-
version: X
5+
version: 1.0.0
66
installer_type: all
77
license_file: TEST_LICENSE.txt
88
check_path_spaces: False

0 commit comments

Comments
 (0)