Skip to content

Commit

Permalink
Fix "pip" installation/upgrade on Windows and apply the same setuptoo…
Browse files Browse the repository at this point in the history
…ls/wheel behavior there
  • Loading branch information
tianon committed Apr 25, 2017
1 parent 05db1ff commit 60d03bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
12 changes: 9 additions & 3 deletions 3.5/windows/windowsservercore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV PYTHON_RELEASE 3.5.3

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

RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
Expand Down Expand Up @@ -40,12 +42,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
Write-Host 'Removing ...'; \
Remove-Item python.exe -Force; \
\
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
Write-Host ('Installing {0} ...' -f $pipInstall); \
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
# 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
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
# (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)
python -m pip install --no-cache-dir --upgrade --force-reinstall \
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
Expand Down
12 changes: 9 additions & 3 deletions 3.6/windows/windowsservercore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV PYTHON_RELEASE 3.6.1

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

RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
Expand Down Expand Up @@ -40,12 +42,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
Write-Host 'Removing ...'; \
Remove-Item python.exe -Force; \
\
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
Write-Host ('Installing {0} ...' -f $pipInstall); \
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
# 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
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
# (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)
python -m pip install --no-cache-dir --upgrade --force-reinstall \
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile-windowsservercore.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENV PYTHON_RELEASE %%PLACEHOLDER%%

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

RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
Expand Down Expand Up @@ -34,12 +36,16 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
Write-Host 'Removing ...'; \
Remove-Item python.exe -Force; \
\
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
Write-Host ('Installing {0} ...' -f $pipInstall); \
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
# 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
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
# (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)
python -m pip install --no-cache-dir --upgrade --force-reinstall \
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
('setuptools=={0}' -f $env:PYTHON_SETUPTOOLS_VERSION) \
('wheel=={0}' -f $env:PYTHON_WHEEL_VERSION) \
; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
Expand Down

0 comments on commit 60d03bd

Please sign in to comment.