From c17ddfbf66e2801ec620d49979aca3d7077d7002 Mon Sep 17 00:00:00 2001 From: Charlie Li Date: Wed, 15 Feb 2023 15:57:06 -0500 Subject: lang/python: add bytecode trigger Facilitates compiling, writing and removing bytecode files (.pyc) in site-packages after all pkg transactions have been completed. Technical details: https://wiki.freebsd.org/Python/CompiledPackages Fixes reports of Python port builds as root failing on filesystem violations due to bytecode file writes where the port did not include them in the package. For those ports/packages that currently package bytecode, some checksum mismatches on those files may occur. This is harmless and will be rectified, in large as part of a USE_PYTHON=distutils overhaul to reduce churn. While here, implement a long-standing todo item of letting lang/python ports use python.mk bits. Not only does this obviate duplicate variables in each Makefile, but SUB_LIST (also added) is used for these triggers. Co-authored by: tcberner Approved by: tcberner (mentor) Differential Revision: https://reviews.freebsd.org/D34739 --- lang/python310/files/python3.10.ucl.in | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lang/python310/files/python3.10.ucl.in (limited to 'lang/python310/files/python3.10.ucl.in') diff --git a/lang/python310/files/python3.10.ucl.in b/lang/python310/files/python3.10.ucl.in new file mode 100644 index 000000000000..63d455839549 --- /dev/null +++ b/lang/python310/files/python3.10.ucl.in @@ -0,0 +1,40 @@ +path_glob: "%%PYTHON_SITELIBDIR%%/*" +trigger: { + type: lua + sandbox: false + script: <=> removed stale bytecode " .. bytecode_file) + os.remove(full_path .. "/" .. bytecode_file) + end + end + end + end + local res = pkg.readdir(full_path) + if #res == 0 then + --print(" >=> removed empty directory " .. full_path ) + os.remove(full_path) + end + end + end +end + +print(">=> Cleaning stale bytecode files...") +cleanup("%%PYTHON_SITELIBDIR%%") + +print(">=> Byte-compiling Python source files...") +pkg.exec({"%%PYTHON_VERSION%%", "-m", "compileall", "-q", "-o", "0", "-o", "1", "-o", "2", "%%PYTHON_SITELIBDIR%%"}) +EOS +} -- cgit v1.2.3