Skip to content

Commit cf0f2c9

Browse files
committed
Begin cleaning up build for v5.0.0
1 parent 5f12a6a commit cf0f2c9

14 files changed

+90
-85
lines changed

GNUmakefile

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44

55
# PY[3] is the target Python interpreter. It must have pytest installed.
66

7-
PY ?= python
8-
PY2 ?= python2
9-
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])))))" )
10-
PY3 ?= python3
11-
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 )
7+
PY ?= python
8+
PY2 ?= python2
9+
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])))))" )
10+
PY3 ?= python3
11+
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 )
1212

1313

14-
VERSION=$(shell $(PY3) -c 'exec(open("version.py").read()); print( __version__ )')
14+
VERSION = $(shell $(PY3) -c 'exec(open("version.py").read()); print( __version__ )')
15+
WHEEL = dist/cpppo-$(VERSION)-py3-none-any.whl
1516

16-
# TARGET=... nix-shell # CPython version targets: py2, py3{10,11,12,13}
17-
TARGET ?= cpppo_py312
17+
# TARGET=... nix-shell # CPython version targets: py27, py3{10,11,12,13}
18+
# (py27 requires reverting to an older nixpkgs.nix)
19+
#TARGET ?= py312
1820
export TARGET
1921

22+
NIX_OPTS ?= # --pure
23+
2024

2125

2226
# PY[23]TEST is the desired method of invoking py.test; either as a command, or
@@ -70,7 +74,7 @@ PY_TEST=TZ=$(TZ) $(PY) -m pytest $(PYTESTOPTS)
7074
PY2TEST=TZ=$(TZ) $(PY2) -m pytest $(PYTESTOPTS)
7175
PY3TEST=TZ=$(TZ) $(PY3) -m pytest $(PYTESTOPTS)
7276

73-
.PHONY: all test clean upload
77+
.PHONY: all test clean upload FORCE
7478
all: help
7579

7680
help:
@@ -114,9 +118,8 @@ pylint:
114118
# TARGET=cpppo_py2 to test under Python 2 (more difficult as time goes on). See default.nix for
115119
# other Python version targets.
116120
#
117-
118121
nix-%:
119-
nix-shell --pure --run "make $*"
122+
nix-shell $(NIX_OPTS) --run "make $*"
120123

121124

122125
#
@@ -131,21 +134,10 @@ nix-%:
131134
# ...
132135
#
133136
test:
134-
$(PY_TEST)
135-
test2:
136-
$(PY2TEST)
137-
test3:
138137
$(PY3TEST)
139-
test23: test2 test3
140-
141138

142139
doctest:
143-
cd crypto/licensing && $(PY_TEST) --doctest-modules
144-
doctest2:
145-
cd crypto/licensing && $(PY2TEST) --doctest-modules
146-
doctest3:
147140
cd crypto/licensing && $(PY3TEST) --doctest-modules
148-
doctest23: doctest2 doctest3
149141

150142
analyze:
151143
flake8 -j 1 --max-line-length=110 \
@@ -157,25 +149,22 @@ pylint:
157149
cd .. && pylint cpppo --disable=W,C,R
158150

159151

160-
build3-check:
152+
build-check:
161153
@$(PY3) -m build --version \
162154
|| ( echo "\n*** Missing Python modules; run:\n\n $(PY3) -m pip install --upgrade -r requirements-dev.txt\n" \
163155
&& false )
164156

165-
build3: build3-check clean
166-
$(PY3) -m build
167-
@ls -last dist
168-
build: build3
157+
build: build-check clean wheel
169158

170-
dist/cpppo-$(VERSION)-py3-none-any.whl: build3
159+
wheel: $(WHEEL)
171160

172-
install2:
173-
$(PY2) setup.py install
174-
install3: dist/cpppo-$(VERSION)-py3-none-any.whl
175-
$(PY3) -m pip install --force-reinstall $^
161+
$(WHEEL): FORCE
162+
$(PY3) -m pip install -r requirements-dev.txt
163+
$(PY3) -m build .
164+
@ls -last dist
176165

177-
install23: install2 install3
178-
install: install3
166+
install: $(WHEEL) FORCE
167+
$(PY3) -m pip install --force-reinstall $<[all]
179168

180169
install-%: # ...-dev, -tests
181170
$(PY3) -m pip install --upgrade -r requirements-$*.txt
@@ -193,53 +182,24 @@ clean:
193182

194183
# Run only tests with a prefix containing the target string, eg test-blah
195184
test-%:
196-
$(PY_TEST) *$*_test.py
197-
test2-%:
198-
$(PY2TEST) *$*_test.py
199-
test3-%:
200-
$(PY3TEST) *$*_test.py
201-
test23-%:
202-
$(PY2TEST) *$*_test.py
203185
$(PY3TEST) *$*_test.py
204186

205187
unit-%:
206-
$(PY_TEST) -k $*
207-
unit2-%:
208-
$(PY2TEST) -k $*
209-
unit3-%:
210-
$(PY3TEST) -k $*
211-
unit23-%:
212-
$(PY2TEST) -k $*
213188
$(PY3TEST) -k $*
214189

215-
216190
#
217191
# venv: Create a Virtual Env containing the installed repo
218192
#
219193
.PHONY: venv venv-activate.sh venv-activate
220194
venv: $(VENV)
221-
venv-activate.sh: $(VENV)/venv-activate.sh
222-
venv-activate: $(VENV)/venv-activate.sh
223195
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
224-
@bash --init-file $< -i
225-
# Create the venv, and then install cpppo from the current directory
196+
@bash --init-file $</bin/activate -i
197+
226198
$(VENV):
227199
@echo; echo "*** Building $@ VirtualEnv..."
228200
@rm -rf $@ && $(PY3) -m venv $(VENV_OPTS) $@ \
229201
&& source $@/bin/activate \
230-
&& make install-dev install
231-
232-
# Activate a given VirtualEnv, and go to its routeros_ssh installation
233-
# o Creates a custom venv-activate.sh script in the venv, and uses it start
234-
# start a sub-shell in that venv, with a CWD in the contained routeros_ssh installation
235-
$(VENV)/venv-activate.sh: $(VENV)
236-
( \
237-
echo "PS1='[\u@\h \W)]\\$$ '"; \
238-
echo "[ -r ~/.git-completion.bash ] && source ~/.git-completion.bash"; \
239-
echo "[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh && PS1='[\u@\h \W\$$(__git_ps1 \" (%s)\")]\\$$ '"; \
240-
echo "source $</bin/activate"; \
241-
) > $@
242-
202+
&& make install install-tests
243203

244204
#
245205
# Target to allow the printing of 'make' variables, eg:

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
include LICENSE
33
include README.org
44
include requirements.txt
5-
include requirements-optional.txt
5+
include requirements-*.txt
66
include cpppo.cfg
77
include crypto/licensing/licensing.sql*
88
recursive-include crypto/licensing/static *

default.nix

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,78 @@ with pkgs;
55
let
66
in
77
{
8-
cpppo_py313 = stdenv.mkDerivation rec {
8+
py313 = stdenv.mkDerivation rec {
99
name = "python313-with-pytest";
1010

1111
buildInputs = [
12+
cacert
1213
git
14+
gnumake
1315
openssh
1416
python313
1517
python313Packages.pytest
1618
];
1719
};
1820

19-
cpppo_py312 = stdenv.mkDerivation rec {
21+
py312 = stdenv.mkDerivation rec {
2022
name = "python312-with-pytest";
2123

2224
buildInputs = [
25+
cacert
2326
git
27+
gnumake
2428
openssh
2529
python312
2630
python312Packages.pytest
2731
];
2832
};
2933

30-
cpppo_py311 = stdenv.mkDerivation rec {
34+
py311 = stdenv.mkDerivation rec {
3135
name = "python311-with-pytest";
3236

3337
buildInputs = [
38+
cacert
3439
git
40+
gnumake
3541
openssh
3642
python311
3743
python311Packages.pytest
3844
];
3945
};
4046

41-
cpppo_py310 = stdenv.mkDerivation rec {
47+
py310 = stdenv.mkDerivation rec {
4248
name = "python310-with-pytest";
4349

4450
buildInputs = [
51+
cacert
4552
git
53+
gnumake
4654
openssh
4755
python310
4856
python310Packages.pytest
4957
];
5058
};
5159

52-
cpppo_py2 = stdenv.mkDerivation rec {
60+
py39 = stdenv.mkDerivation rec {
61+
name = "python39-with-pytest";
62+
63+
buildInputs = [
64+
cacert
65+
git
66+
gnumake
67+
openssh
68+
python39
69+
python39Packages.pytest
70+
];
71+
};
72+
73+
py27 = stdenv.mkDerivation rec {
5374
name = "python2-with-pytest";
5475

5576
buildInputs = [
77+
cacert
5678
git
79+
gnumake
5780
openssh
5881
python27
5982
python27Packages.pytest

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
build
2-
flake8
2+
packaging
33
pip
4-
pytest >=4.6
54
setuptools
65
wheel

requirements-http.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web.py >=0.51
2+
wsgilog >=0.3

requirements-logix.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pylogix >=0.7.5

requirements-modbus.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minimalmodbus
2+
pymodbus >=1.2.0, <2.0.0

requirements-optional-crypto.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements-optional.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

requirements-serial.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyserial >=3.5

0 commit comments

Comments
 (0)