Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Nov 2014 23:00:22 -0500
From:      "John W. O'Brien" <john@saltant.com>
To:        FreeBSD Python List <freebsd-python@FreeBSD.org>
Cc:        Marcus von Appen <mva@freebsd.org>
Subject:   PYTHON_VERSION=python3.4 and USES=python:2,build
Message-ID:  <547A9656.9030602@saltant.com>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--jcR5J6iPM8828dRnBXUEvpFtveNUTnvxi
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

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=3Dpython3.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=3Dpython to USES=3Dpython:2,build. The
trouble is that doesn't work either, and this time the error is:

    =3D=3D=3D>   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=3D    ${PYTHON_MAJOR_VER}

This seems doubly wrong: lang/python2 is being pulled in with
PYTHON_MAJOR_VER=3D3; 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:=3D       ${PYTHON_VERSION:S/^python//}
    _PYTHON_CMD=3D            ${LOCALBASE}/bin/${PYTHON_VERSION}
    .else
    _PYTHON_VERSION:=3D       ${PYTHON_DEFAULT_VERSION:S/^python//}
    _PYTHON_CMD=3D            ${LOCALBASE}/bin/${PYTHON_DEFAULT_VERSION}
    .endif

The port builder says "I want python3.4" (PYTHON_VERSION=3Dpython3.4), th=
e
port maintainer says "I need python2" (USES=3Dpython: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} !=3D ""
    _PYTHON_VERSION:=3D       ${_PYTHON_ARGS}
    _PYTHON_CMD=3D            ${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=3Dpython3.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 !=3D 2. So, if I update
lang/python2/Makefile to set PORTVERSION=3D2 and replace all subsequent
occurrences of PYTHON_MAJOR_VER with PORTVERSION, I get this happy result=


    % make PYTHON_VERSION=3Dpython3.4 \
        -C /usr/ports/lang/python2 \
        -V PKGNAME
    python2-2_3

Also net/openpgm build successfully even with PYTHON_VERSION=3Dpython3.4.=

Yet somehow I feel like I'm not quite there yet. Thoughts?

Regards,
John


--jcR5J6iPM8828dRnBXUEvpFtveNUTnvxi
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)

iQEcBAEBCgAGBQJUepZZAAoJEORay8JGGICYm4EH/3FCVddgTmWxvhP2cMA9L6sZ
JL541DpjoQJwxY4YwAHeO+W7zokNM797c2pjmBRcEuprKqIvlQCBPpjmnMN0C1oo
Vt87b+GnW9pvvVhubLEp51X96VsYjdaa9+diAKg0w01uu2kLcDL3XbkCEeovgw/V
2nYz4ucHfZeZpuTKtfbxd+qqw/oWYgsj165/gG8OkPFeCdkcBKtEOcBUfqonwz78
1o3S3oLKyFDCJUu9KLihmECv3ud9AEarw0ev+DOJGSdZG5UbKn430C31Pkzp2j//
5FzZUGoDJ9NJhU0cNy59zLRWSVQBIdi0rHNCiFOBrE0Ty+hOO/sRdG3wGAR5fdU=
=c91b
-----END PGP SIGNATURE-----

--jcR5J6iPM8828dRnBXUEvpFtveNUTnvxi--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?547A9656.9030602>