Skip to content

Commit 727f4e9

Browse files
committed
Use static notation for setuptools in CI pip commands
`setuptools` may potentially be needed for installation to work fully as desired prior to Python 3.12, so in those versions it is installed automatically in any virtual environment that is created with `pip` available. This is a behavior of the `venv` module that is not specific to CI. However, on CI we upgrade packages that are preinstalled in the virtual environment, or that we may otherwise wish to be present. This took the form of unconditionally installing/upgrading the `pip` and `wheel` packages, but conditionally upgrading the `setuptools` package only if we find that it is already installed. This commit changes the behavior to statically specify the same list of package specifications to `pip` in all environments and in all versions of Python, but to use the static notation recognized by `pip` to indicate that `setuptools` is to be instaled/upgraded only if the Python version is strictly less than Python 3.12. This seems to be more readable. It also avoids using unquoted shell parameter expansion in a way that is potentially confusing (for example, if we were running our CI script steps through ShellCheck, then it would automatically balk at that construction). It is also more consistent with how `test_installation` sets up its environment (especially since 31e1c03, but actually even before that, because it was still conditioning `setuptools` on the Python version rather than whether it was already installed). Finally, this behavior is what the preexisting comment already described. This also adjusts the shell quoting style slightly in other related commands (in the same workflows) that pass package specifications to `pip`, for consistency. (For now, `".[test]"` rather than `.[test]` remains written in the readme because it works in `cmd.exe` as well as other shells, but it may be changed there in the future too.)
1 parent 31e1c03 commit 727f4e9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.github/workflows/alpine-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ jobs:
5555
run: |
5656
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
5757
. .venv/bin/activate
58-
python -m pip install -U pip $(pip freeze --all | grep -ow ^setuptools) wheel
58+
python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
5959
6060
- name: Install project and test dependencies
6161
run: |
6262
. .venv/bin/activate
63-
pip install ".[test]"
63+
pip install '.[test]'
6464
6565
- name: Show version and platform information
6666
run: |

.github/workflows/cygwin-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ jobs:
7979
- name: Update PyPA packages
8080
run: |
8181
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
82-
python -m pip install -U pip $(pip freeze --all | grep -ow ^setuptools) wheel
82+
python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
8383
8484
- name: Install project and test dependencies
8585
run: |
86-
pip install ".[test]"
86+
pip install '.[test]'
8787
8888
- name: Show version and platform information
8989
run: |

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ jobs:
7272
- name: Update PyPA packages
7373
run: |
7474
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
75-
python -m pip install -U pip $(pip freeze --all | grep -ow ^setuptools) wheel
75+
python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
7676
7777
- name: Install project and test dependencies
7878
run: |
79-
pip install ".[test]"
79+
pip install '.[test]'
8080
8181
- name: Show version and platform information
8282
run: |
@@ -114,5 +114,5 @@ jobs:
114114
- name: Documentation
115115
if: matrix.python-version != '3.7'
116116
run: |
117-
pip install ".[doc]"
117+
pip install '.[doc]'
118118
make -C doc html

0 commit comments

Comments
 (0)