Skip to content

Commit

Permalink
Use jq's IN() instead of index()
Browse files Browse the repository at this point in the history
The end result is the same, but the construction is more ergonomic.
  • Loading branch information
tianon committed Oct 16, 2024
1 parent e7036a2 commit 068b62c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Dockerfile-windows-servercore.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{ def is_3: env.version | startswith("3") -}}
{{ def cmd: if [ "3.8" ] | index(env.version) then "pypy3" else "pypy" end -}}
FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }}

# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
Expand Down Expand Up @@ -68,8 +67,8 @@ RUN $url = '{{ .arches["windows-amd64"].url }}'; \
Write-Host 'Renaming ...'; \
Rename-Item -Path C:\{{ .arches["windows-amd64"].url | rtrimstr(".zip") | split("/")[-1] }} -NewName C:\pypy; \
\
Write-Host 'Verifying install ("{{ cmd }} --version") ...'; \
{{ cmd }} --version; \
Write-Host 'Verifying install ("pypy --version") ...'; \
pypy --version; \
\
Write-Host 'Cleanup install ...'; \
Get-ChildItem \
Expand Down Expand Up @@ -100,11 +99,11 @@ RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL);
exit 1; \
}; \
\
$pipVersion = & {{ cmd }} -c 'import ensurepip; print(ensurepip._PIP_VERSION)'; \
$setuptoolsVersion = & {{ cmd }} -c 'import ensurepip; print(ensurepip._SETUPTOOLS_VERSION)'; \
$pipVersion = & pypy -c 'import ensurepip; print(ensurepip._PIP_VERSION)'; \
$setuptoolsVersion = & pypy -c 'import ensurepip; print(ensurepip._SETUPTOOLS_VERSION)'; \
\
Write-Host ('Installing "pip == {0}", "setuptools == {1}" ...' -f $pipVersion, $setuptoolsVersion); \
{{ cmd }} get-pip.py \
pypy get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
('pip == {0}' -f $pipVersion) \
Expand All @@ -131,4 +130,4 @@ RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL);
\
Write-Host 'Complete.'

CMD {{ [ cmd ] | @json }}
CMD ["pypy"]

0 comments on commit 068b62c

Please sign in to comment.