File: generateExternalPackage.py

package info (click to toggle)
libreoffice 4%3A26.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,833,120 kB
  • sloc: cpp: 4,395,780; xml: 499,109; java: 254,438; python: 81,820; ansic: 33,823; perl: 30,297; javascript: 19,722; sh: 12,050; makefile: 10,854; cs: 8,865; yacc: 8,549; objc: 2,131; lex: 1,385; asm: 1,231; awk: 996; pascal: 914; csh: 20; sed: 5
file content (58 lines) | stat: -rwxr-xr-x 1,961 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/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 = ["curses", "test", "tkinter", "turtledemo", "idlelib"]

    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

        # ignore setuptools.dist-info and pip.dist-info folders
        if ".dist-info" in relLibDir:
            continue

        for fileName in sorted(files):
            if not fileName.endswith((".py", ".pem", ".exe", ".txt")):
                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.replace("Lib", "lib", 3)))
        for fileName in sorted(v):
            print("\t{} \\".format(fileName))
        print("))")
        if k == "Lib/msilib":
            print("endif")

# vim: set shiftwidth=4 softtabstop=4 expandtab: