Hi Thomas,
I like the idea of exporting a PYTHON_VERSION to userland, derived from the internal _PYTHON_VERSION, and think you're right to think ahead and plan for future python versions
I was wondering if this might be a better way of calculating the exported version, though? It's more generic, and can handle "40" and friends:
[2023/03/27 Mon 15:18:11] agc@netbsd-002 ~/local [19915] > cat
v.mkPYTHON_VERSION= ${_PYTHON_VERSION:C/^(.)(.)$/\10\2/}
all:
@echo ${_PYTHON_VERSION} ${PYTHON_VERSION}
[2023/03/27 Mon 15:18:22] agc@netbsd-002 ~/local [19916] > make -f
v.mk _PYTHON_VERSION=27
27 207
[2023/03/27 Mon 15:18:29] agc@netbsd-002 ~/local [19917] > make -f
v.mk _PYTHON_VERSION=28
28 208
[2023/03/27 Mon 15:18:36] agc@netbsd-002 ~/local [19918] > make -f
v.mk _PYTHON_VERSION=37
37 307
[2023/03/27 Mon 15:18:41] agc@netbsd-002 ~/local [19919] > make -f
v.mk _PYTHON_VERSION=38
38 308
[2023/03/27 Mon 15:18:47] agc@netbsd-002 ~/local [19920] > make -f
v.mk _PYTHON_VERSION=39
39 309
[2023/03/27 Mon 15:18:51] agc@netbsd-002 ~~/local [19921] > make -f
v.mk _PYTHON_VERSION=40
40 400
[2023/03/27 Mon 15:19:00] agc@netbsd-002 ~/local [19922] > make -f
v.mk _PYTHON_VERSION=400
400 400
[2023/03/27 Mon 15:19:13] agc@netbsd-002 ~/local [19923] > make -f
v.mk _PYTHON_VERSION=310
310 310
[2023/03/27 Mon 15:19:17] agc@netbsd-002 ~/localt [19924] >
Best,
Al
Hi!
Some Python dependencies are only needed for particular python
versions, e.g. "anything before 3.10". Many packages currently use
something like
.include "../../lang/python/pyversion.mk"
.if ${_PYTHON_VERSION} < 310
DEPENDS+=...
.endif
but this has a couple problems:
a) _PYTHON_VERSION can be 'none' if the package-allowed and
environment-allowed settings have no overlap, leading to
make: "/usr/pkgsrc/path/py-foo/Makefile" line 30: Comparison with '<' requires both operands 'none' and '311' to be numeric
b) the numbers are currently ordering well, but only by accident:
27<37<38<39<310<311
if 4.0=40 ever comes out, it will NOT sort well into this.
(c) variables with underscores are internal and not supposed to be used
in package Makefiles)
The attached patch introduces a PYTHON_VERSION that solves all of
these. It's set to "major_version + 100 * minor_version".
a) it's 0 if there is no overlap (but I'd like to hear arguments if
999 would be a better value)
b) it sorts correctly now and will do so later:
207<307<308<309<310<311<400
c) it doesn't start with an underscore
Comments, suggestions?
Thomas