Removed
Link Here
|
1 |
From https://github.com/frescobaldi/python-poppler-qt5/pull/41/commits/4ee58b6ee02772db915fdc5e70e336e0e5b2f34c |
2 |
|
3 |
--- project.py.orig 2020-10-11 18:59:42 UTC |
4 |
+++ project.py |
5 |
@@ -0,0 +1,89 @@ |
6 |
+"""The build configuration file for Python-Poppler-Qt5, used by sip.""" |
7 |
+ |
8 |
+from os.path import join |
9 |
+import re |
10 |
+import subprocess |
11 |
+from pyqtbuild import PyQtBindings, PyQtProject |
12 |
+from sipbuild import Option |
13 |
+import PyQt5 |
14 |
+ |
15 |
+ |
16 |
+class PythonPopplerQt5(PyQtProject): |
17 |
+ """The Project class.""" |
18 |
+ |
19 |
+ def __init__(self): |
20 |
+ super().__init__() |
21 |
+ self.bindings_factories = [PopplerQt5Bindings] |
22 |
+ |
23 |
+ def update(self, tool): |
24 |
+ """Allows SIP to find PyQt5 .sip files.""" |
25 |
+ super().update(tool) |
26 |
+ self.sip_include_dirs.append(join(PyQt5.__path__[0], 'bindings')) |
27 |
+ |
28 |
+ |
29 |
+class PopplerQt5Bindings(PyQtBindings): |
30 |
+ """The Poppler-Qt5 Bindings class.""" |
31 |
+ |
32 |
+ def __init__(self, project): |
33 |
+ super().__init__(project, name='Poppler-Qt5', |
34 |
+ sip_file='poppler-qt5.sip', |
35 |
+ qmake_QT=['xml']) |
36 |
+ |
37 |
+ def get_options(self): |
38 |
+ """Our custom options that a user can pass to sip-build.""" |
39 |
+ options = super().get_options() |
40 |
+ options.append( |
41 |
+ Option('poppler_version', |
42 |
+ help='version of the poppler library', |
43 |
+ metavar='VERSION')) |
44 |
+ return options |
45 |
+ |
46 |
+ @staticmethod |
47 |
+ def run_pkg_config(option): |
48 |
+ output = subprocess.check_output( |
49 |
+ ['pkg-config', option, 'poppler-qt5'], |
50 |
+ text=True) |
51 |
+ return output.rstrip() |
52 |
+ |
53 |
+ def apply_user_defaults(self, tool): |
54 |
+ # Set include_dirs, library_dirs and libraries based on pkg-config data |
55 |
+ cflags = self.run_pkg_config('--cflags-only-I').split() |
56 |
+ libs = self.run_pkg_config('--libs').split() |
57 |
+ self.include_dirs.extend( |
58 |
+ flag[2:] for flag in cflags if flag.startswith('-I')) |
59 |
+ self.library_dirs.extend( |
60 |
+ flag[2:] for flag in libs if flag.startswith('-L')) |
61 |
+ self.libraries.extend( |
62 |
+ flag[2:] for flag in libs if flag.startswith('-l')) |
63 |
+ |
64 |
+ # Generate version.sip file |
65 |
+ if self.poppler_version is not None: |
66 |
+ poppler_qt5_version = self.poppler_version |
67 |
+ else: |
68 |
+ poppler_qt5_version = self.run_pkg_config('--modversion') |
69 |
+ poppler_qt5_version = tuple(map(int, poppler_qt5_version.split('.'))) |
70 |
+ python_poppler_qt5_version = self.project.version_str.split('.') |
71 |
+ format_dict = { |
72 |
+ 'vlen': 'i' * len(python_poppler_qt5_version), |
73 |
+ 'vargs': ', '.join(python_poppler_qt5_version), |
74 |
+ 'pvlen': 'i' * len(poppler_qt5_version), |
75 |
+ 'pvargs': ', '.join(map(str, poppler_qt5_version)), |
76 |
+ } |
77 |
+ with open('version.sip.in') as template_file: |
78 |
+ version_sip_template = template_file.read() |
79 |
+ with open('version.sip', 'w') as version_file: |
80 |
+ version_file.write(version_sip_template.format(**format_dict)) |
81 |
+ |
82 |
+ # Add Poppler version tag |
83 |
+ if poppler_qt5_version: |
84 |
+ with open('timeline.sip') as timeline_file: |
85 |
+ timeline = timeline_file.read() |
86 |
+ for match in re.finditer(r'POPPLER_V(\d+)_(\d+)_(\d+)', timeline): |
87 |
+ if poppler_qt5_version < tuple(map(int, match.group(1, 2, 3))): |
88 |
+ break |
89 |
+ tag = match.group() |
90 |
+ else: |
91 |
+ tag = 'POPPLER_V0_20_0' |
92 |
+ self.tags.append(tag) |
93 |
+ self.tags.append("WS_X11") |
94 |
+ super().apply_user_defaults(tool) |