Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use --upgrade rather than --ignore-installed to upgrade pip #268

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build-python-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ jobs:
- name: Fully cleanup the toolcache directory before testing
run: ./helpers/clean-toolcache.ps1 -ToolName "Python"

- name: Delete macOS /Library/Frameworks/Python.framework
if: matrix.platform == 'darwin'
shell: bash
run: if [ -d /Library/Frameworks/Python.framework ]; then sudo rm -rf /Library/Frameworks/Python.framework; fi

Comment on lines +108 to +112
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required because current macos-11 runners come with 2 outdated pip dist-info.

When installing from pkg, these will be left alone and only one out of the 2 outdated version will be removed by --upgrade thus failing the tests.

Once runners are using fixed installs of Python, this block can removed.

- name: Download artifact
uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion installers/macos-pkg-setup-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ chmod +x ../python $PYTHON_MAJOR $PYTHON_MAJOR_DOT_MINOR $PYTHON_MAJOR_MINOR pyt
echo "Upgrading pip..."
export PIP_ROOT_USER_ACTION=ignore
./python -m ensurepip
./python -m pip install --ignore-installed pip --disable-pip-version-check --no-warn-script-location
./python -m pip install --upgrade pip --disable-pip-version-check --no-warn-script-location

echo "Install OpenSSL certificates"
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
Expand Down
2 changes: 1 addition & 1 deletion installers/nix-setup-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ chmod +x ../python $PYTHON_MAJOR $PYTHON_MAJOR_DOT_MINOR $PYTHON_MAJORMINOR pyth
echo "Upgrading pip..."
export PIP_ROOT_USER_ACTION=ignore
./python -m ensurepip
./python -m pip install --ignore-installed pip --disable-pip-version-check --no-warn-script-location
./python -m pip install --upgrade pip --disable-pip-version-check --no-warn-script-location

echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete
4 changes: 4 additions & 0 deletions tests/python-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ Describe "Tests" {
It "Check urlopen with HTTPS works" {
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
}

It "Check a single dist-info per distribution is present" {
"python ./sources/dist-info.py" | Should -ReturnZeroExitCode
}
}
24 changes: 24 additions & 0 deletions tests/sources/dist-info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import glob
import os.path
import sysconfig
from collections import defaultdict


def check_dist_info():
paths = set([sysconfig.get_path("purelib"), sysconfig.get_path("platlib")])
versions = defaultdict(list)
for path in paths:
pattern = os.path.join(path, "*.dist-info")
for dist_info in glob.glob(pattern):
name = os.path.basename(dist_info).split("-", maxsplit=1)[0]
versions[name].append(dist_info)
exit_code = 0
for name in versions:
if len(versions[name]) > 1:
print("multiple dist-info found for {}: {}".format(name, versions[name]))
exit_code = 1
exit(exit_code)


if __name__ == "__main__":
check_dist_info()