tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
comparable PYTHON_VERSION
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
Index: pyversion.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python/pyversion.mk,v
retrieving revision 1.147
diff -u -r1.147 pyversion.mk
--- pyversion.mk 25 Mar 2023 18:29:44 -0000 1.147
+++ pyversion.mk 27 Mar 2023 20:11:47 -0000
@@ -139,9 +139,12 @@
# No supported version found, annotate to simplify statements below.
.if !defined(_PYTHON_VERSION)
_PYTHON_VERSION= none
+PYTHON_VERSION= 0
PKG_FAIL_REASON+= "No valid Python version"
PYPKGPREFIX= none
PYVERSSUFFIX= none
+.else
+PYTHON_VERSION= ${_PYTHON_VERSION:S/27/207/:S/37/307/:S/38/308/:S/39/309/}
.endif
# Additional CONFLICTS
@@ -240,7 +243,7 @@
PYTHON_VERSIONS_ACCEPTED PYTHON_VERSIONS_INCOMPATIBLE \
PYTHON_SELF_CONFLICT PYTHON_FOR_BUILD_ONLY USE_CMAKE BUILD_USES_CMAKE
_SYS_VARS.pyversion= \
- PYTHON_VERSION_REQD PYPACKAGE PYVERSSUFFIX PYPKGSRCDIR \
+ PYTHON_VERSION PYTHON_VERSION_REQD PYPACKAGE PYVERSSUFFIX PYPKGSRCDIR \
PYPKGPREFIX PYTHONBIN PYTHONCONFIG PY_COMPILE_ALL \
PY_COMPILE_O_ALL PYINC PYLIB PYSITELIB CMAKE_ARGS
_USE_VARS.pyversion= \
Home |
Main Index |
Thread Index |
Old Index