Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ jobs:
run: conda list
- name: conda config
run: conda config --show-sources

- name: Checkout Briefcase (pinned)
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: beeware/briefcase
ref: efb0e08c2a9ce72dcebd0a62c12f5662fd5eb0e0 # this is a commit with latest necessary changes on the main branch
path: briefcase
fetch-depth: 1

- name: Install Briefcase (editable)
run: |
pip install -e briefcase
- name: Run unit tests
run: |
pytest -vv --cov=constructor --cov-branch tests/ -m "not examples"
Expand All @@ -153,6 +165,7 @@ jobs:
AZURE_SIGNTOOL_KEY_VAULT_URL: ${{ secrets.AZURE_SIGNTOOL_KEY_VAULT_URL }}
CONSTRUCTOR_EXAMPLES_KEEP_ARTIFACTS: "${{ runner.temp }}/examples_artifacts"
CONSTRUCTOR_SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x86/signtool.exe"
CONSTRUCTOR_VERBOSE: 1
run: |
rm -rf coverage.json
pytest -vv --cov=constructor --cov-branch tests/test_examples.py
Expand Down
21 changes: 18 additions & 3 deletions constructor/briefcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
import re
import sys
import shutil
import sysconfig
import tempfile
Expand All @@ -22,8 +23,7 @@


def get_name_version(info):
name = info["name"]
if not name:
if not (name := info.get("name")):
raise ValueError("Name is empty")

# Briefcase requires version numbers to be in the canonical Python format, and some
Expand Down Expand Up @@ -86,6 +86,13 @@ def get_bundle_app_name(info, name):

return bundle, app_name

def get_license(info):
""" Retrieve the specified license as a dict or return a placeholder if not set. """

if "license_file" in info:
return {"file": info["license_file"]}
# We cannot return an empty string because that results in an exception on the briefcase side.
return {"text": "TODO"}

# Create a Briefcase configuration file. Using a full TOML writer rather than a Jinja
# template allows us to avoid escaping strings everywhere.
Expand All @@ -97,7 +104,7 @@ def write_pyproject_toml(tmp_dir, info):
"project_name": name,
"bundle": bundle,
"version": version,
"license": ({"file": info["license_file"]} if "license_file" in info else {"text": ""}),
"license": get_license(info),
"app": {
app_name: {
"formal_name": f"{info['name']} {info['version']}",
Expand All @@ -117,6 +124,9 @@ def write_pyproject_toml(tmp_dir, info):


def create(info, verbose=False):
if sys.platform != 'win32':
raise Exception(f"Invalid platform '{sys.platform}'. Only Windows is supported.")

tmp_dir = Path(tempfile.mkdtemp())
write_pyproject_toml(tmp_dir, info)

Expand All @@ -133,6 +143,11 @@ def create(info, verbose=False):
copy_conda_exe(external_dir, "_conda.exe", info["_conda_exe"])

briefcase = Path(sysconfig.get_path("scripts")) / "briefcase.exe"
if not briefcase.exists():
raise FileNotFoundError(
f"Dependency 'briefcase' does not seem to be installed.\n"
f"Tried: {briefcase}"
)
logger.info("Building installer")
run(
[briefcase, "package"] + (["-v"] if verbose else []),
Expand Down
2 changes: 1 addition & 1 deletion examples/azure_signtool/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Signed_AzureSignTool
version: X
version: 1.0.0
installer_type: exe
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_nsis_template/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: custom
version: X
version: 1.0.0
ignore_duplicate_files: True
installer_filename: {{ name }}-installer.exe
installer_type: exe
Expand Down
2 changes: 1 addition & 1 deletion examples/customize_controls/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: NoCondaOptions
version: X
version: 1.0.0
installer_type: all

channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/customized_welcome_conclusion/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: CustomizedWelcomeConclusion
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/exe_extra_pages/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% set name = "extraPageSingle" %}
{% endif %}
name: {{ name }}
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/extra_envs/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: ExtraEnvs
version: X
version: 1.0.0
installer_type: all
channels:
- https://conda.anaconda.org/conda-forge
Expand Down
2 changes: 1 addition & 1 deletion examples/extra_files/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: ExtraFiles
version: X
version: 1.0.0
installer_type: all
check_path_spaces: False
check_path_length: False
Expand Down
2 changes: 1 addition & 1 deletion examples/from_env_txt/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: EnvironmentTXT
version: X
version: 1.0.0
installer_type: all
environment_file: env.txt
initialize_by_default: false
Expand Down
2 changes: 1 addition & 1 deletion examples/from_env_yaml/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: EnvironmentYAML
version: X
version: 1.0.0
installer_type: all
environment_file: env.yaml
initialize_by_default: false
Expand Down
2 changes: 1 addition & 1 deletion examples/from_existing_env/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=../../constructor/data/construct.schema.json
"$schema": "../../constructor/data/construct.schema.json"
name: Existing
version: X
version: 1.0.0
installer_type: all
environment: {{ os.environ.get("CONSTRUCTOR_TEST_EXISTING_ENV", os.environ["CONDA_PREFIX"]) }}
channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/from_explicit/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Explicit
version: X
version: 1.0.0
installer_type: all
environment_file: explicit_linux-64.txt
initialize_by_default: false
Expand Down
2 changes: 1 addition & 1 deletion examples/miniconda/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: MinicondaX
version: X
version: 1.0.0
installer_type: all

channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/mirrored_channels/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Mirrors
version: X
version: 1.0.0

channels:
- conda-forge
Expand Down
2 changes: 1 addition & 1 deletion examples/noconda/constructor_input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: NoConda
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/outputs/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Outputs
version: X
version: 1.0.0
installer_type: sh # [unix]
installer_type: exe # [win]
channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/protected_base/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: ProtectedBaseEnv
version: X
version: 1.0.0
installer_type: all

channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/register_envs/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: RegisterEnvs
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Scripts
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
2 changes: 1 addition & 1 deletion examples/shortcuts/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: MinicondaWithShortcuts
version: X
version: 1.0.0
installer_type: all

channels:
Expand Down
2 changes: 1 addition & 1 deletion examples/signing/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../constructor/data/construct.schema.json"

name: Signed
version: X
version: 1.0.0
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [
"jinja2",
"jsonschema >=4",
"tomli-w >=1.2.0",
"briefcase"
]

[project.optional-dependencies]
Expand Down
Loading