Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify stub handling to allow for console and GUI stubs #48

Merged
merged 5 commits into from
Jun 5, 2024
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
29 changes: 11 additions & 18 deletions .github/workflows/update-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ jobs:
# Generate the stub app
cd stub
briefcase build windows visualstudio
echo "Move the binary into the final location"
mv ./build/stub/windows/visualstudio/x64/Release/Stub.exe ./Stub-${{ env.PYTHON_TAG }}.exe
echo "Move the binaries into the final location"
mv ./build/console-stub/windows/visualstudio/x64/Release/console-stub.exe ./Console-Stub-${{ env.PYTHON_TAG }}.exe
mv "./build/gui-stub/windows/visualstudio/x64/Release/GUI stub.exe" ./GUI-Stub-${{ env.PYTHON_TAG }}.exe

- name: Upload Stub Artefact
uses: actions/[email protected]
with:
name: stub-${{ matrix.python-version }}
path: stub/Stub-${{ env.PYTHON_TAG }}.exe
path: stub/*-Stub-${{ env.PYTHON_TAG }}.exe

commit-stubs:
name: Commit Stub Binaries
Expand All @@ -75,23 +76,15 @@ jobs:
export BRIEFCASE_VERSION="${TAG%-*}"
export BUILD_NUMBER="${TAG#*-}"

echo "TAG=${TAG}"
echo "PYTHON_TAG=${PYTHON_TAG}"
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}"
echo "BUILD_NUMBER=${BUILD_NUMBER}"

echo "TAG=${TAG}" >> $GITHUB_ENV
echo "PYTHON_TAG=${PYTHON_TAG}" >> $GITHUB_ENV
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}" >> $GITHUB_ENV
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
echo "TAG=${TAG}" | tee -a $GITHUB_ENV
echo "BRIEFCASE_VERSION=${BRIEFCASE_VERSION}" | tee -a $GITHUB_ENV
echo "BUILD_NUMBER=${BUILD_NUMBER}" | tee -a $GITHUB_ENV

if [ "${BRIEFCASE_VERSION}" == "dev" ]; then
# We're on the development template; push to main
echo "TEMPLATE_BRANCH=main"
echo "TEMPLATE_BRANCH=main" >> $GITHUB_ENV
echo "TEMPLATE_BRANCH=main" | tee -a $GITHUB_ENV
else
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}"
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}" >> $GITHUB_ENV
echo "TEMPLATE_BRANCH=v${BRIEFCASE_VERSION}" | tee -a $GITHUB_ENV
fi

- name: Checkout Template
Expand All @@ -108,8 +101,8 @@ jobs:
run: |
git config user.email "[email protected]"
git config user.name "Brutus (robot)"
# Move the binary into it's final location
mv stub/Stub-* "{{ cookiecutter.format }}/src"
# Move the binaries into their final location
mv stub/*-Stub-* "{{ cookiecutter.format }}/src"
git add "{{ cookiecutter.format }}/src"
git commit -m "AUTO: Update app binaries; build ${{ env.TAG }}"
git push origin HEAD:${{ env.TEMPLATE_BRANCH }}
Expand Down
5 changes: 4 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
"formal_name": "App Name",
"app_name": "{{ cookiecutter.formal_name|lower|replace(' ', '-') }}",
"module_name": "{{ cookiecutter.app_name|replace('-', '_') }}",
"bundle": "com.example",
"version_triple": "0.0.1",
"author": "Example Corporation",
"author_email": "[email protected]",
"url": "http://example.com",
"description": "Short description of app",
"console_app": false,
"guid": "1409c8f5-c276-4cf3-a2fd-defcbdfef9a2",
"install_scope": "",
"use_full_install_path": true,
"python_version": "3.X.0",
"_extensions": [
"briefcase.integrations.cookiecutter.PythonVersionExtension"
"briefcase.integrations.cookiecutter.PythonVersionExtension",
"briefcase.integrations.cookiecutter.UUIDExtension"
]
}
9 changes: 6 additions & 3 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

BIN_PATH = Path("src")

# Move the stub for the Python version into the final location
os.rename(BIN_PATH / 'Stub-{{ cookiecutter.python_version|py_tag }}.exe', BIN_PATH / '{{ cookiecutter.formal_name }}.exe')
# Rename the stub binary we want
STUB_PATH = (
BIN_PATH / '{% if cookiecutter.console_app %}Console{% else %}GUI{% endif %}-Stub-{{ cookiecutter.python_version|py_tag }}.exe'
)
STUB_PATH.rename(BIN_PATH / "Stub.exe")

# Delete all remaining stubs
for stub in BIN_PATH.glob("Stub-*.exe"):
for stub in BIN_PATH.glob("*-Stub-*.exe"):
os.unlink(stub)
15 changes: 11 additions & 4 deletions stub/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
project_name = "Stub"
bundle = "org.beeware"
version = "1.0.0"
license.file = "../LICENSE"

[tool.briefcase.app.stub]
formal_name = "Stub"
description = "A stub binary that can be integrated into the Windows app template"
sources = ['src/stub']
[tool.briefcase.app.gui-stub]
formal_name = "GUI Stub"
description = "A stub binary for GUI apps that can be integrated into the Windows app template"
sources = ['src/gui_stub']

[tool.briefcase.app.console-stub]
formal_name = "Console Stub"
description = "A stub binary for console apps that can be integrated into the Windows app template"
sources = ['src/console_stub']
console_app = true
File renamed without changes.
Empty file added stub/src/gui_stub/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added {{ cookiecutter.format }}/src/GUI-Stub-3.10.exe
Binary file not shown.
Binary file added {{ cookiecutter.format }}/src/GUI-Stub-3.11.exe
Binary file not shown.
Binary file added {{ cookiecutter.format }}/src/GUI-Stub-3.12.exe
Binary file not shown.
Binary file added {{ cookiecutter.format }}/src/GUI-Stub-3.8.exe
Binary file not shown.
Binary file added {{ cookiecutter.format }}/src/GUI-Stub-3.9.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.10.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.11.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.12.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.8.exe
Binary file not shown.
Binary file removed {{ cookiecutter.format }}/src/Stub-3.9.exe
Binary file not shown.
22 changes: 19 additions & 3 deletions {{ cookiecutter.format }}/{{ cookiecutter.app_name }}.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@
<Directory Id="{{ cookiecutter.module_name }}_ROOTDIR" Name="{{ cookiecutter.formal_name }}" />
{%- endif %}
</Directory>

{% if cookiecutter.console_app %}
<Component Id="SystemPathEnv" Guid="{{ ".".join(["system-path", cookiecutter.app_name] + cookiecutter.bundle.split(".")[::-1])|dns_uuid5 }}">
<Environment Id="AppendSystemPathEnvValue" Name="PATH" Action="set" Part="last" System="yes" Value="[{{ cookiecutter.module_name }}_ROOTDIR]" Permanent="no" />
</Component>
<Component Id="UserPathEnv" Guid="{{ ".".join(["user-path", cookiecutter.app_name] + cookiecutter.bundle.split(".")[::-1])|dns_uuid5 }}">
<Environment Id="AppendUserPathEnvValue" Name="PATH" Action="set" Part="last" System="no" Value="[{{ cookiecutter.module_name }}_ROOTDIR]" Permanent="no" />
</Component>
{% endif %}
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="{{ cookiecutter.formal_name }}">
<Component
Expand All @@ -76,7 +83,7 @@
Name="{{ cookiecutter.formal_name }}"
Icon="ProductIcon"
Description="{{ cookiecutter.description }}"
Target="[{{ cookiecutter.module_name }}_ROOTDIR]{{ cookiecutter.formal_name }}.exe"
Target="[{{ cookiecutter.module_name }}_ROOTDIR]{% if cookiecutter.console_app %}{{ cookiecutter.app_name }}{% else %}{{ cookiecutter.formal_name }}{% endif %}.exe"
/>
<RegistryValue
Root="HKCU"
Expand All @@ -99,7 +106,16 @@
<ComponentGroupRef Id="{{ cookiecutter.module_name }}_COMPONENTS" />
<ComponentRef Id="ApplicationShortcuts"/>
</Feature>

{% if cookiecutter.console_app %}
<Feature Id="SystemPathEnvFeature" Level="1">
<Condition Level="0">ALLUSERS=2 OR MSIINSTALLPERUSER=1</Condition>
<ComponentRef Id="SystemPathEnv"/>
</Feature>
<Feature Id="UserPathEnvFeature" Level="1">
<Condition Level="0">ALLUSERS=1</Condition>
<ComponentRef Id="UserPathEnv"/>
</Feature>
{% endif %}
<WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
<WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />

Expand Down