external/python3/ExternalPackage_python3.mk |   24 +++++-------
 external/python3/generateExternalPackage.py |   54 ++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 14 deletions(-)

New commits:
commit 860e4b044a40d69bddd39efc97d281a43f1f6e48
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Dec 18 16:26:01 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Dec 18 22:30:45 2024 +0100

    related tdf#162798: add script to create the list of external packages
    
    Change-Id: Ifc24cb42df76c50f0ca40e3c793f36c355e483d8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178730
    Tested-by: Xisco Fauli <[email protected]>
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/external/python3/ExternalPackage_python3.mk 
b/external/python3/ExternalPackage_python3.mk
index 111d81d18789..871175b03de8 100644
--- a/external/python3/ExternalPackage_python3.mk
+++ b/external/python3/ExternalPackage_python3.mk
@@ -176,12 +176,10 @@ endif
 # test - probably unnecessary? was explicitly removed #i116738#
 # venv - why would we need virtual environments
 #
-# These lists are now sorted with "LC_COLLATE=C sort", by using
-#   find Lib/ -name "*.py" | sort | sed -e 's/^/       /' -e 's/$/ \/'
+# Call generateExternalPackage.py to update the lists below
 #
 
 $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib,\
-       LICENSE \
        Lib/__future__.py \
        Lib/__phello__.foo.py \
        Lib/_aix_support.py \
@@ -413,11 +411,11 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
 
 $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/ctypes/macholib,\
        Lib/ctypes/macholib/README.ctypes \
-       Lib/ctypes/macholib/fetch_macholib \
-       Lib/ctypes/macholib/fetch_macholib.bat \
        Lib/ctypes/macholib/__init__.py \
        Lib/ctypes/macholib/dyld.py \
        Lib/ctypes/macholib/dylib.py \
+       Lib/ctypes/macholib/fetch_macholib \
+       Lib/ctypes/macholib/fetch_macholib.bat \
        Lib/ctypes/macholib/framework.py \
 ))
 
@@ -687,10 +685,10 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
 ))
 
 $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/lib2to3,\
-       Lib/lib2to3/__init__.py \
-       Lib/lib2to3/__main__.py \
        Lib/lib2to3/Grammar.txt \
        Lib/lib2to3/PatternGrammar.txt \
+       Lib/lib2to3/__init__.py \
+       Lib/lib2to3/__main__.py \
        Lib/lib2to3/btm_matcher.py \
        Lib/lib2to3/btm_utils.py \
        Lib/lib2to3/fixer_base.py \
@@ -758,7 +756,7 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
        Lib/lib2to3/fixes/fix_zip.py \
 ))
 
-$(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/pgen2,\
+$(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/lib2to3/pgen2,\
        Lib/lib2to3/pgen2/__init__.py \
        Lib/lib2to3/pgen2/conv.py \
        Lib/lib2to3/pgen2/driver.py \
@@ -789,8 +787,6 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
        Lib/multiprocessing/__init__.py \
        Lib/multiprocessing/connection.py \
        Lib/multiprocessing/context.py \
-       Lib/multiprocessing/dummy/__init__.py \
-       Lib/multiprocessing/dummy/connection.py \
        Lib/multiprocessing/forkserver.py \
        Lib/multiprocessing/heap.py \
        Lib/multiprocessing/managers.py \
@@ -822,6 +818,10 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
        Lib/pydoc_data/topics.py \
 ))
 
+$(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/site-packages,\
+       Lib/site-packages/README.txt \
+))
+
 $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/unittest,\
        Lib/unittest/__init__.py \
        Lib/unittest/__main__.py \
@@ -906,8 +906,4 @@ $(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
        Lib/zoneinfo/_zoneinfo.py \
 ))
 
-$(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/lib/site-packages,\
-       Lib/site-packages/README.txt \
-))
-
 # vim: set noet sw=4 ts=4:
diff --git a/external/python3/generateExternalPackage.py 
b/external/python3/generateExternalPackage.py
new file mode 100755
index 000000000000..b5fe0d1e158e
--- /dev/null
+++ b/external/python3/generateExternalPackage.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from os import path, walk
+
+if __name__ == '__main__':
+
+    ignoredPackages = ["dbm", "curses", "test", "tkinter", "turtledemo", 
"sqlite3", "idlelib", "venv"]
+
+    coreDir = path.dirname(path.dirname(path.dirname(path.abspath(__file__))))
+    pythonDir = path.join(coreDir, "workdir/UnpackedTarball/python3")
+    libDir = path.join(pythonDir, "Lib")
+    subDirDict = {}
+    for subdir, dirs, files in walk(libDir):
+        filesList = []
+        relPythonDir = path.relpath(subdir, pythonDir)
+        relLibDir = path.relpath(subdir, libDir)
+
+        isShipped = True
+        for package in ignoredPackages:
+            if relLibDir.startswith(package):
+                isShipped = False
+                continue
+
+        if not isShipped:
+            continue
+
+        if "/test" in relLibDir:
+            continue
+
+        for fileName in sorted(files):
+            if fileName.endswith(".pyc"):
+                continue
+            filesList.append(path.join(relPythonDir, fileName))
+        if filesList:
+            subDirDict[relPythonDir] = filesList
+
+    for k,v in sorted(subDirDict.items()):
+        print()
+        if k == "Lib/msilib":
+            print("ifeq (WNT,$(OS))")
+        print("$(eval $(call 
gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/python-core-$(PYTHON_VERSION)/{},\".format(k.lower()))
+        for fileName in sorted(v):
+            print("    {} \".format(fileName))
+        print("))")
+        if k == "Lib/msilib":
+            print("endif")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to