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 template to be v0.3 compliant. #16

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
84a37ae
Modify template to be v0.3 compliant.
freakboy3742 Dec 7, 2019
0480fc7
Merge branch 'master' into v0.3
freakboy3742 Dec 7, 2019
8f1d90c
Updated details to be compatible with v0.3 briefcase.
freakboy3742 Dec 8, 2019
110431a
Corrected iOS platform name.
freakboy3742 Dec 8, 2019
d401a42
Add proprietary license option and distinct project name.
freakboy3742 Dec 13, 2019
786df62
Make the module name check PEP508 compliant.
freakboy3742 Dec 15, 2019
4148a04
Make sure module name is used in the right places.
freakboy3742 Dec 15, 2019
d8a98e7
Expose class name as a template variable.
freakboy3742 Dec 15, 2019
4a56d45
Expose module_name as a variable.
freakboy3742 Dec 17, 2019
92ab8dc
Correctly reference class_name variable
freakboy3742 Dec 17, 2019
8130417
Another use of module name, rather than app_name.
freakboy3742 Dec 17, 2019
2e3c451
Use .dev16 toga build.
freakboy3742 Dec 28, 2019
17613bb
Make sure ICNS file is RGB profile.
freakboy3742 Dec 30, 2019
36c153a
Update template to latest Toga changes.
freakboy3742 Jan 1, 2020
dd03074
Bumped the toga requirement again.
freakboy3742 Jan 1, 2020
72f69b3
Add support for PPB
AstraLuma Apr 16, 2020
4b59268
Fix up some problems
AstraLuma Apr 16, 2020
2f9ad9f
Merge pull request #17 from astronouth7303/add-ppb
freakboy3742 Apr 20, 2020
e2acf0b
Add system requirements for Toga AppImage builds.
freakboy3742 May 2, 2020
e40b1b9
Fix pyproject.toml formatting error
GenevieveBuckley May 23, 2020
5da13fa
Merge pull request #18 from GenevieveBuckley/fix-pyproject-toml-forma…
freakboy3742 May 23, 2020
28ce801
Include setuptools, wheel, in build-system specs
GenevieveBuckley May 24, 2020
4a0038b
Remove build-system from pyproject.toml
GenevieveBuckley May 25, 2020
1d2a435
Merge pull request #20 from GenevieveBuckley/patch-1
freakboy3742 May 26, 2020
48b9039
Add tests for briefcase cookiecutter template
GenevieveBuckley May 26, 2020
f746bda
Must add build-backend key so tox won't complain
GenevieveBuckley May 27, 2020
ecb3dbd
Make pathnames multi-plaform, also fix typo
GenevieveBuckley May 27, 2020
3d6f797
Add pathlib explicitly for Python2.7 tox runs
GenevieveBuckley May 27, 2020
8f9e63d
Fix tests for python 2.7
GenevieveBuckley May 27, 2020
3dbd81c
Add github actions CI script
GenevieveBuckley May 27, 2020
060e4be
Black reformatting tests
GenevieveBuckley May 27, 2020
bcf9ad6
Update .github/workflows/run_tests.yml
GenevieveBuckley May 28, 2020
f6420fd
Update .github/workflows/run_tests.yml
GenevieveBuckley May 28, 2020
e662b35
Test only python3.5 and local python with tox
GenevieveBuckley May 28, 2020
04868d9
Rename github actions CI file
GenevieveBuckley May 28, 2020
8ce9be2
Remove unneccesary test of ap file structure
GenevieveBuckley May 28, 2020
7a08dc1
Fix typo
GenevieveBuckley May 28, 2020
e3a820f
Tox - skip install before tests
GenevieveBuckley May 28, 2020
2028ec1
Fixture cleanup not needed, Russell says
GenevieveBuckley May 28, 2020
7dd4066
Use toml instead of tomlkit for tests
GenevieveBuckley May 28, 2020
5adb5be
Switch to pathlib.Path wherever possible
GenevieveBuckley May 29, 2020
5b16492
Parameterize tests so they run for all GUI frameworks
GenevieveBuckley May 29, 2020
281b2e0
Merge pull request #21 from GenevieveBuckley/v0.3-test-suite
freakboy3742 May 29, 2020
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install tox
- name: Test with tox
run: |
tox
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.python-version
.vscode
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing

BeeWare <3's contributions!

Please be aware, BeeWare operates under a Code of Conduct.

See [CONTRIBUTING to BeeWare](https://beeware.org/contributing) for details.

21 changes: 11 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Using this template

2. Run ``cookiecutter`` on this template::

$ cookiecutter https://github.com/pybee/briefcase-template
$ cookiecutter https://github.com/beeware/briefcase-template

3. Add your code to the project.

Expand All @@ -22,14 +22,15 @@ Using this template

$ pip install briefcase

5. Use Briefcase to generate the artifacts for your platform of choice::
5. Use Briefcase to generate a project::

$ python setup.py ios
$ python setup.py android
$ python setup.py macos
$ python setup.py windows
$ python setup.py linux
$ python setup.py django
$ briefcase create
$ briefcase run

.. _cookiecutter: http://github.com/audreyr/cookiecutter
.. _briefcase: http://github.com/pybee/briefcase
To build for a mobile platform, add the platform name::

$ briefcase create iOS
$ briefcase run iOS

.. _cookiecutter: http://github.com/cookiecutter/cookiecutter
.. _briefcase: http://github.com/beeware/briefcase
6 changes: 6 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"formal_name": "Hello World",
"app_name": "{{ cookiecutter.formal_name|lower|replace(' ', '') }}",
"class_name": "{{ cookiecutter.formal_name.title().replace(' ','').replace('-','').replace('!','').replace('.','').replace(',','') }}",
"module_name": "{{ cookiecutter.app_name|lower|replace('-', '_') }}",
"project_name": "Project Awesome",
"description": "An app that does lots of stuff",
"author": "Jane Developer",
"author_email": "[email protected]",
"bundle": "com.example",
"url": "https://example.com",
"license": [
"BSD license",
"MIT license",
Expand All @@ -13,11 +17,13 @@
"GNU General Public License v2 or later (GPLv2+)",
"GNU General Public License v3 (GPLv3)",
"GNU General Public License v3 or later (GPLv3+)",
"Proprietary",
"Other"
],
"gui_framework": [
"Toga",
"PySide2",
"PursuedPyBear",
"None"
]
}
10 changes: 7 additions & 3 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import sys


MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$'
# The restriction on application naming comes from PEP508
PEP508_NAME_RE = re.compile(
r'^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$',
re.IGNORECASE
)

app_name = '{{ cookiecutter.app_name }}'

if not re.match(MODULE_REGEX, app_name):
print('ERROR: `%s` is not a valid Python module name!' % app_name)
if not re.match(PEP508_NAME_RE, app_name):
print('ERROR: `%s` is not a valid Python package name!' % app_name)

# exits with status 1 to indicate failure
sys.exit(1)
66 changes: 66 additions & 0 deletions tests/test_app_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pathlib
import shutil

from cookiecutter import main
from flake8.api import legacy as flake8
import py_compile
import pytest
import toml

TEST_CASES = [
{}, # use only the default briefcase-template values
{"gui_framework": "1"}, # Toga GUI framework
{"gui_framework": "2"}, # PySide2 GUI framework
{"gui_framework": "3"}, # PursuedPyBear GUI framework
{"gui_framework": "4"}, # "None" for GUI framework
]


@pytest.fixture
def app_directory(tmpdir_factory, args):
"""Fixture for a default app."""
print(args)
output_dir = tmpdir_factory.mktemp("default-app")
output_dir = pathlib.Path(str(output_dir)).resolve()
root_dir = pathlib.Path(__file__).parent.parent.resolve()
main.cookiecutter(
str(root_dir), no_input=True, output_dir=str(output_dir),
)
return output_dir


def _all_filenames(directory):
"""Return list of filenames in a directory, excluding __pycache__ files."""
filenames = []
for root, _, files in pathlib.os.walk(str(directory)):
for f in files:
full_filename = root+pathlib.os.sep+f
if "__pycache__" not in full_filename:
filenames.append(full_filename)
filenames.sort()
return filenames


@pytest.mark.parametrize('args', TEST_CASES)
def test_parse_pyproject_toml(app_directory):
"""Test for errors in parsing the generated pyproject.toml file."""
pyproject_toml = app_directory/"helloworld"/"pyproject.toml"
assert pyproject_toml.is_file() # check pyproject.toml exists
toml.load(pyproject_toml) # any error in parsing will trigger pytest


@pytest.mark.parametrize('args', TEST_CASES)
def test_flake8_app(app_directory, args):
"""Check there are no flake8 errors in any of the generated python files"""
files = [f for f in _all_filenames(app_directory) if f.endswith(".py")]
style_guide = flake8.get_style_guide()
report = style_guide.check_files(files)
assert report.get_statistics("E") == [], "Flake8 found violations"


@pytest.mark.parametrize('args', TEST_CASES)
def test_files_compile(app_directory, args):
files = [f for f in _all_filenames(app_directory) if f.endswith(".py")]
for filename in files:
# If there is a compilation error, pytest is triggered
py_compile.compile(filename)
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tox]
envlist = py, py35

[testenv]
skip_install = True
deps =
cookiecutter
flake8
pytest
pytest-tldr
toml
commands = pytest
4 changes: 4 additions & 0 deletions {{ cookiecutter.app_name }}/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
{% elif cookiecutter.license == 'Proprietary' %}
Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.author }}

All rights reserved.
{% endif %}
6 changes: 3 additions & 3 deletions {{ cookiecutter.app_name }}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ consider** `becoming a financial member of BeeWare`_.

{{ cookiecutter.description }}

.. _`Briefcase`: https://github.com/pybee/briefcase
.. _`The BeeWare Project`: https://pybee.org/
.. _`becoming a financial member of BeeWare`: https://pybee.org/contributing/membership
.. _`Briefcase`: https://github.com/beeware/briefcase
.. _`The BeeWare Project`: https://beeware.org/
.. _`becoming a financial member of BeeWare`: https://beeware.org/contributing/membership
67 changes: 67 additions & 0 deletions {{ cookiecutter.app_name }}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[tool.briefcase]
project_name = "{{ cookiecutter.project_name }}"
bundle = "{{ cookiecutter.bundle }}"
version = "0.0.1"
url = "{{ cookiecutter.url }}"
license = "{{ cookiecutter.license }}"
author = '{{ cookiecutter.author }}'
author_email = "{{ cookiecutter.author_email }}"

[tool.briefcase.app.{{ cookiecutter.app_name }}]
formal_name = "{{ cookiecutter.formal_name }}"
description = "{{ cookiecutter.description }}"
icon = "src/{{ cookiecutter.module_name }}/resources/{{ cookiecutter.app_name }}"
sources = ['src/{{ cookiecutter.module_name }}']
requires = [
{%- if cookiecutter.gui_framework == 'PySide2' %}
'pyside2==5.13.0',
{%- elif cookiecutter.gui_framework == 'PursuedPyBear' %}
'ppb~=0.8.0',
{% endif -%}
]


[tool.briefcase.app.{{ cookiecutter.app_name }}.macOS]
requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'toga-cocoa>=0.3.0.dev18',
{% endif -%}
]

[tool.briefcase.app.{{ cookiecutter.app_name }}.linux]
requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'toga-gtk>=0.3.0.dev18',
{% endif -%}
]
system_requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'libgirepository1.0-dev',
'libcairo2-dev',
'libpango1.0-dev',
'libwebkitgtk-3.0-0',
'gir1.2-webkit-3.0',
{% endif -%}
]

[tool.briefcase.app.{{ cookiecutter.app_name }}.windows]
requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'toga-winforms>=0.3.0.dev18',
{% endif -%}
]

# Mobile deployments
[tool.briefcase.app.{{ cookiecutter.app_name }}.iOS]
requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'toga-iOS>=0.3.0.dev18',
{% endif -%}
]

[tool.briefcase.app.{{ cookiecutter.app_name }}.android]
requires = [
{%- if cookiecutter.gui_framework == 'Toga' %}
'toga-android>=0.3.0.dev18',
{% endif -%}
]
84 changes: 0 additions & 84 deletions {{ cookiecutter.app_name }}/setup.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from {{ cookiecutter.app_name }}.app import main
from {{ cookiecutter.module_name }}.app import main

if __name__ == '__main__':
{%- if cookiecutter.gui_framework == 'Toga' %}
Expand Down
Loading