PYTHON_VERSION=python3.4 and USES=python:2,build
John W. O'Brien
john at saltant.com
Sun Nov 30 04:00:36 UTC 2014
Hello FreeBSD-Python (and mva),
I think there is a bug, either in Mk/Uses/python.mk or in
lang/python{2,3}, or perhaps both, and I would appreciate some review of
my analysis that follows to validate or correct it. I'm sorry if I'm
stumbling along well-trod ground here.
Let's say that I want to build net/py-pyzmq with
PYTHON_VERSION=python3.4. It depends on net/libzmq4, which depends on
net/openpgm, but the last fails to build because of a syntax error in
version_generator.py that seems clearly to be a case of
print-statement-itis. It looks like the right thing to do, short of
patching openpgm's build scripts to be py3k-friendly, is to update
net/openpgm/Makefile from USES=python to USES=python:2,build. The
trouble is that doesn't work either, and this time the error is:
===> openpgm-5.2.122_1 depends on package:
/packages/All/python2-3_3.txz - not found
The problem here is that the PORTVERSION is 3 and should be 2. This
leads me to the first fishy bit of Makefile-ness. lang/python2 and
lang/python3 both set
PORTVERSION= ${PYTHON_MAJOR_VER}
This seems doubly wrong: lang/python2 is being pulled in with
PYTHON_MAJOR_VER=3; and the port is trying to go along with it.
In tracing through Mk/Uses/python.mk to find the cause of the incorrect
PYTHON_MAJOR_VER, I observe that the comment added by mva in r371600---
A port however may require a different version, which is stored
(above) in _PYTHON_VERSION. Every python bit below hence should use
python${_PYTHON_VERSION}, since this is the value, the _port_
requires
---with which I agree and is applicable in this case, is not actually
true given case "b.2" (see mva's comment from r364450), though I'm not
sure I completely understand yet the intrinsic difficulty of resolving
b.2. For easy reference, the logic goes:
.if defined(PYTHON_VERSION)
_PYTHON_VERSION:= ${PYTHON_VERSION:S/^python//}
_PYTHON_CMD= ${LOCALBASE}/bin/${PYTHON_VERSION}
.else
_PYTHON_VERSION:= ${PYTHON_DEFAULT_VERSION:S/^python//}
_PYTHON_CMD= ${LOCALBASE}/bin/${PYTHON_DEFAULT_VERSION}
.endif
The port builder says "I want python3.4" (PYTHON_VERSION=python3.4), the
port maintainer says "I need python2" (USES=python:2,build), and
python.mk doesn't actually allow the maintainer to overrule the
builder's wishes within an appropriately limited scope where the
maintainer knows best.
In order to make the r371600 comment true, the logic that sets
_PYTHON_VERSION would need a prepended third case (the maintainer has
expressed a need through USES).
.if ${_PYTHON_ARGS} != ""
_PYTHON_VERSION:= ${_PYTHON_ARGS}
_PYTHON_CMD= ${LOCALBASE}/bin/python${_PYTHON_ARGS}
.elif defined(PYTHON_VERSION)
...
[Incidentally, _PYTHON_CMD isn't used anywhere and could probably be
deleted.]
While this now sets PYTHON_MAJOR_VER according to the maintainer's
needs, it does not, in fact, propagate them through to lang/python2,
because that still happens when the builder's desires in PYTHON_VERSION
is propagated through DEPENDS_ARGS:
% make PYTHON_VERSION=python3.4 \
-C /usr/ports/lang/python2 \
-V PKGNAME
python2-3_3
This may be an example of b.2 that doesn't need to be an example b.2
because lang/python2 should ignore PYTHON_VERSION (it's just a hint,
after all) if the implied PYTHON_MAJOR_VER != 2. So, if I update
lang/python2/Makefile to set PORTVERSION=2 and replace all subsequent
occurrences of PYTHON_MAJOR_VER with PORTVERSION, I get this happy result
% make PYTHON_VERSION=python3.4 \
-C /usr/ports/lang/python2 \
-V PKGNAME
python2-2_3
Also net/openpgm build successfully even with PYTHON_VERSION=python3.4.
Yet somehow I feel like I'm not quite there yet. Thoughts?
Regards,
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-python/attachments/20141129/22e0d2db/attachment.sig>
More information about the freebsd-python
mailing list