Skip to content

Commit a2f02d7

Browse files
authored
Merge pull request #41 from stlehmann/build_upstream
Include script for upstream stub generation
2 parents c770082 + 996dff0 commit a2f02d7

File tree

10 files changed

+425
-104
lines changed

10 files changed

+425
-104
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7-
## [Unreleased]
7+
## 5.14.2.1
88

99
### Added
1010
* [#39](https://github.com/stlehmann/PyQt5-stubs/pull/39) Add this changelog file
11+
* [#36](https://github.com/stlehmann/PyQt5-stubs/pull/36), [#41](https://github.com/stlehmann/PyQt5-stubs/pull/41
12+
) New build script for upstream stubs includes extra
13+
packages
14+
like QtWebEngine and Qt3D
1115

1216
### Changed
13-
1417
* [#38](https://github.com/stlehmann/PyQt5-stubs/pull/38) Changed license to GPLv3 to be compilient with PyQt5 license
1518

1619
### Fixed

Dockerfile

+274
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# Careful, the version and build date are both dates, but different formats
2+
ARG ARCH_VERSION="20200407"
3+
ARG BUILD_DATE="2020/04/22"
4+
5+
ARG PYQT_VERSION="5.14.2"
6+
ARG PYQT_3D_VERSION="5.14.0"
7+
ARG PYQT_CHART_VERSION="5.14.0"
8+
ARG PYQT_DATA_VISUALIZATION_VERSION="5.14.0"
9+
ARG PYQT_PURCHASING_VERSION="5.14.0"
10+
ARG PYQT_WEB_ENGINE_VERSION="5.14.0"
11+
12+
################################################################################
13+
# Build dependencies
14+
################################################################################
15+
16+
FROM archlinux:${ARCH_VERSION} AS build-dep
17+
18+
# Reuse argument from previous build scope
19+
ARG BUILD_DATE
20+
21+
# Use Arch archive to freeze packages to a certain date
22+
RUN echo "Server=https://archive.archlinux.org/repos/${BUILD_DATE}/\$repo/os/\$arch" \
23+
| tee /etc/pacman.d/mirrorlist && \
24+
pacman -Syyuu --noconfirm
25+
26+
# Install build dependencies and Qt Modules
27+
RUN pacman --noconfirm -S \
28+
# Build stuff
29+
base-devel wget \
30+
# PyQt stuff
31+
pyqt-builder python-sip sip5 \
32+
# Used to build other PyQt modules in later build stages
33+
python-pyqt5 \
34+
# Qt core
35+
qt5-base \
36+
# Qt modules not included in qt5-base
37+
qt5-3d \
38+
qt5-charts \
39+
qt5-connectivity \
40+
qt5-datavis3d \
41+
qt5-declarative \
42+
qt5-gamepad \
43+
qt5-graphicaleffects \
44+
qt5-imageformats \
45+
qt5-location \
46+
qt5-multimedia \
47+
qt5-purchasing \
48+
qt5-networkauth \
49+
qt5-remoteobjects \
50+
qt5-script \
51+
qt5-sensors \
52+
qt5-serialport \
53+
qt5-svg \
54+
qt5-tools \
55+
qt5-wayland \
56+
qt5-webchannel \
57+
qt5-webengine \
58+
qt5-webkit \
59+
qt5-websockets \
60+
qt5-x11extras \
61+
qt5-xmlpatterns \
62+
# Required for QtDBus
63+
python-dbus
64+
65+
################################################################################
66+
# PyQt5 core stubs
67+
################################################################################
68+
69+
FROM build-dep AS pyqt5
70+
71+
# Reuse argument from previous build scope
72+
ARG PYQT_VERSION
73+
74+
# Download source tar
75+
RUN wget --no-verbose \
76+
--output-document upstream.tar.gz \
77+
https://pypi.io/packages/source/p/pyqt5/PyQt5-${PYQT_VERSION}.tar.gz
78+
RUN mkdir /upstream/ && \
79+
tar -xf \
80+
upstream.tar.gz \
81+
--directory /upstream/ \
82+
--strip-components 1
83+
84+
# Build PyQt with stubs
85+
# TODO: Find way to build only stubs. This takes way too long
86+
WORKDIR /upstream/
87+
RUN sip-install \
88+
--qmake /usr/bin/qmake-qt5 \
89+
--confirm-license \
90+
--pep484-pyi \
91+
--build-dir ./build \
92+
--verbose
93+
94+
# Copy all .pyi files to output dir
95+
WORKDIR /output/
96+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
97+
98+
################################################################################
99+
# PyQt3D
100+
################################################################################
101+
102+
FROM build-dep AS pyqt-3d
103+
104+
# Reuse argument from previous build scope
105+
ARG PYQT_3D_VERSION
106+
107+
# Download source tar
108+
RUN wget --no-verbose \
109+
--output-document upstream.tar.gz \
110+
https://pypi.io/packages/source/p/pyqt3d/PyQt3D-${PYQT_3D_VERSION}.tar.gz
111+
RUN mkdir /upstream/ && \
112+
tar -xf \
113+
upstream.tar.gz \
114+
--directory /upstream/ \
115+
--strip-components 1
116+
117+
# Build PyQt3D with stubs
118+
# TODO: Find way to build only stubs
119+
WORKDIR /upstream/
120+
RUN sip-install \
121+
--qmake /usr/bin/qmake-qt5 \
122+
--pep484-pyi \
123+
--build-dir ./build \
124+
--verbose
125+
126+
# Copy all .pyi files to output dir
127+
WORKDIR /output/
128+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
129+
130+
################################################################################
131+
# PyQtChart
132+
################################################################################
133+
134+
FROM build-dep AS pyqt-chart
135+
136+
# Reuse argument from previous build scope
137+
ARG PYQT_CHART_VERSION
138+
139+
# Download source tar
140+
RUN wget --no-verbose \
141+
--output-document upstream.tar.gz \
142+
https://pypi.io/packages/source/p/pyqtchart/PyQtChart-${PYQT_CHART_VERSION}.tar.gz
143+
RUN mkdir /upstream/ && \
144+
tar -xf \
145+
upstream.tar.gz \
146+
--directory /upstream/ \
147+
--strip-components 1
148+
149+
# Build PyQtChart with stubs
150+
# TODO: Find way to build only stubs
151+
WORKDIR /upstream/
152+
RUN sip-install \
153+
--qmake /usr/bin/qmake-qt5 \
154+
--pep484-pyi \
155+
--build-dir ./build \
156+
--verbose
157+
158+
# Copy all .pyi files to output dir
159+
WORKDIR /output/
160+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
161+
162+
################################################################################
163+
# PyQtDataVisualization
164+
################################################################################
165+
166+
FROM build-dep AS pyqt-data-visualization
167+
168+
# Reuse argument from previous build scope
169+
ARG PYQT_DATA_VISUALIZATION_VERSION
170+
171+
# Download source tar
172+
RUN wget --no-verbose \
173+
--output-document upstream.tar.gz \
174+
https://pypi.io/packages/source/p/pyqtdatavisualization/PyQtDataVisualization-${PYQT_DATA_VISUALIZATION_VERSION}.tar.gz
175+
RUN mkdir /upstream/ && \
176+
tar -xf \
177+
upstream.tar.gz \
178+
--directory /upstream/ \
179+
--strip-components 1
180+
181+
# Build PyQtDataVisualization with stubs
182+
# TODO: Find way to build only stubs
183+
WORKDIR /upstream/
184+
RUN sip-install \
185+
--qmake /usr/bin/qmake-qt5 \
186+
--pep484-pyi \
187+
--build-dir ./build \
188+
--verbose
189+
190+
# Copy all .pyi files to output dir
191+
WORKDIR /output/
192+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
193+
194+
################################################################################
195+
# PyQtPurchasing
196+
################################################################################
197+
198+
FROM build-dep AS pyqt-purchasing
199+
200+
# Reuse argument from previous build scope
201+
ARG PYQT_PURCHASING_VERSION
202+
203+
# Download source tar
204+
RUN wget --no-verbose \
205+
--output-document upstream.tar.gz \
206+
https://pypi.io/packages/source/p/pyqtpurchasing/PyQtPurchasing-${PYQT_PURCHASING_VERSION}.tar.gz
207+
RUN mkdir /upstream/ && \
208+
tar -xf \
209+
upstream.tar.gz \
210+
--directory /upstream/ \
211+
--strip-components 1
212+
213+
# Build PyQtPurchasing with stubs
214+
# TODO: Find way to build only stubs
215+
WORKDIR /upstream/
216+
RUN sip-install \
217+
--qmake /usr/bin/qmake-qt5 \
218+
--pep484-pyi \
219+
--build-dir ./build \
220+
--verbose
221+
222+
# Copy all .pyi files to output dir
223+
WORKDIR /output/
224+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
225+
226+
################################################################################
227+
# PyQtWebEngine
228+
################################################################################
229+
230+
FROM build-dep AS pyqt-web-engine
231+
232+
# Reuse argument from previous build scope
233+
ARG PYQT_WEB_ENGINE_VERSION
234+
235+
# Download source tar
236+
RUN wget --no-verbose \
237+
--output-document upstream.tar.gz \
238+
https://pypi.io/packages/source/p/pyqtwebengine/PyQtWebEngine-${PYQT_WEB_ENGINE_VERSION}.tar.gz
239+
RUN mkdir /upstream/ && \
240+
tar -xf \
241+
upstream.tar.gz \
242+
--directory /upstream/ \
243+
--strip-components 1
244+
245+
# Build PyQtWebEngine with stubs
246+
# TODO: Find way to build only stubs
247+
WORKDIR /upstream/
248+
RUN sip-install \
249+
--qmake /usr/bin/qmake-qt5 \
250+
--pep484-pyi \
251+
--build-dir ./build \
252+
--verbose
253+
254+
# Copy all .pyi files to output dir
255+
WORKDIR /output/
256+
RUN find /upstream/ -name \*.pyi -exec cp {} . \;
257+
258+
################################################################################
259+
# Output
260+
################################################################################
261+
262+
FROM scratch AS output
263+
264+
# Get all the outputs from the build layers
265+
WORKDIR /output/
266+
COPY --from=pyqt5 /output/* ./
267+
COPY --from=pyqt-3d /output/* ./
268+
COPY --from=pyqt-chart /output/* ./
269+
COPY --from=pyqt-data-visualization /output/* ./
270+
COPY --from=pyqt-purchasing /output/* ./
271+
COPY --from=pyqt-web-engine /output/* ./
272+
273+
# Required to run the image (which we need to do to get the files)
274+
CMD /bin/true

PyQt5-stubs/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "5.14.2.0"
1+
__version__ = "5.14.2.1"

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,29 @@ The following modules are supported by PyQt5-stubs:
3838
* QtTest
3939
* QtXml
4040
* sip
41+
42+
# Building upstream stubs
43+
The Dockerfile is used to build all of the stubs for the upstream PyQt5 modules.
44+
The Dockerfile consists of multiple build layers:
45+
* core: `PyQt5`
46+
* `PyQt3D`
47+
* `PyQtChart`
48+
* `PyQtDataVisualization`
49+
* `PyQtPurchasing`
50+
* `PyQtWebEngine`
51+
* an output layer
52+
53+
Each module build layer deposits its stub files within `/output/` in its
54+
filesystem. The output layer then collects the contents of each into its own
55+
`/output/` dir for export to the host computer. Build args are provided to
56+
change the version of each module.
57+
58+
A convenience script, `build_upstream.py`, is provided. It builds the stubs and
59+
copies them to the host computer. Make sure you install `docker-py` to use it.
60+
It builds `$PWD/Dockerfile` (overridden with `--dockerfile`) and outputs the
61+
stubs to `$PWD/PyQt5-stubs` (overridden with `--output-dir`).
62+
63+
\* There are a few missing modules: `QtAxContainer`, `QtAndroidExtras`,
64+
`QtMacExtras`, and `QtWindowsExtras`. The current project understanding is that
65+
they need to be built on the target platform, something a Linux-based docker
66+
image cannot do. The deprecated `Enginio` module is also missing.

0 commit comments

Comments
 (0)