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

fix: restructure #41

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/desktop-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Desktop App

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, windows, macos]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install build dependencies (ubuntu)
if: matrix.os == 'ubuntu'
run: |
sudo apt update
sudo apt install libbluetooth-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install .
- name: Build package
run: |
bash build.sh ${{ matrix.os }}
- name: Upload package artifact
if: matrix.os != 'macos'
uses: actions/upload-artifact@v2
with:
name: pytouch-cube-${{ matrix.os }}
path: dist/pytouch-cube/*
- name: Upload app bundle artifact (macOS)
if: matrix.os == 'macos'
uses: actions/upload-artifact@v2
with:
name: pytouch-cube-${{ matrix.os }}
path: dist/*.app
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"python.analysis.extraPaths": [
"./src"
],
"files.exclude": {
"**/__pycache__": true,
"build": true,
"dist": true
}
}
4 changes: 0 additions & 4 deletions app.py

This file was deleted.

29 changes: 29 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

APP_SCRIPT='src/pytouch_cube/__main__.py'
ICON='pytouch3.ico'
IMG_DATA="pytouch3.png:."

case "$1" in
"windows")
IMG_DATA=$(echo "$IMG_DATA" | tr ':' ';')
;;
"macos")
ICON="pytouch3.icns"
;;
esac

VER=$(git describe || echo "0.10-${GITHUB_EVENT_NAME:-build}")

echo "APP_VERSION = '$VER'" > src/pytouch_cube/version.py

echo "version.py:"
cat src/pytouch_cube/version.py
echo

pyinstaller \
--windowed \
--add-data="$IMG_DATA" \
--icon="$ICON" \
--name pytouch-cube \
--collect-all=pytouch_cube \
"$APP_SCRIPT"
2 changes: 0 additions & 2 deletions cli/__init__.py

This file was deleted.

46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[project]
name = "pytouch-cube"
version = "0.10.0"
authors = [
{ name="nils måsén", email="nils@piksel.se" },
{ name="Mimoja", email="git@mimoja.de" },
{ name="Sophie Tyalie", email="dev@flowerpot.me" },
]
description = "Qt6 Label Editor for Brother P-Touch Cube label maker"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
'PyQt6>=6.3',
'django-qrcode~=0.3',
'pyserial~=3.4',
'packbits~=0.6',
'pypng',
'appdirs~=1.4.4',
'pyyaml~=5.4.0',
'qrcode~=6.1',
'qasync~=0.23.0',
'altgraph~=0.17',
'pybluez @ git+https://github.com/pybluez/pybluez.git@37d7888',
]

[project.urls]
"Homepage" = "https://github.com/piksel/pytouch-cube"
"Bug Tracker" = "https://github.com/piksel/pytouch-cube/issues"

[project.gui-scripts]
pytouch-cube = "pytouch_cube:main"

[project.scripts]
pytouch-cube = "pytouch_cube:main"

[build-system]
requires = [
"setuptools>=61.0",
]
build-backend = "setuptools.build_meta"
61 changes: 0 additions & 61 deletions pytouch3.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pyyaml~=5.4.0
qrcode~=6.1
qasync~=0.23.0
altgraph~=0.17
git+https://github.com/pybluez/pybluez.git@37d7888#egg=pybluez; sys_platform == 'linux'
git+https://github.com/pybluez/pybluez.git@37d7888#egg=pybluez
46 changes: 28 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@
"""

from setuptools import setup
from util import *
import app
import site
import site, os, re, sys

qt_plugin_root = site.getsitepackages()[1] + "\\PyQt6\\Qt\\plugins"
with open(os.path.join('src', 'pytouch_cube', 'version.py'), encoding='utf-8') as f:
version = re.search(r"^APP_VERSION = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)

if not version:
raise RuntimeError('Failed to parse version information')

APP = 'pytouch3.py'
data_files = [
('', ['pytouch3.png']),
]

setup_requires = []
requires = ['PyQt6', 'django-qrcode', 'pyserial', 'packbits', 'pypng', 'appdirs']
setup_requires = ['setuptools>=61']
requires = ['PyQt6', 'django-qrcode', 'pyserial', 'packbits', 'pypng', 'appdirs', 'qasync']
kwargs = {}

if is_mac:
setup_requires = ['py2app']
elif is_win:
if sys.argv[1:2] == ['py2app']:
setup_requires.append('py2app')
elif sys.argv[1:2] == ['py2exe']:
qt_plugin_root = site.getsitepackages()[1] + "\\PyQt6\\Qt\\plugins"
kwargs = {
"windows": [{
"script": APP[0],
"script": 'pytouch-cube/__init__.py',
"icon_resources": [(0, "pytouch3.ico")],
"dest_base": "pytouch3"
}],
}
setup_requires = ['py2exe~=0.10.2.1']
requires += ['wmi']
setup_requires.append('py2exe~=0.10.2.1')
requires.append('wmi')
data_files += [
("platforms", [ qt_plugin_root + "\\platforms\\qwindows.dll"]),
("iconengines", [qt_plugin_root + "\\iconengines\\qsvgicon.dll"]),
Expand All @@ -42,11 +44,11 @@
else:
pass


setup(
name=app.APP_NAME,
version=app.APP_VERSION,
author=app.APP_AUTHOR,
app=[APP],
name='pytouch-cube',
version=version,
author='piksel bitworks',
data_files=data_files,
options={
'py2app': {
Expand All @@ -60,8 +62,16 @@
]
}
},

setup_requires=setup_requires,
install_requires=requires,
package_dir={'': 'src'},
packages=[
'pytouch_cube',
'pytouch_cube.cli',
'pytouch_cube.gui',
'pytouch_cube.printing',
'pytouch_cube.printables',
'barcode',
'barcode.charsets'],
**kwargs
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/pytouch3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pytouch_cube.cli import run

run()
6 changes: 6 additions & 0 deletions src/pytouch_cube/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .version import APP_VERSION

__version__ = APP_VERSION

APP_NAME = 'PyTouch Cube Editor'
APP_AUTHOR = 'piksel bitworks'
3 changes: 3 additions & 0 deletions src/pytouch_cube/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pytouch_cube.cli import run

run()
9 changes: 9 additions & 0 deletions src/pytouch_cube/_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum, auto
from typing import *

Color = Tuple[int, int, int]

class ItemType(Enum):
Image = auto()
Text = auto()
Barcode = auto()
19 changes: 19 additions & 0 deletions src/pytouch_cube/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys, logging

from .arguments import get_parser
from .cli_print import CliPrint
from .cli_gui import CliGui

def run():
if not sys.gettrace() is None:
logging.basicConfig(level=logging.DEBUG)

parser = get_parser()
args = parser.parse_args()
match args.runtime:
case "print":
CliPrint.run(args)
case "gui" | "":
CliGui.run("seed" in args and args.seed)
case _:
raise RuntimeError(f"Invalid action {args.runtime}")
2 changes: 1 addition & 1 deletion cli/arguments.py → src/pytouch_cube/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import fields, MISSING


from labelmaker.config import LabelMakerConfig
from pytouch_cube.printing.config import LabelMakerConfig


class OrderArguments(argparse.Action):
Expand Down
Loading