Skip to content

Commit 60d03bd

Browse files
committed
Fix "pip" installation/upgrade on Windows and apply the same setuptools/wheel behavior there
1 parent 05db1ff commit 60d03bd

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

3.5/windows/windowsservercore/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ENV PYTHON_RELEASE 3.5.3
1313

1414
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
1515
ENV PYTHON_PIP_VERSION 9.0.1
16+
ENV PYTHON_SETUPTOOLS_VERSION 35.0.1
17+
ENV PYTHON_WHEEL_VERSION 0.29.0
1618

1719
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
1820
Write-Host ('Downloading {0} ...' -f $url); \
@@ -40,12 +42,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4042
Write-Host 'Removing ...'; \
4143
Remove-Item python.exe -Force; \
4244
\
43-
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
44-
Write-Host ('Installing {0} ...' -f $pipInstall); \
45+
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
4546
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
4647
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
4748
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
48-
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
49+
# (using "python -m pip" instead of "pip" to avoid pip trying to remove itself while it's running; see also https://pip.readthedocs.io/en/stable/installing/#id6)
50+
python -m pip install --no-cache-dir --upgrade --force-reinstall \
51+
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
52+
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
53+
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
54+
; \
4955
\
5056
Write-Host 'Verifying pip install ...'; \
5157
pip --version; \

3.6/windows/windowsservercore/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ENV PYTHON_RELEASE 3.6.1
1313

1414
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
1515
ENV PYTHON_PIP_VERSION 9.0.1
16+
ENV PYTHON_SETUPTOOLS_VERSION 35.0.1
17+
ENV PYTHON_WHEEL_VERSION 0.29.0
1618

1719
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
1820
Write-Host ('Downloading {0} ...' -f $url); \
@@ -40,12 +42,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4042
Write-Host 'Removing ...'; \
4143
Remove-Item python.exe -Force; \
4244
\
43-
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
44-
Write-Host ('Installing {0} ...' -f $pipInstall); \
45+
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
4546
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
4647
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
4748
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
48-
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
49+
# (using "python -m pip" instead of "pip" to avoid pip trying to remove itself while it's running; see also https://pip.readthedocs.io/en/stable/installing/#id6)
50+
python -m pip install --no-cache-dir --upgrade --force-reinstall \
51+
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
52+
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
53+
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
54+
; \
4955
\
5056
Write-Host 'Verifying pip install ...'; \
5157
pip --version; \

Dockerfile-windowsservercore.template

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ENV PYTHON_RELEASE %%PLACEHOLDER%%
77

88
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
99
ENV PYTHON_PIP_VERSION %%PLACEHOLDER%%
10+
ENV PYTHON_SETUPTOOLS_VERSION %%PLACEHOLDER%%
11+
ENV PYTHON_WHEEL_VERSION %%PLACEHOLDER%%
1012

1113
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
1214
Write-Host ('Downloading {0} ...' -f $url); \
@@ -34,12 +36,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3436
Write-Host 'Removing ...'; \
3537
Remove-Item python.exe -Force; \
3638
\
37-
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
38-
Write-Host ('Installing {0} ...' -f $pipInstall); \
39+
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
3940
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
4041
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
4142
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
42-
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
43+
# (using "python -m pip" instead of "pip" to avoid pip trying to remove itself while it's running; see also https://pip.readthedocs.io/en/stable/installing/#id6)
44+
python -m pip install --no-cache-dir --upgrade --force-reinstall \
45+
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
46+
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
47+
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
48+
; \
4349
\
4450
Write-Host 'Verifying pip install ...'; \
4551
pip --version; \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy