summaryrefslogtreecommitdiff
path: root/lang/python38
diff options
context:
space:
mode:
Diffstat (limited to 'lang/python38')
-rw-r--r--lang/python38/Makefile10
-rw-r--r--lang/python38/files/python3.8.ucl.in42
2 files changed, 46 insertions, 6 deletions
diff --git a/lang/python38/Makefile b/lang/python38/Makefile
index fd476d48aecf..07a565977f73 100644
--- a/lang/python38/Makefile
+++ b/lang/python38/Makefile
@@ -1,5 +1,6 @@
PORTNAME= python
DISTVERSION= ${PYTHON_DISTVERSION}
+PORTREVISION= 1
CATEGORIES= lang python
MASTER_SITES= PYTHON/ftp/python/${DISTVERSION}
PKGNAMESUFFIX= ${PYTHON_SUFFIX}
@@ -14,7 +15,8 @@ LICENSE= PSFL
LIB_DEPENDS= libffi.so:devel/libffi
-USES= cpe ncurses pathfix pkgconfig readline shebangfix ssl tar:xz
+USES= cpe ncurses pathfix pkgconfig python:${PYTHON_DISTVERSION:R},env readline \
+ shebangfix ssl tar:xz trigger
PATHFIX_MAKEFILEIN= Makefile.pre.in
USE_LDCONFIG= yes
GNU_CONFIGURE= yes
@@ -23,11 +25,7 @@ SHEBANG_FILES= Lib/*.py Lib/*/*.py Lib/*/*/*.py Lib/*/*/*/*.py
SHEBANG_FILES+= Lib/test/ziptestdata/exe_with_z64 \
Lib/test/ziptestdata/exe_with_zip \
Lib/test/ziptestdata/header.sh
-
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER= ${PYTHON_DISTVERSION:R}
-PYTHON_VERSION= python${PYTHON_VER}
-PYTHON_SUFFIX= ${PYTHON_VER:S/.//g}
+TRIGGERS= ${PYTHON_VERSION}
DISABLED_EXTENSIONS= _sqlite3 _tkinter _gdbm
CONFIGURE_ARGS+= --enable-shared --without-ensurepip \
diff --git a/lang/python38/files/python3.8.ucl.in b/lang/python38/files/python3.8.ucl.in
new file mode 100644
index 000000000000..a9ebb18f9c27
--- /dev/null
+++ b/lang/python38/files/python3.8.ucl.in
@@ -0,0 +1,42 @@
+path_glob: "%%PYTHON_SITELIBDIR%%/*"
+trigger: {
+ type: lua
+ sandbox: false
+ script: <<EOS
+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 (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[-]%%PYTHON_SUFFIX%%[.].*pyc", ".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
+ 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", "%%PYTHON_SITELIBDIR%%"})
+pkg.exec({"%%PYTHON_VERSION%%", "-O", "-m", "compileall", "-q", "%%PYTHON_SITELIBDIR%%"})
+pkg.exec({"%%PYTHON_VERSION%%", "-OO", "-m", "compileall", "-q", "%%PYTHON_SITELIBDIR%%"})
+EOS
+}