Page MenuHomeFreeBSD

D34739.id104557.diff
No OneTemporary

D34739.id104557.diff

Index: devel/py-qt5-pyqt/Makefile
===================================================================
--- devel/py-qt5-pyqt/Makefile
+++ devel/py-qt5-pyqt/Makefile
@@ -28,12 +28,6 @@
${RM} -r ${WRKSRC}/pyuic/uic/port_v2
post-install:
- ${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR}/PyQt5 \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/PyQt5
- ${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR}/PyQt5 \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/PyQt5
@${FIND} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/PyQt5 \
-name '*.so*' -exec ${STRIP_CMD} {} +
Index: devel/py-sip4/Makefile
===================================================================
--- devel/py-sip4/Makefile
+++ devel/py-sip4/Makefile
@@ -54,12 +54,6 @@
post-install:
${MKDIR} ${STAGEDIR}${DOCSDIR} && cd ${WRKSRC}/doc/html && \
${COPYTREE_SHARE} \. ${STAGEDIR}${DOCSDIR}
- ${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
- ${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
${STRIP_CMD} ${STAGEDIR}/${PREFIX}/bin/sip
${STRIP_CMD} ${STAGEDIR}/${PYTHON_SITELIBDIR}/sip.so
Index: devel/py-sip4/pkg-plist
===================================================================
--- devel/py-sip4/pkg-plist
+++ devel/py-sip4/pkg-plist
@@ -11,8 +11,4 @@
%%PYTHON_SITELIBDIR%%/sip.pyi
%%PYTHON_SITELIBDIR%%/sip.so
%%PYTHON_SITELIBDIR%%/sipconfig.py
-%%PYTHON_SITELIBDIR%%/sipconfig.pyc
-%%PYTHON_SITELIBDIR%%/sipconfig.pyo
%%PYTHON_SITELIBDIR%%/sipdistutils.py
-%%PYTHON_SITELIBDIR%%/sipdistutils.pyc
-%%PYTHON_SITELIBDIR%%/sipdistutils.pyo
Index: devel/pyside2/Makefile
===================================================================
--- devel/pyside2/Makefile
+++ devel/pyside2/Makefile
@@ -50,12 +50,4 @@
CMAKE_ARGS+= -DDISABLE_QtWebEngine:BOOL=TRUE
.endif
-post-install:
- ${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
- ${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
-
.include <bsd.port.mk>
Index: devel/shiboken2/Makefile
===================================================================
--- devel/shiboken2/Makefile
+++ devel/shiboken2/Makefile
@@ -45,12 +45,4 @@
WRKSRC= ${WRKDIR}/pyside-setup-opensource-src-${DISTVERSION:C/^([0-9].[0-9]+.[0-9])(.[0-9])?/\1/}/sources/shiboken2
-post-install:
- ${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
- ${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
- -f -d ${PYTHONPREFIX_SITELIBDIR} \
- ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
-
.include <bsd.port.post.mk>
Index: lang/Makefile
===================================================================
--- lang/Makefile
+++ lang/Makefile
@@ -275,6 +275,7 @@
SUBDIR += python-doc-pdf-letter
SUBDIR += python-doc-text
SUBDIR += python-mode.el
+ SUBDIR += python-pycache
SUBDIR += python-tools
SUBDIR += python2
SUBDIR += python27
Index: lang/python-pycache/Makefile
===================================================================
--- /dev/null
+++ lang/python-pycache/Makefile
@@ -0,0 +1,11 @@
+PORTNAME= python-pycache
+PORTVERSION= 0.0.1
+CATEGORIES= lang
+
+MAINTAINER= portmgr@FreeBSD.org
+COMMENT= Trigger to recreate python precompiled bytecode
+
+USES= metaport trigger
+TRIGGERS= python-update-cache
+
+.include <bsd.port.mk>
Index: lang/python-pycache/files/python-update-cache.ucl.in
===================================================================
--- /dev/null
+++ lang/python-pycache/files/python-update-cache.ucl.in
@@ -0,0 +1,102 @@
+path_regex: "%%PREFIX%%/lib/python.*/site-packages(/.*)?"
+cleanup: {
+ type: lua
+ sandbox: false
+ script: <<EOS
+-- do nada?
+EOS
+}
+trigger: {
+ type: lua
+ sandbox: false
+ script: <<EOS
+-- helper function to recreate the bytecode for the given python binary
+-- inside site_package_path for the passed directory
+function recreate_bytecode(python, directory)
+ print(" >=> wrote bytecode for " .. directory)
+ -- create the cache and optimized cache non-recursively -- as all directories are passed
+ -- via the trigger anyways
+ pkg.exec({python, "-m", "compileall", "-q", "-d", directory, "-l", directory})
+ pkg.exec({python, "-O", "-m", "compileall", "-q", "-d", directory, "-l", directory})
+end
+
+function cleanup(directory)
+ for _,d in ipairs(pkg.readdir(directory)) do
+ local full_path = directory .. "/" .. d
+ local stat = pkg.stat(full_path)
+ if stat["type"] == "dir" then
+ if (not (d == "__pycache__")) then
+ cleanup(full_path)
+ else
+ for _,bytecode_file in ipairs(pkg.readdir(full_path)) do
+ local file_origin = string.gsub(bytecode_file, "[.]cpython[-]%d%d[.].*py[oc]", ".py")
+ if file_origin then
+ local origin_path = directory .. "/" .. file_origin
+ if (not pkg.stat(origin_path)) then
+ print(" >=> removed stale bytecode " .. bytecode_file)
+ os.remove(full_path .. "/" .. bytecode_file)
+ end
+ end
+ end
+ local res = pkg.readdir(full_path)
+ if #res == 0 then
+ print(" >=> removed empty cache directory " .. full_path )
+ os.remove(full_path)
+ end
+ end
+ end
+ end
+end
+
+-- keep track of directories already compiled
+local hash = {}
+-- keep track of site-packages directories
+local site_libs = {}
+
+print(">=> Recreating python bytecode ... ")
+-- recreate the cache for the site-packages sub-directories touched
+for _,path in ipairs(arg) do
+ local path = string.match(path, ".*/site[-]packages/[^/]*")
+ if path then
+ local python_sitepackages = string.match(path, ".*/site[-]packages")
+ if (not hash[path]) and pkg.stat(path) then
+ local python_version = string.match(path, "python3.%d")
+ local is_egg = string.find(path, ".*egg[-]info")
+ local is_info = string.find(path, ".*dist[-]info")
+ if (not is_egg) and (not is_info) and python_version then
+ local dir = pkg.readdir(path)
+ local python_binary = "%%PREFIX%%/bin/" .. python_version
+ if pkg.stat(python_binary) then
+ recreate_bytecode(python_binary, path)
+
+ hash[path] = true
+
+ if (not site_libs[python_binary]) then
+ site_libs[python_binary] = python_sitepackages
+ end
+ end
+ end
+ end
+ end
+end
+
+-- recreate the top-level cache of the touched site-packages
+print(">=> Recreating top-level python bytecode ... ")
+for python_binary,python_sitepackages in pairs(site_libs) do
+ recreate_bytecode(python_binary, python_sitepackages)
+end
+
+-- cleanup stale bytecode files
+-- note, it seems to be necessary to manually walk the tree as the removal does not trigger the appropriate paths
+print(">=> Cleaning stale python bytecode ... ")
+for _,dir in pairs(pkg.readdir("%%PREFIX%%/lib")) do
+ i,j = string.find(dir, "python%d[.]%d")
+ if i == 1 then
+ local python_sitepackages = "%%PREFIX%%/lib/" .. dir .. "/site-packages"
+ if pkg.stat(python_sitepackages) then
+ cleanup(python_sitepackages)
+ end
+ end
+end
+EOS
+}
Index: lang/python-pycache/pkg-descr
===================================================================
--- /dev/null
+++ lang/python-pycache/pkg-descr
@@ -0,0 +1 @@
+Recreates pycache on pkg registration.
Index: lang/python310/Makefile
===================================================================
--- lang/python310/Makefile
+++ lang/python310/Makefile
@@ -14,6 +14,7 @@
LICENSE= PSFL
LIB_DEPENDS= libffi.so:devel/libffi
+RUN_DEPENDS= python-pycache>=0:lang/python-pycache
USES= compiler:c11 cpe ncurses pathfix pkgconfig readline \
shebangfix ssl tar:xz
Index: lang/python311/Makefile
===================================================================
--- lang/python311/Makefile
+++ lang/python311/Makefile
@@ -15,6 +15,7 @@
LICENSE= PSFL
LIB_DEPENDS= libffi.so:devel/libffi
+RUN_DEPENDS= python-pycache>=0:lang/python-pycache
USES= compiler:c11 cpe ncurses pathfix pkgconfig readline \
shebangfix ssl tar:xz
Index: lang/python37/Makefile
===================================================================
--- lang/python37/Makefile
+++ lang/python37/Makefile
@@ -15,6 +15,7 @@
LIB_DEPENDS= libffi.so:devel/libffi \
libmpdec.so:math/mpdecimal
+RUN_DEPENDS= python-pycache>=0:lang/python-pycache
USES= cpe ncurses pathfix pkgconfig readline shebangfix ssl tar:xz
PATHFIX_MAKEFILEIN= Makefile.pre.in
Index: lang/python38/Makefile
===================================================================
--- lang/python38/Makefile
+++ lang/python38/Makefile
@@ -14,6 +14,7 @@
LICENSE= PSFL
LIB_DEPENDS= libffi.so:devel/libffi
+RUN_DEPENDS= python-pycache>=0:lang/python-pycache
USES= cpe ncurses pathfix pkgconfig readline shebangfix ssl tar:xz
PATHFIX_MAKEFILEIN= Makefile.pre.in
Index: lang/python39/Makefile
===================================================================
--- lang/python39/Makefile
+++ lang/python39/Makefile
@@ -14,6 +14,7 @@
LICENSE= PSFL
LIB_DEPENDS= libffi.so:devel/libffi
+RUN_DEPENDS= python-pycache>=0:lang/python-pycache
USES= compiler:c11 cpe ncurses pathfix pkgconfig readline \
shebangfix ssl tar:xz

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 3, 12:45 AM (18 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35875749
Default Alt Text
D34739.id104557.diff (9 KB)

Event Timeline