Skip to content

Commit 25b50ed

Browse files
committed
Elaborate Dockerfile to build additional PyQt5 modules
1 parent cc347fc commit 25b50ed

File tree

1 file changed

+212
-8
lines changed

1 file changed

+212
-8
lines changed

Dockerfile

Lines changed: 212 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# Careful, the version and build date are both dates, but different formats
22
ARG ARCH_VERSION="20200407"
33
ARG BUILD_DATE="2020/04/22"
4+
45
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+
################################################################################
515

6-
FROM archlinux:${ARCH_VERSION}
16+
FROM archlinux:${ARCH_VERSION} AS build-dep
717

8-
# Reuse arguments from previous build scope
18+
# Reuse argument from previous build scope
919
ARG BUILD_DATE
10-
ARG PYQT_VERSION
1120

1221
# Use Arch archive to freeze packages to a certain date
1322
RUN echo "Server=https://archive.archlinux.org/repos/${BUILD_DATE}/\$repo/os/\$arch" \
@@ -20,10 +29,13 @@ RUN pacman --noconfirm -S \
2029
base-devel wget \
2130
# PyQt stuff
2231
pyqt-builder python-sip sip5 \
32+
# Used to build other PyQt modules in later build stages
33+
python-pyqt5 \
2334
# Qt core
2435
qt5-base \
2536
# Qt modules not included in qt5-base
2637
qt5-3d \
38+
qt5-charts \
2739
qt5-connectivity \
2840
qt5-datavis3d \
2941
qt5-declarative \
@@ -50,14 +62,28 @@ RUN pacman --noconfirm -S \
5062
# Required for QtDBus
5163
python-dbus
5264

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+
5374
# Download source tar
54-
WORKDIR /upstream/
55-
RUN wget --no-verbose https://pypi.io/packages/source/p/pyqt5/PyQt5-${PYQT_VERSION}.tar.gz
56-
RUN tar -xf PyQt5-${PYQT_VERSION}.tar.gz
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
5783

5884
# Build PyQt with stubs
5985
# TODO: Find way to build only stubs. This takes way too long
60-
WORKDIR PyQt5-${PYQT_VERSION}/
86+
WORKDIR /upstream/
6187
RUN sip-install \
6288
--qmake /usr/bin/qmake-qt5 \
6389
--confirm-license \
@@ -67,4 +93,182 @@ RUN sip-install \
6793

6894
# Copy all .pyi files to output dir
6995
WORKDIR /output/
70-
RUN find /upstream/PyQt5-${PYQT_VERSION}/ -name \*.pyi -exec cp {} . \;
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

0 commit comments

Comments
 (0)