Skip to content

Commit aaf3347

Browse files
committed
Merge branch 'feature-pro-serial'
2 parents 00e38df + 3a59aac commit aaf3347

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+7804
-1984
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2323

2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@master
2626
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v2
27+
uses: actions/setup-python@master
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
- name: Install dependencies
3131
run: |
32-
python -m pip install --upgrade pip
33-
pip install wheel
34-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
35-
pip install flake8 pytest pytz tzlocal pymodbus pylogix
36-
pip install 'argparse; python_version < "2.7"'
37-
pip install 'configparser; python_version < "3.0"'
38-
pip install 'ipaddress; python_version < "3.0"'
32+
python3 -m pip install --upgrade pip
33+
python3 -m pip install .[all,tests]
3934
- name: Lint with flake8
4035
run: |
4136
make analyze || true

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Build
2424
run: |
2525
python -m pip install --upgrade pip
26-
python -m pip install setuptools build wheel
26+
python -m pip install -r requirements-dev.txt
2727
python -m build .
2828
- name: Publish package distributions to PyPI
2929
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
# System generated files
1414
.DS_Store
15-
*.png
1615

1716
*.tex
1817
auto/
@@ -24,3 +23,8 @@ dist/
2423
*.svg
2524
.vagrant
2625
.pytest_cache/
26+
.cache/
27+
*.aux
28+
*.toc
29+
/ttyS[0-9]
30+
/ttyV[0-9]

GNUmakefile

Lines changed: 105 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
#
44

55
# PY[3] is the target Python interpreter. It must have pytest installed.
6+
SHELL = /bin/bash
7+
8+
PY ?= python
9+
PY2 ?= python2
10+
PY2_V = $(shell $(PY2) -c "import sys; print('-'.join((next(iter(filter(None,sys.executable.split('/')))),sys.platform,sys.subversion[0].lower(),''.join(map(str,sys.version_info[:2])))))" )
11+
PY3 ?= python3
12+
PY3_V = $(shell $(PY3) -c "import sys; print('-'.join((next(iter(filter(None,sys.executable.split('/')))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null )
13+
14+
15+
VERSION = $(shell $(PY3) -c 'exec(open("version.py").read()); print( __version__ )')
16+
WHEEL = dist/cpppo-$(VERSION)-py3-none-any.whl
17+
18+
# TARGET=... nix-shell # CPython version targets: py27, py3{10,11,12,13}
19+
# (py27 requires reverting to an older nixpkgs.nix)
20+
#TARGET ?= py312
21+
export TARGET
22+
23+
NIX_OPTS ?= # --pure
24+
625

7-
PY=python
8-
PY2=python2
9-
PY3=python3
1026

1127
# PY[23]TEST is the desired method of invoking py.test; either as a command, or
1228
# loading it as module, by directly invoking the target Python interpreter.
@@ -35,14 +51,31 @@ PY3=python3
3551
# LC_ALL=en_CA.UTF-8
3652
#
3753

54+
# Some tests assume the local time-zone is:
55+
TZ=Canada/Mountain
56+
57+
58+
GIT_SSH_COMMAND = ssh -o StrictHostKeyChecking=no
59+
export GIT_SSH_COMMAND
60+
61+
GHUB_NAME = cpppo
62+
GHUB_REPO = [email protected]:pjkundert/$(GHUB_NAME).git
63+
GHUB_BRCH = $(shell git rev-parse --abbrev-ref HEAD )
64+
65+
# We'll agonizingly find the directory above this makefile's path
66+
VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/.. )
67+
VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PY3_V)
68+
VENV = $(VENV_DIR)/$(VENV_NAME)
69+
VENV_OPTS =
70+
3871
# To see all pytest output, uncomment --capture=no
39-
PYTESTOPTS=-v # --capture=no
72+
PYTESTOPTS=-v --capture=no --log-cli-level=WARNING # INFO 25 == NORMAL 23 == DETAIL
4073

4174
PY_TEST=TZ=$(TZ) $(PY) -m pytest $(PYTESTOPTS)
4275
PY2TEST=TZ=$(TZ) $(PY2) -m pytest $(PYTESTOPTS)
4376
PY3TEST=TZ=$(TZ) $(PY3) -m pytest $(PYTESTOPTS)
4477

45-
.PHONY: all test clean upload
78+
.PHONY: all test clean FORCE
4679
all: help
4780

4881
help:
@@ -51,7 +84,6 @@ help:
5184
@echo " test Run unit tests under Python2/3 (no serial_test w/o 'make SERIAL_TEST=1 test')"
5285
@echo " install Install in /usr/local for Python2/3"
5386
@echo " clean Remove build artifacts"
54-
@echo " upload Upload new version to pypi (package maintainer only)"
5587
@echo
5688
@echo " virtualbox-* Manage VirtualBox virtual machine"
5789
@echo " vmware-* Manage VMWare Fusion virtual machine (recommended; requires license)"
@@ -67,106 +99,101 @@ help:
6799
@echo " vmware-debian-up Brings up Jessie VM w/ Docker capability"
68100
@echo " vmware-debian-ssh Log in to the VM"
69101

102+
analyze:
103+
$(PY3) -m flake8 --color never -j 1 --max-line-length=250 \
104+
--exclude lib,bin,dist,build,signals,.git \
105+
--ignore=W503,E201,E202,E203,E127,E211,E221,E222,E223,E225,E226,E231,E241,E242,E251,E265,E272,E274,E291 \
106+
107+
pylint:
108+
pylint . --disable=W,C,R
109+
110+
#
111+
# nix-...:
112+
#
113+
# Use a NixOS environment to execute the make target, eg.
114+
#
115+
# nix-venv-activate
116+
#
117+
# The default is the Python 3 crypto_licensing target in default.nix; choose
118+
# TARGET=py27 to test under Python 2 (more difficult as time goes on). See default.nix for
119+
# other Python version targets.
120+
#
121+
nix-%:
122+
nix-shell $(NIX_OPTS) --run "make $*"
123+
124+
125+
#
126+
# test...: Perform Unit Tests
127+
#
128+
# Assumes that the requirements.txt has been installed in the target Python environment. This
129+
# is probably best accomplished by first creating/activating a venv, and then running the test:
130+
#
131+
# $ make nix-venv-activate
132+
# (crypto-licensing-4.0.0) [perry@Perrys-MBP crypto-licensing (feature-py-3.12)]$ make test
133+
# make[1]: Entering directory '/Users/perry/src/crypto-licensing'
134+
# ...
135+
#
70136
test:
71-
$(PY_TEST)
72-
test2:
73-
$(PY2TEST)
74-
test3:
75-
$(PY3TEST)
76-
test23:
77-
$(PY2TEST)
78137
$(PY3TEST)
79138

80-
install:
81-
$(PY) setup.py install
82-
install2:
83-
$(PY2) setup.py install
84-
install3:
85-
$(PY3) setup.py install
86-
install23:
87-
$(PY2) setup.py install
88-
$(PY3) setup.py install
139+
doctest:
140+
cd crypto/licensing && $(PY3TEST) --doctest-modules
89141

90142
analyze:
91-
flake8 -j 1 --max-line-length=110 \
92-
--ignore=F401,E221,E201,E202,E203,E223,E225,E226,E231,E241,E242,E261,E272,E302,W503,E701,E702,E,W \
143+
flake8 -j 1 --max-line-length=110 \
144+
--ignore=F401,E201,E202,E221,E223,E226,E231,E242,E272,E701,E702,W191,W291,W503,W293,W391,E \
93145
--exclude="__init__.py" \
94146
.
95147

96148
pylint:
97149
cd .. && pylint cpppo --disable=W,C,R
98150

99-
# Support uploading a new version of cpppo to pypi. Must:
100-
# o advance __version__ number in cpppo/version.py
101-
# o log in to your pypi account (ie. for package maintainer only)
102-
upload:
103-
python setup.py sdist upload
104151

105-
clean:
106-
@rm -rf MANIFEST *.png build dist auto *.egg-info $(shell find . -name '*.pyc' -o -name '__pycache__' )
152+
build-check:
153+
@$(PY3) -m build --version \
154+
|| ( echo "\n*** Missing Python modules; run:\n\n $(PY3) -m pip install --upgrade -r requirements-dev.txt\n" \
155+
&& false )
107156

108-
# Virtualization management, eg:
109-
# make {vmware,vagrant}-up/halt/ssh/destroy
110-
#
111-
# To use a different Vagrant box than precise64 (eg. raring), Vagrantfile must be altered
112-
.PHONY: vagrant vagrant_boxes \
113-
precise64_virtualbox precise64_vmware_fusion \
114-
raring_virtualbox
115-
116-
# The vagrant/ubuntu/Vagrantfile doesn't contain a config.vm.box_url; we must
117-
# supply. The precise64 VMware image presently supports only VMware Fusion 5;
118-
# if you see an error regarding hgfs kernel modules, you may be running a
119-
# version of VMware Fusion incompatible with the VMware Tools in the image.
120-
# TODO: remove; no longer supported.
121-
vmware-ubuntu-%: precise64-vmware_fusion
122-
cd vagrant/ubuntu; vagrant $* $(if $(filter up, $*), --provider=vmware_fusion,)
123-
124-
virtualbox-ubuntu-%: precise64-virtualbox
125-
cd vagrant/ubuntu; vagrant $* $(if $(filter up, $*), --provider=virtualbox,)
157+
build: build-check clean wheel
126158

127-
# The jessie64 VMware image is compatible with VMware Fusion 6, and the VirtualBox image is
128-
# compatible with VirtualBox 4.3. Obtains the box, if necessary. The packer.io generated VMware
129-
# boxes identify themselves as being for vmware_desktop; these are compatible with vmware_fusion
130-
vmware-debian-%: jessie64-vmware_desktop
131-
cd vagrant/debian; vagrant $* $(if $(filter up, $*), --provider=vmware_fusion,)
159+
wheel: $(WHEEL)
132160

133-
virtualbox-debian-%: jessie64-virtualbox
134-
cd vagrant/debian; vagrant $* $(if $(filter up, $*), --provider=virtualbox,)
161+
$(WHEEL): FORCE
162+
$(PY3) -m pip install -r requirements-dev.txt
163+
$(PY3) -m build .
164+
@ls -last dist
135165

136-
vagrant:
137-
@vagrant --help >/dev/null || ( echo "Install vagrant: http://vagrantup.com"; exit 1 )
166+
install: $(WHEEL) FORCE
167+
$(PY3) -m pip install --force-reinstall $<[all]
138168

169+
install-%: # ...-dev, -tests
170+
$(PY3) -m pip install --upgrade -r requirements-$*.txt
139171

140-
# Check if jessie64-{virtualbox,vmware_desktop} exists in the vagrant box list.
141-
# If not, install it.
142-
jessie64-%:
143-
@if ! vagrant box list | grep -q '^jessie64.*($*'; then \
144-
vagrant box add jessie64 http://box.hardconsulting.com/jessie64-$*.box --provider $*; \
145-
fi
146172

173+
clean:
174+
@rm -rf MANIFEST *.png build dist auto *.egg-info $(shell find . -name '*.pyc' -o -name '__pycache__' )
147175

148176

149177
# Run only tests with a prefix containing the target string, eg test-blah
150178
test-%:
151-
$(PY_TEST) *$*_test.py
152-
test2-%:
153-
$(PY2TEST) *$*_test.py
154-
test3-%:
155-
$(PY3TEST) *$*_test.py
156-
test23-%:
157-
$(PY2TEST) *$*_test.py
158179
$(PY3TEST) *$*_test.py
159180

160181
unit-%:
161-
$(PY_TEST) -k $*
162-
unit2-%:
163-
$(PY2TEST) -k $*
164-
unit3-%:
165-
$(PY3TEST) -k $*
166-
unit23-%:
167-
$(PY2TEST) -k $*
168182
$(PY3TEST) -k $*
169183

184+
#
185+
# venv: Create a Virtual Env containing the installed repo
186+
#
187+
.PHONY: venv
188+
venv: $(VENV)
189+
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
190+
@bash --init-file $</bin/activate -i
191+
192+
$(VENV):
193+
@echo; echo "*** Building $@ VirtualEnv..."
194+
@rm -rf $@ && $(PY3) -m venv $(VENV_OPTS) $@ \
195+
&& source $@/bin/activate \
196+
&& make install install-tests
170197

171198
#
172199
# Target to allow the printing of 'make' variables, eg:

MANIFEST.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# Both sdist and bdist include these files
12
include LICENSE
23
include README.org
34
include requirements.txt
4-
include requirements-optional.txt
5+
include requirements-*.txt
56
include cpppo.cfg
7+
include crypto/licensing/licensing.sql*
8+
recursive-include crypto/licensing/static *
9+
global-exclude *~

0 commit comments

Comments
 (0)