Skip to content

Commit 90c4bcc

Browse files
author
Dmitry Berezovsky
committed
feat: update libraries and migrate to poetry for builds
1 parent 449f067 commit 90c4bcc

33 files changed

+1952
-335
lines changed

Makefile

+39-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PYPI_API_KEY :=
77
PYPI_REPOSITORY_URL :=
88
ALPHA_VERSION :=
99
SRC_ROOT := ./src
10+
FORMAT_PATH := $(SRC_ROOT)
1011

1112
.DEFAULT_GOAL := pre_commit
1213

@@ -17,8 +18,10 @@ copyright:
1718
@( \
1819
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
1920
echo "Applying copyright..."; \
20-
./development/copyright-update; \
21-
echo "DONE: copyright"; \
21+
for p in $(FORMAT_PATH); do \
22+
licenseheaders -t ./development/copyright.tmpl -E ".py" -cy -d $$p; \
23+
done; \
24+
echo "Done: copyright"; \
2225
)
2326

2427
flake8:
@@ -68,23 +71,25 @@ build: copyright format lint clean
6871
set -e; \
6972
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
7073
echo "Building wheel package..."; \
71-
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../build"; \
74+
poetry build; \
7275
echo "DONE: wheel package"; \
7376
)
77+
78+
package:
7479
@( \
75-
set -e; \
76-
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
77-
echo "Building source distribution..."; \
78-
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py sdist --dist-dir=../dist"; \
79-
echo "DONE: source distribution"; \
80-
)
80+
echo "Building packages"; \
81+
set -e; \
82+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
83+
poetry build; \
84+
echo "DONE: Building packages"; \
85+
)
8186

8287
single-binary:
8388
@( \
8489
set -e; \
8590
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
8691
echo "Building single binary"; \
87-
bash -c "pyinstaller --windowed tapen.spec"; \
92+
bash -c "pyinstaller tapen.spec"; \
8893
echo "DONE: wheel package"; \
8994
)
9095

@@ -111,12 +116,32 @@ set-version:
111116

112117
deps:
113118
@( \
114-
source ./venv/bin/activate; \
115-
pip install -r ./requirements-dev.txt; \
119+
set -e; \
120+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
121+
poetry install --all-extras --no-root; \
122+
)
123+
124+
deps-update:
125+
@( \
126+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
127+
poetry lock; \
128+
)
129+
130+
deps-lock:
131+
@( \
132+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
133+
poetry lock --no-update \
134+
)
135+
136+
deps-tree:
137+
@( \
138+
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
139+
poetry show --tree; \
116140
)
117141

142+
.PHONY: venv
118143
venv:
119144
@( \
120-
virtualenv $(VIRTUAL_ENV_PATH); \
121-
source ./venv/bin/activate; \
145+
python3 -m venv $(VIRTUAL_ENV_PATH); \
146+
source $(VIRTUAL_ENV_PATH)/bin/activate; \
122147
)

development/apply-copyright.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "${NO_VENV}" ]; then source venv/bin/activate; fi;
4+
5+
if [ "$#" -eq "0" ]; then
6+
echo "No changed files";
7+
exit 0;
8+
fi
9+
10+
licenseheaders -t ./development/copyright.tmpl -E ".py" -cy -f "$@";

development/copyright-update

-4
This file was deleted.

development/copyright.json

-11
This file was deleted.

development/copyright.tmpl

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Tapen - software for managing label printers
2+
Copyright (C) 2022 Dmitry Berezovsky
3+
4+
Tapen is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
Tapen is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.

development/package.json

-1
This file was deleted.

poetry.lock

+1,468
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+92-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,69 @@
1+
[tool.poetry]
2+
name = "tapen"
3+
version = "0.1.0"
4+
license = "GPL-3.0-or-later"
5+
description = "Tapen - software for managing label printers"
6+
authors = ["Dmitry Berezovsky"]
7+
maintainers = ["Dmitry Berezovsky"]
8+
repository = "https://github.com/corvis/tapen"
9+
keywords = []
10+
classifiers = [
11+
"Development Status :: 3 - Alpha",
12+
# Who your project is intended for
13+
"Intended Audience :: Developers",
14+
"Topic :: Software Development :: Libraries :: Python Modules",
15+
"Topic :: Home Automation",
16+
# License (should match "license" above)
17+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
18+
# Python versions support
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
]
24+
readme = "README.md"
25+
packages = [
26+
{include = "ptouch_py", from = "src"},
27+
{include = "tapen", from = "src"},
28+
]
29+
include = ["tapen/resources/*", "tapen/renderer/resources/*"]
30+
31+
[tool.poetry.scripts]
32+
tapen = "tapen.cli:default_entrypoint"
33+
tpp = "tapen.cli:default_entrypoint"
34+
35+
[tool.poetry.dependencies]
36+
python = ">=3.10, <3.12"
37+
# PTouch
38+
pyusb = "~1.2.1"
39+
Pillow = ">=9.1.0"
40+
41+
# Tapen
42+
cli-rack = { version = "~1.0.1", extras=["validation"] }
43+
weasyprint="~=60.2"
44+
pyyaml = ">=5.0.0"
45+
appdirs = ">=1.4.4"
46+
jinja2 = ">=3.0.0, <4.0.0"
47+
48+
[tool.poetry.dev-dependencies]
49+
# Dev tools
50+
black = "~=22.3"
51+
licenseheaders = "~=0.8"
52+
flake8 = "~=4.0"
53+
isort = "~=5.11"
54+
mypy = ">=1.0.1"
55+
pre-commit = "~=2.19"
56+
commitizen = "~=2.42.1"
57+
mistune = ">=3.0.0"
58+
pyinstaller = "~=6.3"
59+
60+
# Type checking
61+
types-PyYAML = ">=5.0.0"
62+
types-Pillow = ">=10.0.0"
63+
164
[tool.black]
265
line-length = 120
3-
target-version = ['py37']
66+
target-version = ['py311']
467
exclude = '''
568
(
669
/(
@@ -15,4 +78,31 @@ exclude = '''
1578
| dist
1679
)/
1780
)
18-
'''
81+
'''
82+
83+
[tool.isort]
84+
profile = "black"
85+
line_length = 120
86+
force_sort_within_sections = "true"
87+
atomic = "true"
88+
89+
[tool.mypy]
90+
python_version = "3.11"
91+
show_error_codes = true
92+
ignore_errors = false
93+
warn_return_any = false
94+
disallow_any_generics = false
95+
pretty = true
96+
mypy_path = "$MYPY_CONFIG_FILE_DIR/stubs"
97+
exclude = ["test_.*\\.py$", ]
98+
99+
[[tool.mypy.overrides]]
100+
module = ["examples"]
101+
ignore_errors = true
102+
follow_imports = "silent"
103+
ignore_missing_imports = true
104+
105+
[[tool.mypy.overrides]]
106+
module = ["weasyprint.*", "cli_rack_validation.*", "cli_rack.*", "usb.*", "appdirs.*"]
107+
ignore_missing_imports = true
108+
follow_imports = "skip"

src/ptouch_py/__init__.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# Tapen - software for managing label printers
2-
# Copyright (C) 2022 Dmitry Berezovsky
31
#
4-
# Tapen is free software: you can redistribute it and/or modify
5-
# it under the terms of the GNU General Public License as published by
6-
# the Free Software Foundation, either version 3 of the License, or
7-
# (at your option) any later version.
2+
# Tapen - software for managing label printers
3+
# Copyright (C) 2022 Dmitry Berezovsky
84
#
9-
# Tapen is distributed in the hope that it will be useful,
10-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
# GNU General Public License for more details.
5+
# Tapen is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
139
#
14-
# You should have received a copy of the GNU General Public License
15-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
10+
# Tapen is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.#

src/ptouch_py/const.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# Tapen - software for managing label printers
2-
# Copyright (C) 2022 Dmitry Berezovsky
31
#
4-
# Tapen is free software: you can redistribute it and/or modify
5-
# it under the terms of the GNU General Public License as published by
6-
# the Free Software Foundation, either version 3 of the License, or
7-
# (at your option) any later version.
2+
# Tapen - software for managing label printers
3+
# Copyright (C) 2022 Dmitry Berezovsky
84
#
9-
# Tapen is distributed in the hope that it will be useful,
10-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
# GNU General Public License for more details.
5+
# Tapen is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
139
#
14-
# You should have received a copy of the GNU General Public License
15-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
10+
# Tapen is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
1617

1718
PTOUCH_ENDPOINT = 0x02
1819
PTOUCH_INPUT_ENDPOINT = 0x81

src/ptouch_py/core.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# Tapen - software for managing label printers
2-
# Copyright (C) 2022 Dmitry Berezovsky
31
#
4-
# Tapen is free software: you can redistribute it and/or modify
5-
# it under the terms of the GNU General Public License as published by
6-
# the Free Software Foundation, either version 3 of the License, or
7-
# (at your option) any later version.
2+
# Tapen - software for managing label printers
3+
# Copyright (C) 2022 Dmitry Berezovsky
84
#
9-
# Tapen is distributed in the hope that it will be useful,
10-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
# GNU General Public License for more details.
5+
# Tapen is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
139
#
14-
# You should have received a copy of the GNU General Public License
15-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
10+
# Tapen is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
1617

1718
import logging
1819
import time
@@ -55,7 +56,7 @@ def _pt_send(self, data: bytes):
5556
msg_len = len(data)
5657
assert self.usb_dev.write(0x02, data) == msg_len
5758

58-
def init(self):
59+
def init(self) -> None:
5960
if self.usb_dev.is_kernel_driver_active(0):
6061
self.usb_dev.detach_kernel_driver(0)
6162
self.usb_dev.set_configuration()

src/ptouch_py/domain.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# Tapen - software for managing label printers
2-
# Copyright (C) 2022 Dmitry Berezovsky
31
#
4-
# Tapen is free software: you can redistribute it and/or modify
5-
# it under the terms of the GNU General Public License as published by
6-
# the Free Software Foundation, either version 3 of the License, or
7-
# (at your option) any later version.
2+
# Tapen - software for managing label printers
3+
# Copyright (C) 2022 Dmitry Berezovsky
84
#
9-
# Tapen is distributed in the hope that it will be useful,
10-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
# GNU General Public License for more details.
5+
# Tapen is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
139
#
14-
# You should have received a copy of the GNU General Public License
15-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
10+
# Tapen is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
1617

1718
import ctypes
1819
import enum

0 commit comments

Comments
 (0)