bsd.python.mk: python3 plist shim

Ruslan Makhmatkhanov cvs-src at yandex.ru
Wed Jan 23 12:30:01 UTC 2013


Hello,

I'm planning to apply this patch to Mk/bsd.python.mk soon. It's an 
nivit's solution from devel/py-virtualenv for changes, introduced in PEP 
3147 [1]. It will not affect default packages build, because packages 
are not yet building for python3 on cluster, but it will affect python 
ports, built with python3, that already has fix like that applied 
locally. I tested it with dozen of ports and everything seems fine. 
Local fixes will be removed right after this change. Please tell me if 
there is any objections or suggestions on this. Thanks.

[1] http://www.python.org/dev/peps/pep-3147/

-- 
Regards,
Ruslan

Tinderboxing kills... the drives.
-------------- next part --------------
Index: bsd.python.mk
===================================================================
--- bsd.python.mk	(revision 310860)
+++ bsd.python.mk	(working copy)
@@ -666,6 +666,23 @@
 
 .endif # defined(USE_TWISTED)
 
+.if ${PYTHON_REL} >= 320
+# When Python version is 3.2+ we rewrite all the filenames
+# of TMPPLIST that end with .py[co], so that they conform
+# to PEP 3147 (see http://www.python.org/dev/peps/pep-3147/)
+PYMAGICTAG=	${PYTHON_CMD} -c 'import imp; print(imp.get_tag())'
+add-plist-post:
+	@${AWK} '\
+		/\.py[co]$$/ && !($$0 ~ "/" pc "/") {id = match($$0, /\/[^\/]+\.py[co]$$/); if (id != 0) {d = substr($$0, 1, RSTART - 1); dirs[d] = 1}; sub(/\.py[co]$$/,  "." mt "&"); sub(/[^\/]+\.py[co]$$/, pc "/&"); print; next} \
+		/^@dirrm / {d = substr($$0, 8); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \
+		{print} \
+		END {if (sp in dirs) {print "@dirrm " sp "/" pc}} \
+		' \
+		pc="__pycache__" mt="$$(${PYMAGICTAG})" sp="${PYTHON_SITELIBDIR:S,${PYTHONBASE}/,,g}" \
+		${TMPPLIST} > ${TMPPLIST}.pyc_tmp
+	@${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST}
+.endif
+
 # XXX Hm, should I export some of the variables above to *_ENV?
 
 # If multiple Python versions are installed and cmake is used, it might


More information about the freebsd-python mailing list