Skip to content

Commit 14fb3fc

Browse files
committed
Fixing python
1 parent 32d29d9 commit 14fb3fc

File tree

134 files changed

+5676
-4312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+5676
-4312
lines changed

.automation/build.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def build_dockerfile(
292292
is_docker_other_run = False
293293
is_docker_build_platform_other_run = False
294294
has_npm_copy = False
295+
venv_builddeps_command = []
296+
venv_apk_builddeps = ["gcc", "libffi-dev", "musl-dev", "make", "curl", "openssl-dev"]
295297
# Manage docker
296298
if requires_docker is True:
297299
apk_packages += ["docker", "openrc"]
@@ -449,6 +451,10 @@ def build_dockerfile(
449451
# Collect apk packages
450452
if "apk" in item["install"]:
451453
apk_packages += item["install"]["apk"]
454+
if "pip_apk" in item["install"]:
455+
venv_apk_builddeps += item["install"]["pip_apk"]
456+
if "pip_builddep" in item["install"]:
457+
venv_builddeps_command += item["install"]["pip_builddep"]
452458
if "build_platform_apk" in item["install"]:
453459
apk_build_platform_packages += item["install"]["build_platform_apk"]
454460
if "npm_apk" in item["install"]:
@@ -498,6 +504,11 @@ def build_dockerfile(
498504
"RUN apk add --update --no-cache \\\n "
499505
+ " \\\n ".join(list(dict.fromkeys(apk_npm_packages)))
500506
)
507+
if len(venv_apk_builddeps) > 0:
508+
venv_builddeps_command = [(
509+
"RUN apk add --update --no-cache \\\n "
510+
+ " \\\n ".join(list(dict.fromkeys(venv_apk_builddeps)))
511+
)] + venv_builddeps_command
501512
replace_in_file(dockerfile, "#APK__START", "#APK__END", apk_install_command)
502513
replace_in_file(dockerfile, "#BUILD_PLATFORM_APK__START", "#BUILD_PLATFORM_APK__END", apk_build_platform_install_command)
503514
replace_in_file(dockerfile, "#NPM_APK__START", "#NPM_APK__END", apk_npm_install_command)
@@ -652,6 +663,9 @@ def build_dockerfile(
652663
replace_in_file(
653664
dockerfile, "#PIPVENV_DOWNLOAD__START", "#PIPVENV_DOWNLOAD__END", pipenv_download_command
654665
)
666+
replace_in_file(
667+
dockerfile, "#PIPVENV_BUILDDEPS__START", "#PIPVENV_BUILDDEPS__END", "\\n".join(venv_builddeps_command)
668+
)
655669
replace_in_file(
656670
dockerfile, "#PIPVENV_PATH__START", "#PIPVENV_PATH__END", pipenv_path_command
657671
)

Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,21 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip crossenv
259259

260260
#PIPVENV_DOWNLOAD__END
261261

262-
#PIPVENV_APK__START
263-
RUN apk add --update --no-cache gcc musl-dev libffi-dev rust cargo cmake make g++ openssl-dev
264-
#PIPVENV_APK__END
262+
#PIPVENV_BUILDDEPS__START
263+
RUN apk add --update --no-cache \
264+
gcc \
265+
libffi-dev \
266+
musl-dev \
267+
make \
268+
curl \
269+
openssl-dev \
270+
g++ \
271+
cmake
272+
ENV CFLAGS=-mno-outline-atomics
273+
#PIPVENV_BUILDDEPS__END
274+
275+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable
276+
ENV PATH=${PATH}:/root/.cargo/bin
265277

266278
RUN mkdir /venvs
267279

@@ -271,7 +283,7 @@ COPY --link --from=target-python /usr/local/bin/python3 /usr/local/bin/target-py
271283
################################
272284
# Installs python dependencies #
273285
################################
274-
COPY megalinter /megalinter
286+
COPY --link megalinter /megalinter
275287
RUN mkdir -p "/venvs/megalinter" \
276288
&& cd "/venvs/megalinter" \
277289
&& python3 -m crossenv /usr/local/bin/target-python3 . \

flavors/ci_light/Dockerfile

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,54 @@ FROM --platform=$BUILDPLATFORM python:3.11.3-alpine3.17 AS build-platform
6666

6767
#BUILD_PLATFORM_OTHER__END
6868

69+
FROM --platform=$BUILDPLATFORM python:3.11.3-alpine3.17 AS node_modules
70+
71+
#NPM_APK__START
72+
RUN apk add --update --no-cache \
73+
npm
74+
#NPM_APK__END
75+
76+
############################
77+
# Install NPM dependencies #
78+
#############################################################################################
79+
## @generated by .automation/build.py using descriptor files, please do not update manually ##
80+
#############################################################################################
81+
82+
ENV NODE_OPTIONS="--max-old-space-size=8192" \
83+
NODE_ENV=production
84+
#NPM__START
85+
WORKDIR /node-deps
86+
RUN npm --no-cache install --ignore-scripts --omit=dev \
87+
jscpd \
88+
npm-groovy-lint \
89+
@prantlf/jsonlint \
90+
eslint \
91+
eslint-plugin-jsonc \
92+
@microsoft/eslint-formatter-sarif \
93+
v8r \
94+
prettier \
95+
secretlint \
96+
@secretlint/secretlint-rule-preset-recommend \
97+
@secretlint/secretlint-formatter-sarif && \
98+
echo "Cleaning npm cache..." \
99+
&& npm cache clean --force || true \
100+
&& echo "Changing owner of node_modules files..." \
101+
&& chown -R "$(id -u)":"$(id -g)" node_modules # fix for https://github.com/npm/cli/issues/5900 \
102+
&& echo "Removing extra node_module files..." \
103+
&& rm -rf /root/.npm/_cacache \
104+
&& find . -name "*.d.ts" -delete \
105+
&& find . -name "*.map" -delete \
106+
&& find . -name "*.npmignore" -delete \
107+
&& find . -name "*.travis.yml" -delete \
108+
&& find . -name "CHANGELOG.md" -delete \
109+
&& find . -name "README.md" -delete \
110+
&& find . -name ".package-lock.json" -delete \
111+
&& find . -name "package-lock.json" -delete \
112+
&& find . -name "README.md" -delete
113+
WORKDIR /
114+
115+
#NPM__END
116+
69117
FROM scratch AS copy-collector
70118

71119
##############################
@@ -99,18 +147,28 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip crossenv
99147

100148
#PIPVENV_DOWNLOAD__END
101149

102-
#PIPVENV_APK__START
103-
RUN apk add --update --no-cache gcc musl-dev libffi-dev rust cargo cmake make g++ openssl-dev
104-
#PIPVENV_APK__END
150+
#RUN apk add --update --no-cache cmake g++
151+
#PIPVENV_BUILDDEPS__START
152+
RUN apk add --update --no-cache \
153+
gcc \
154+
libffi-dev \
155+
musl-dev \
156+
make \
157+
curl \
158+
openssl-dev
159+
#PIPVENV_BUILDDEPS__END
160+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable
161+
ENV PATH=${PATH}:/root/.cargo/bin
105162

106163
RUN mkdir /venvs
107164

165+
ARG TARGETPLATFORM
108166
COPY --link --from=target-python /usr/local/bin/python3 /usr/local/bin/target-python3
109167

110168
################################
111169
# Installs python dependencies #
112170
################################
113-
COPY megalinter /megalinter
171+
COPY --link megalinter /megalinter
114172
RUN mkdir -p "/venvs/megalinter" \
115173
&& cd "/venvs/megalinter" \
116174
&& python3 -m crossenv /usr/local/bin/target-python3 . \
@@ -128,54 +186,6 @@ RUN echo \
128186

129187
#PIPVENV__END
130188

131-
FROM --platform=$BUILDPLATFORM python:3.11.3-alpine3.17 AS node_modules
132-
133-
#NPM_APK__START
134-
RUN apk add --update --no-cache \
135-
npm
136-
#NPM_APK__END
137-
138-
############################
139-
# Install NPM dependencies #
140-
#############################################################################################
141-
## @generated by .automation/build.py using descriptor files, please do not update manually ##
142-
#############################################################################################
143-
144-
ENV NODE_OPTIONS="--max-old-space-size=8192" \
145-
NODE_ENV=production
146-
#NPM__START
147-
WORKDIR /node-deps
148-
RUN npm --no-cache install --ignore-scripts --omit=dev \
149-
jscpd \
150-
npm-groovy-lint \
151-
@prantlf/jsonlint \
152-
eslint \
153-
eslint-plugin-jsonc \
154-
@microsoft/eslint-formatter-sarif \
155-
v8r \
156-
prettier \
157-
secretlint \
158-
@secretlint/secretlint-rule-preset-recommend \
159-
@secretlint/secretlint-formatter-sarif && \
160-
echo "Cleaning npm cache..." \
161-
&& npm cache clean --force || true \
162-
&& echo "Changing owner of node_modules files..." \
163-
&& chown -R "$(id -u)":"$(id -g)" node_modules # fix for https://github.com/npm/cli/issues/5900 \
164-
&& echo "Removing extra node_module files..." \
165-
&& rm -rf /root/.npm/_cacache \
166-
&& find . -name "*.d.ts" -delete \
167-
&& find . -name "*.map" -delete \
168-
&& find . -name "*.npmignore" -delete \
169-
&& find . -name "*.travis.yml" -delete \
170-
&& find . -name "CHANGELOG.md" -delete \
171-
&& find . -name "README.md" -delete \
172-
&& find . -name ".package-lock.json" -delete \
173-
&& find . -name "package-lock.json" -delete \
174-
&& find . -name "README.md" -delete
175-
WORKDIR /
176-
177-
#NPM__END
178-
179189
##################
180190
# Get base image #
181191
##################

0 commit comments

Comments
 (0)