Skip to content

Commit 82c02d3

Browse files
authored
Remove duplicate get_external_apt_dependencies.py and re-standardize CI package install logs (#14533)
1 parent 2b27104 commit 82c02d3

File tree

6 files changed

+26
-44
lines changed

6 files changed

+26
-44
lines changed

.github/workflows/daily.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,19 @@ jobs:
8080
8181
if [ "${{ runner.os }}" = "Linux" ]; then
8282
if [ -n "$PACKAGES" ]; then
83+
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
8384
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
8485
fi
8586
8687
PYTHON_EXECUTABLE="xvfb-run python"
8788
else
8889
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
90+
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
8991
brew install -q $PACKAGES
9092
fi
9193
9294
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
95+
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
9396
choco install -y $PACKAGES
9497
fi
9598

.github/workflows/stubtest_third_party.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ jobs:
6666
6767
if [ "${{ runner.os }}" = "Linux" ]; then
6868
if [ -n "$PACKAGES" ]; then
69-
echo "Installing apt packages: $PACKAGES"
69+
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
7070
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
7171
fi
7272
7373
PYTHON_EXECUTABLE="xvfb-run python"
7474
else
7575
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
76-
echo "Installing Homebrew packages: $PACKAGES"
76+
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
7777
brew install -q $PACKAGES
7878
fi
7979
8080
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
81-
echo "Installing Chocolatey packages: $PACKAGES"
81+
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
8282
choco install -y $PACKAGES
8383
fi
8484

.github/workflows/tests.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ jobs:
5656
- run: uv pip install -r requirements-tests.txt --system
5757
- name: Install required APT packages
5858
run: |
59-
sudo apt-get update -qy
60-
DEPENDENCIES=$( python tests/get_external_apt_dependencies.py )
61-
if [ -n "$DEPENDENCIES" ]; then
62-
printf "Installing APT packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
63-
sudo apt-get install -qy $DEPENDENCIES
59+
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
60+
if [ -n "$PACKAGES" ]; then
61+
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
62+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
6463
fi
6564
- name: Run mypy_test.py
6665
run: |
@@ -108,24 +107,23 @@ jobs:
108107
with:
109108
version-file: "requirements-tests.txt"
110109
- name: Install typeshed test-suite requirements
111-
# Install these so we can run `get_external_stub_requirements.py`
110+
# Install these so we can run `get_*_requirements.py`
112111
run: uv pip install -r requirements-tests.txt --system
113112
- name: Install required APT packages
114113
run: |
115-
sudo apt-get update -qy
116-
DEPENDENCIES=$( python tests/get_external_apt_dependencies.py )
117-
if [ -n "$DEPENDENCIES" ]; then
118-
printf "Installing APT packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
119-
sudo apt-get install -qy $DEPENDENCIES
114+
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
115+
if [ -n "$PACKAGES" ]; then
116+
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
117+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
120118
fi
121119
- name: Create an isolated venv for testing
122120
run: uv venv .venv
123121
- name: Install 3rd-party stub dependencies
124122
run: |
125-
DEPENDENCIES=$( python tests/get_external_stub_requirements.py )
126-
if [ -n "$DEPENDENCIES" ]; then
127-
printf "Installing packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
128-
uv pip install --python-version ${{ matrix.python-version }} $DEPENDENCIES
123+
PACKAGES=$(python tests/get_external_stub_requirements.py)
124+
if [ -n "$PACKAGES" ]; then
125+
printf "Installing python packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
126+
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
129127
fi
130128
- name: Activate the isolated venv for the rest of the job
131129
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH

lib/ts_utils/requirements.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ def get_external_stub_requirements(distributions: Iterable[str] = ()) -> set[Req
1818
return set(itertools.chain.from_iterable([read_dependencies(distribution).external_pkgs for distribution in distributions]))
1919

2020

21-
def get_stubtest_system_requirements(distributions: Iterable[str] = (), platform: str = sys.platform) -> list[str]:
21+
def get_stubtest_system_requirements(distributions: Iterable[str] = (), platform: str = sys.platform) -> set[str]:
2222
if not distributions:
2323
distributions = os.listdir(STUBS_PATH)
2424

25-
requirements: list[str] = []
26-
for distribution in distributions:
27-
requirements.extend(read_stubtest_settings(distribution).system_requirements_for_platform(platform))
28-
return requirements
25+
return set(
26+
itertools.chain.from_iterable(
27+
[read_stubtest_settings(distribution).system_requirements_for_platform(platform) for distribution in distributions]
28+
)
29+
)

tests/get_external_apt_dependencies.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/get_stubtest_system_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
if __name__ == "__main__":
77
distributions = sys.argv[1:]
8-
for requirement in get_stubtest_system_requirements(distributions):
8+
for requirement in sorted(get_stubtest_system_requirements(distributions)):
99
print(requirement)

0 commit comments

Comments
 (0)