From 61deba65bf47cb5dd7cb6939878b962036eb6cd1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 18 Oct 2022 14:39:46 +0300 Subject: [PATCH 01/24] Run stubtest on stubs on different platforms --- .github/workflows/daily.yml | 2 +- .github/workflows/stubtest_stubs.yml | 69 ++++++++++++++++++++++++++++ .github/workflows/tests.yml | 33 ------------- CONTRIBUTING.md | 3 ++ stubs/JACK-Client/METADATA.toml | 1 + stubs/pyaudio/METADATA.toml | 1 + stubs/pycurl/METADATA.toml | 1 + tests/get_apt_packages.py | 14 ------ tests/get_packages.py | 23 ++++++++++ tests/stubtest_third_party.py | 5 ++ 10 files changed, 104 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/stubtest_stubs.yml delete mode 100755 tests/get_apt_packages.py create mode 100755 tests/get_packages.py diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 6dace9482b30..29122711b275 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -54,7 +54,7 @@ jobs: - name: Install apt packages run: | sudo apt update - sudo apt install -y $(python tests/get_apt_packages.py) + sudo apt install -y $(python tests/get_packages.py) - name: Run stubtest run: xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} diff --git a/.github/workflows/stubtest_stubs.yml b/.github/workflows/stubtest_stubs.yml new file mode 100644 index 000000000000..e5348fdb3c52 --- /dev/null +++ b/.github/workflows/stubtest_stubs.yml @@ -0,0 +1,69 @@ +name: Test + +on: + pull_request: + paths-ignore: + - '**/*.md' + - 'scripts/**' + +permissions: + contents: read + +env: + PIP_DISABLE_PIP_VERSION_CHECK: 1 + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + stubtest-third-party: + name: Check third party stubs with stubtest + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install dependencies + run: pip install -r requirements-tests.txt + - name: Run stubtest + run: | + STUBS=$( + git diff --name-only origin/${{ github.base_ref }} HEAD | + # Uncomment the following to (very slowly) run on all third party stubs: + # git ls-files | + egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done) + ) + if test -n "$STUBS"; then + echo "Testing $STUBS..." + PACKAGES=$(python tests/get_packages.py $STUBS) + + if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then + if test -n "$PACKAGES"; then + echo "Installing apt packages: $PACKAGES" + sudo apt update && sudo apt install -y $PACKAGES + fi + xvfb-run python tests/stubtest_third_party.py $STUBS + fi + + if [ "${{ matrix.os }}" = "macos-latest" ]; then + # TODO: install brew packages + python tests/stubtest_third_party.py $STUBS + fi + + if [ "${{ matrix.os }}" = "windows-latest" ]; then + # TODO: support windows + python tests/stubtest_third_party.py $STUBS + fi + else + echo "Nothing to test" + fi diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b407ba22e364..2b4b6a14fcbc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -147,36 +147,3 @@ jobs: cd stub_uploader pip install -r requirements.txt python -m pytest tests - - stubtest-third-party: - name: Check third party stubs with stubtest - runs-on: ubuntu-20.04 - if: github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - name: Install dependencies - run: pip install -r requirements-tests.txt - - name: Run stubtest - run: | - STUBS=$( - git diff --name-only origin/${{ github.base_ref }} HEAD | - # Uncomment the following to (very slowly) run on all third party stubs: - # git ls-files | - egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done) - ) - if test -n "$STUBS"; then - echo "Testing $STUBS..." - APT_PACKAGES=$(python tests/get_apt_packages.py $STUBS) - if test -n "$APT_PACKAGES"; then - echo "Installing apt packages: $APT_PACKAGES" - sudo apt update && sudo apt install -y $APT_PACKAGES - fi - xvfb-run python tests/stubtest_third_party.py $STUBS - else - echo "Nothing to test" - fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36d67c31ed0d..88b0c9499dad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,6 +192,9 @@ This has the following keys: * `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages that need to be installed for stubtest to run successfully. These are usually packages needed to pip install the implementation distribution. +* `platform` (default: `None`): A list of supported OSes. + Can contain `win32`, `linux`, and `darwin` values. + If not specified, all platforms are considered supported. The format of all `METADATA.toml` files can be checked by running `python3 ./tests/check_consistent.py`. diff --git a/stubs/JACK-Client/METADATA.toml b/stubs/JACK-Client/METADATA.toml index 5e65c85ad252..45edee0c70e6 100644 --- a/stubs/JACK-Client/METADATA.toml +++ b/stubs/JACK-Client/METADATA.toml @@ -1,4 +1,5 @@ version = "0.5.*" [tool.stubtest] +platform = ["linux"] apt_dependencies = ["libjack-dev"] diff --git a/stubs/pyaudio/METADATA.toml b/stubs/pyaudio/METADATA.toml index a259ccae9200..c2c82cfa292f 100644 --- a/stubs/pyaudio/METADATA.toml +++ b/stubs/pyaudio/METADATA.toml @@ -1,4 +1,5 @@ version = "0.2.*" [tool.stubtest] +platform = ["linux"] apt_dependencies = ["portaudio19-dev"] diff --git a/stubs/pycurl/METADATA.toml b/stubs/pycurl/METADATA.toml index 575cf2229e09..8153427fc7ef 100644 --- a/stubs/pycurl/METADATA.toml +++ b/stubs/pycurl/METADATA.toml @@ -1,4 +1,5 @@ version = "7.45.*" [tool.stubtest] +platform = ["linux"] apt_dependencies = ["libcurl4-openssl-dev"] diff --git a/tests/get_apt_packages.py b/tests/get_apt_packages.py deleted file mode 100755 index 9a902ee99d1d..000000000000 --- a/tests/get_apt_packages.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 -import os -import sys - -import tomli - -distributions = sys.argv[1:] -if not distributions: - distributions = os.listdir("stubs") - -for distribution in distributions: - with open(f"stubs/{distribution}/METADATA.toml", "rb") as file: - for apt_package in tomli.load(file).get("tool", {}).get("stubtest", {}).get("apt_dependencies", []): - print(apt_package) diff --git a/tests/get_packages.py b/tests/get_packages.py new file mode 100755 index 000000000000..fad2b6365324 --- /dev/null +++ b/tests/get_packages.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import os +import sys + +import tomli + +platform = sys.platform +distributions = sys.argv[1:] +if not distributions: + distributions = os.listdir("stubs") + +metadata_mapping = { + "linux": "apt_dependencies", + # TODO: support others: + # "darwin": "brew_dependencies", + # "win32": "choco_dependencies", +} + +if platform in metadata_mapping: + for distribution in distributions: + with open(f"stubs/{distribution}/METADATA.toml", "rb") as file: + for package in tomli.load(file).get("tool", {}).get("stubtest", {}).get(metadata_mapping[platform], []): + print(package) diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 2f3e55845ab6..5d3bf82f13d6 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -34,6 +34,11 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: print(colored("skipping", "yellow")) return True + platform = metadata.get("tool", {}).get("plaform", None) + if platform is not None and sys.platform not in platform: + print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platform}", "yellow")) + return True + with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) venv.create(venv_dir, with_pip=True, clear=True) From 0a96d994c496616e8dada07f48574497238c073c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 18 Oct 2022 14:48:39 +0300 Subject: [PATCH 02/24] Fix CI --- .github/workflows/stubtest_stubs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stubtest_stubs.yml b/.github/workflows/stubtest_stubs.yml index e5348fdb3c52..54d780a2cd81 100644 --- a/.github/workflows/stubtest_stubs.yml +++ b/.github/workflows/stubtest_stubs.yml @@ -43,12 +43,12 @@ jobs: # git ls-files | egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done) ) - if test -n "$STUBS"; then + if [ -n "$STUBS" ]; then echo "Testing $STUBS..." PACKAGES=$(python tests/get_packages.py $STUBS) if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then - if test -n "$PACKAGES"; then + if [ -n "$PACKAGES" ]; then echo "Installing apt packages: $PACKAGES" sudo apt update && sudo apt install -y $PACKAGES fi From 8149e3c9c73e50e14cc197e8c4c9521a8da05ffb Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 18 Oct 2022 14:55:27 +0300 Subject: [PATCH 03/24] Fix CI --- tests/check_consistent.py | 2 +- tests/stubtest_third_party.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/check_consistent.py b/tests/check_consistent.py index a22d908d61f1..95aa5a920c91 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -18,7 +18,7 @@ from utils import VERSIONS_RE, get_all_testcase_directories, get_gitignore_spec, spec_matches_path, strip_comments metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"} -tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub"}} +tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub", "platform"}} extension_descriptions = {".pyi": "stub", ".py": ".py"} diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 5d3bf82f13d6..963a9b9ee603 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -34,7 +34,7 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: print(colored("skipping", "yellow")) return True - platform = metadata.get("tool", {}).get("plaform", None) + platform = stubtest_meta.get("platform", None) if platform is not None and sys.platform not in platform: print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platform}", "yellow")) return True From 7d364f7b28f44f1858189fdb7fd8dc4a9889822b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 18 Oct 2022 15:08:30 +0300 Subject: [PATCH 04/24] Fix CI --- .github/workflows/stubtest_stubs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/stubtest_stubs.yml b/.github/workflows/stubtest_stubs.yml index 54d780a2cd81..30e02ef25603 100644 --- a/.github/workflows/stubtest_stubs.yml +++ b/.github/workflows/stubtest_stubs.yml @@ -36,6 +36,7 @@ jobs: - name: Install dependencies run: pip install -r requirements-tests.txt - name: Run stubtest + shell: bash run: | STUBS=$( git diff --name-only origin/${{ github.base_ref }} HEAD | @@ -43,6 +44,7 @@ jobs: # git ls-files | egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done) ) + if [ -n "$STUBS" ]; then echo "Testing $STUBS..." PACKAGES=$(python tests/get_packages.py $STUBS) From 1a9af3a2f36f68d3dfc3a692edbba8e8f11ecb83 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 13:35:26 +0300 Subject: [PATCH 05/24] Address review --- CONTRIBUTING.md | 4 ++-- stubs/D3DShot/METADATA.toml | 4 +--- stubs/JACK-Client/METADATA.toml | 2 +- stubs/pyaudio/METADATA.toml | 2 +- stubs/pycurl/METADATA.toml | 2 +- stubs/pywin32/METADATA.toml | 5 ++--- tests/stubtest_third_party.py | 7 ++++--- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 88b0c9499dad..71bd2a659e1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,9 +192,9 @@ This has the following keys: * `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages that need to be installed for stubtest to run successfully. These are usually packages needed to pip install the implementation distribution. -* `platform` (default: `None`): A list of supported OSes. +* `platforms` (default: `["linux"]`): A list of supported OSes. Can contain `win32`, `linux`, and `darwin` values. - If not specified, all platforms are considered supported. + If not specified, only `linux` is considered supported. The format of all `METADATA.toml` files can be checked by running `python3 ./tests/check_consistent.py`. diff --git a/stubs/D3DShot/METADATA.toml b/stubs/D3DShot/METADATA.toml index d6bdd1ba0ba9..7d2830ecb08c 100644 --- a/stubs/D3DShot/METADATA.toml +++ b/stubs/D3DShot/METADATA.toml @@ -2,6 +2,4 @@ version = "0.1.*" requires = ["types-Pillow"] [tool.stubtest] -# The library only works on Windows; we currently only run stubtest on Ubuntu for third-party stubs in CI. -# See #8660 -skip = true +platforms = ["win32"] diff --git a/stubs/JACK-Client/METADATA.toml b/stubs/JACK-Client/METADATA.toml index 45edee0c70e6..6052c937d493 100644 --- a/stubs/JACK-Client/METADATA.toml +++ b/stubs/JACK-Client/METADATA.toml @@ -1,5 +1,5 @@ version = "0.5.*" [tool.stubtest] -platform = ["linux"] +platforms = ["linux"] apt_dependencies = ["libjack-dev"] diff --git a/stubs/pyaudio/METADATA.toml b/stubs/pyaudio/METADATA.toml index c2c82cfa292f..f1492c2a5753 100644 --- a/stubs/pyaudio/METADATA.toml +++ b/stubs/pyaudio/METADATA.toml @@ -1,5 +1,5 @@ version = "0.2.*" [tool.stubtest] -platform = ["linux"] +platforms = ["linux"] apt_dependencies = ["portaudio19-dev"] diff --git a/stubs/pycurl/METADATA.toml b/stubs/pycurl/METADATA.toml index 8153427fc7ef..06b23b2b8a2f 100644 --- a/stubs/pycurl/METADATA.toml +++ b/stubs/pycurl/METADATA.toml @@ -1,5 +1,5 @@ version = "7.45.*" [tool.stubtest] -platform = ["linux"] +platforms = ["linux"] apt_dependencies = ["libcurl4-openssl-dev"] diff --git a/stubs/pywin32/METADATA.toml b/stubs/pywin32/METADATA.toml index 6bbaddd0e5a3..a1782e4b2dad 100644 --- a/stubs/pywin32/METADATA.toml +++ b/stubs/pywin32/METADATA.toml @@ -1,5 +1,4 @@ version = "304.*" + [tool.stubtest] -# The library only works on Windows; we currently only run stubtest on Ubuntu for third-party stubs in CI. -# See #8660 -skip = true +platforms = ["win32"] diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 963a9b9ee603..b84b09601554 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -34,9 +34,10 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: print(colored("skipping", "yellow")) return True - platform = stubtest_meta.get("platform", None) - if platform is not None and sys.platform not in platform: - print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platform}", "yellow")) + # TODO: enable for `win32` and `darwin` by default? + platforms_to_test = stubtest_meta.get("platforms", ["linux"]) + if sys.platform not in platforms_to_test: + print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow")) return True with tempfile.TemporaryDirectory() as tmp: From f00714a0f49cbb50151dac5e92c5d15e01ec1065 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 13:41:10 +0300 Subject: [PATCH 06/24] Run daily on differeny platforms --- .github/workflows/daily.yml | 3 ++- .github/workflows/stubtest_stubs.yml | 2 +- tests/check_consistent.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 29122711b275..b17590246a1f 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -39,9 +39,10 @@ jobs: stubtest-third-party: name: Check third party stubs with stubtest if: ${{ github.repository == 'python/typeshed' || github.event_name == 'workflow_dispatch' }} - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} strategy: matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] shard-index: [0, 1, 2, 3] fail-fast: false steps: diff --git a/.github/workflows/stubtest_stubs.yml b/.github/workflows/stubtest_stubs.yml index 30e02ef25603..da59d187509d 100644 --- a/.github/workflows/stubtest_stubs.yml +++ b/.github/workflows/stubtest_stubs.yml @@ -1,4 +1,4 @@ -name: Test +name: Run stubtest on stubs on: pull_request: diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 95aa5a920c91..b0a55d265a2f 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -18,7 +18,7 @@ from utils import VERSIONS_RE, get_all_testcase_directories, get_gitignore_spec, spec_matches_path, strip_comments metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"} -tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub", "platform"}} +tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub", "platforms"}} extension_descriptions = {".pyi": "stub", ".py": ".py"} From 3f31bedaa60dfe79e2400288a118d867d82f5d8e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 13:47:30 +0300 Subject: [PATCH 07/24] Fix daily run --- .github/workflows/daily.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index b17590246a1f..720153523baa 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -52,12 +52,17 @@ jobs: python-version: "3.9" - name: Install dependencies run: pip install -r requirements-tests.txt - - name: Install apt packages - run: | - sudo apt update - sudo apt install -y $(python tests/get_packages.py) - name: Run stubtest - run: xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} + shell: bash + run: | + if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then + sudo apt update + sudo apt install -y $(python tests/get_packages.py) + + xvfb-run python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} + else + python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} + fi stub-uploader: name: Run the stub_uploader tests From c8650b373fc2e0a47ab06bd631f771015298fa0b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 20:29:47 +0300 Subject: [PATCH 08/24] Rename `stubtest` files --- .github/workflows/stubtest_stdlib.yml | 2 +- .../workflows/{stubtest_stubs.yml => stubtest_third_party.yml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{stubtest_stubs.yml => stubtest_third_party.yml} (98%) diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 3fed32946b5a..2db4159410e1 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -1,4 +1,4 @@ -name: Run stubtest +name: Stdlib stubtest on: workflow_dispatch: diff --git a/.github/workflows/stubtest_stubs.yml b/.github/workflows/stubtest_third_party.yml similarity index 98% rename from .github/workflows/stubtest_stubs.yml rename to .github/workflows/stubtest_third_party.yml index da59d187509d..e745de5aa1ec 100644 --- a/.github/workflows/stubtest_stubs.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -1,4 +1,4 @@ -name: Run stubtest on stubs +name: Third-party stubtest on: pull_request: From fdf13bb09323c0e18bec9390f3a020c1628722ba Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 20:48:26 +0300 Subject: [PATCH 09/24] Add platform-specific allowlists for stubs --- .../D3DShot/@tests/requirements-stubtest.txt | 1 + stubs/pywin32/@tests/stubtest_allowlist.txt | 75 ------------------- tests/stubtest_third_party.py | 3 + 3 files changed, 4 insertions(+), 75 deletions(-) create mode 100644 stubs/D3DShot/@tests/requirements-stubtest.txt delete mode 100644 stubs/pywin32/@tests/stubtest_allowlist.txt diff --git a/stubs/D3DShot/@tests/requirements-stubtest.txt b/stubs/D3DShot/@tests/requirements-stubtest.txt new file mode 100644 index 000000000000..3868fb16b890 --- /dev/null +++ b/stubs/D3DShot/@tests/requirements-stubtest.txt @@ -0,0 +1 @@ +pillow diff --git a/stubs/pywin32/@tests/stubtest_allowlist.txt b/stubs/pywin32/@tests/stubtest_allowlist.txt deleted file mode 100644 index 5579b37d9ec1..000000000000 --- a/stubs/pywin32/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,75 +0,0 @@ -# Not available at runtime. Contains type definitions that are otherwise not exposed -_win32typing -win32com(ext)?.mapi._exchdapi -win32._wincerapi -# PyWin tool / debugger -pythonwin.pywin.* -win32com.client.combrowse -win32com.client.tlbrowse -# Utilities to generate python bindings -win32com.client.build -win32com.client.CLSIDToClass -win32com.client.connect -# Necessary for mypy to not throw AssertionError -win32com.client.dynamic.* -win32com.client.gencache -win32com.client.genpy -win32com.client.makepy -win32com.client.selecttlb -win32com.client.util -win32com.makegw.* -# COM object servers scripts -win32com.server.factory -win32com.server.localserver -win32com.server.register -win32com.servers.* -# Active X Scripts -win32com(ext)?.axscript.client.framework -win32com(ext)?.axscript.client.pyscript_rexec -# Necessary for mypy to not fail -win32com(ext)?.axscript.client.pyscript.* -win32com(ext)?.axscript.client.scriptdispatch -# Other scripts -isapi.install -win32.scripts.* -win32.lib.netbios -win32.lib.sspi -win32.lib.win32pdhutil -win32.lib.win32rcparser -win32.lib.win32serviceutil -win32.lib.win32traceutil -win32.lib.verstamp -# Demos, tests and debugging -win32.lib.pywin32_testutil -win32.lib.rasutil -win32.lib.win32gui_struct -win32com.demos.* -win32com.servers.test_pycomtest -win32com.test.* -win32com(ext)?.axdebug.codecontainer -win32com(ext)?.axdebug.dump -win32com(ext)?.axdebug.debugger -win32com(ext)?.axscript.client.pydumper -win32com(ext)?.directsound.test.* -# Deprecated and obsolete -pythoncom.MakeIID -pythoncom.MakeTime -win32.lib.dbi -win32.lib.win32pdhquery.Query.addperfcounter -win32.win32gui.PyMakeBuffer -# Also a script -win32.lib.regcheck -# failed to import, ImportError: DLL load failed while importing axdebug: The specified module could not be found. -# https://github.com/python/mypy/issues/13822 -win32com.axdebug.axdebug -win32com(ext)?.axdebug.adb -win32com(ext)?.axdebug.codecontainer -# failed to import, SystemError: CoInternetCreateSecurityManager() method: bad call flags -win32com(ext)?.internet.internet -# failed to import, ModuleNotFoundError: No module named '...' -win32com(ext)?.axdebug.contexts -win32com(ext)?.axdebug.debugger -win32com(ext)?.axdebug.documents -win32com(ext)?.axdebug.expressions -win32com(ext)?.axdebug.stackframe -win32com(ext)?.axscript.client.debug diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index b84b09601554..62e66f9d0897 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -108,6 +108,9 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: allowlist_path = dist / "@tests/stubtest_allowlist.txt" if allowlist_path.exists(): stubtest_cmd.extend(["--allowlist", str(allowlist_path)]) + platform_allowlist = dist / f"@tests/stubtest_allowlist_{sys.platform}.txt" + if allowlist_path.exists(): + stubtest_cmd.extend(["--allowlist", str(platform_allowlist)]) try: subprocess.run(stubtest_cmd, env=stubtest_env, check=True, capture_output=True) From c84fe272b6cbd1aa09cdf59b5fe3046478ecb5b6 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 21:05:04 +0300 Subject: [PATCH 10/24] Fix CI --- tests/stubtest_third_party.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 62e66f9d0897..ea1b45d3e80c 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -38,7 +38,7 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: platforms_to_test = stubtest_meta.get("platforms", ["linux"]) if sys.platform not in platforms_to_test: print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow")) - return True + # return True with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) @@ -63,8 +63,9 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: # If @tests/requirements-stubtest.txt exists, run "pip install" on it. req_path = dist / "@tests" / "requirements-stubtest.txt" if req_path.exists(): + pip_cmd = [pip_exe, "install", "-r", str(req_path)] + print("Running install of extra requirements:", " ".join(pip_cmd)) try: - pip_cmd = [pip_exe, "install", "-r", str(req_path)] subprocess.run(pip_cmd, check=True, capture_output=True) except subprocess.CalledProcessError as e: print_command_failure("Failed to install requirements", e) From 40a4c5087c739c5601e60577c3caaa79e898e827 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 21:16:07 +0300 Subject: [PATCH 11/24] Fix CI --- tests/stubtest_third_party.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index ea1b45d3e80c..91c8a5ef52bd 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -64,7 +64,6 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: req_path = dist / "@tests" / "requirements-stubtest.txt" if req_path.exists(): pip_cmd = [pip_exe, "install", "-r", str(req_path)] - print("Running install of extra requirements:", " ".join(pip_cmd)) try: subprocess.run(pip_cmd, check=True, capture_output=True) except subprocess.CalledProcessError as e: @@ -110,7 +109,7 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: if allowlist_path.exists(): stubtest_cmd.extend(["--allowlist", str(allowlist_path)]) platform_allowlist = dist / f"@tests/stubtest_allowlist_{sys.platform}.txt" - if allowlist_path.exists(): + if platform_allowlist.exists(): stubtest_cmd.extend(["--allowlist", str(platform_allowlist)]) try: From 025568b39d9454b1620a65fe8e61387916965fe4 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 21:33:30 +0300 Subject: [PATCH 12/24] Try `Pillow~=7.1.2` --- stubs/D3DShot/@tests/requirements-stubtest.txt | 2 +- tests/stubtest_third_party.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/D3DShot/@tests/requirements-stubtest.txt b/stubs/D3DShot/@tests/requirements-stubtest.txt index 3868fb16b890..e267784c3328 100644 --- a/stubs/D3DShot/@tests/requirements-stubtest.txt +++ b/stubs/D3DShot/@tests/requirements-stubtest.txt @@ -1 +1 @@ -pillow +Pillow~=7.1.2 diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 91c8a5ef52bd..bba6dba2fd7b 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -38,7 +38,7 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: platforms_to_test = stubtest_meta.get("platforms", ["linux"]) if sys.platform not in platforms_to_test: print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow")) - # return True + return True with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) From c8b6472eb2faee9b60217eac8ad5f1252e64102c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Oct 2022 22:50:27 +0300 Subject: [PATCH 13/24] Skip `D3DShot` --- .../D3DShot/@tests/requirements-stubtest.txt | 1 - stubs/D3DShot/METADATA.toml | 2 ++ .../@tests/stubtest_allowlist_win32.txt | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) delete mode 100644 stubs/D3DShot/@tests/requirements-stubtest.txt create mode 100644 stubs/pywin32/@tests/stubtest_allowlist_win32.txt diff --git a/stubs/D3DShot/@tests/requirements-stubtest.txt b/stubs/D3DShot/@tests/requirements-stubtest.txt deleted file mode 100644 index e267784c3328..000000000000 --- a/stubs/D3DShot/@tests/requirements-stubtest.txt +++ /dev/null @@ -1 +0,0 @@ -Pillow~=7.1.2 diff --git a/stubs/D3DShot/METADATA.toml b/stubs/D3DShot/METADATA.toml index 7d2830ecb08c..f60a451fc7ac 100644 --- a/stubs/D3DShot/METADATA.toml +++ b/stubs/D3DShot/METADATA.toml @@ -2,4 +2,6 @@ version = "0.1.*" requires = ["types-Pillow"] [tool.stubtest] +# TODO: re-enable +skip = true platforms = ["win32"] diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt new file mode 100644 index 000000000000..a23964f4658c --- /dev/null +++ b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt @@ -0,0 +1,21 @@ +_win32typing +win32._wincerapi +win32com.axdebug.adb +win32com.axdebug.axdebug +win32com.axdebug.codecontainer +win32com.axdebug.contexts +win32com.axdebug.debugger +win32com.axdebug.documents +win32com.axdebug.expressions +win32com.axdebug.stackframe +win32com.internet.internet +win32com.mapi._exchdapi +win32comext.axdebug.adb +win32comext.axdebug.codecontainer +win32comext.axdebug.contexts +win32comext.axdebug.debugger +win32comext.axdebug.documents +win32comext.axdebug.expressions +win32comext.axdebug.stackframe +win32comext.internet.internet +win32comext.mapi._exchdapi From 21eb994dcfef064f791ec6aec79662c61e2c8f9c Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 20 Oct 2022 01:07:28 +0300 Subject: [PATCH 14/24] Revert `win32` change --- stubs/pywin32/@tests/stubtest_allowlist.txt | 75 +++++++++++++++++++ .../@tests/stubtest_allowlist_win32.txt | 21 ------ 2 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 stubs/pywin32/@tests/stubtest_allowlist.txt delete mode 100644 stubs/pywin32/@tests/stubtest_allowlist_win32.txt diff --git a/stubs/pywin32/@tests/stubtest_allowlist.txt b/stubs/pywin32/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..5579b37d9ec1 --- /dev/null +++ b/stubs/pywin32/@tests/stubtest_allowlist.txt @@ -0,0 +1,75 @@ +# Not available at runtime. Contains type definitions that are otherwise not exposed +_win32typing +win32com(ext)?.mapi._exchdapi +win32._wincerapi +# PyWin tool / debugger +pythonwin.pywin.* +win32com.client.combrowse +win32com.client.tlbrowse +# Utilities to generate python bindings +win32com.client.build +win32com.client.CLSIDToClass +win32com.client.connect +# Necessary for mypy to not throw AssertionError +win32com.client.dynamic.* +win32com.client.gencache +win32com.client.genpy +win32com.client.makepy +win32com.client.selecttlb +win32com.client.util +win32com.makegw.* +# COM object servers scripts +win32com.server.factory +win32com.server.localserver +win32com.server.register +win32com.servers.* +# Active X Scripts +win32com(ext)?.axscript.client.framework +win32com(ext)?.axscript.client.pyscript_rexec +# Necessary for mypy to not fail +win32com(ext)?.axscript.client.pyscript.* +win32com(ext)?.axscript.client.scriptdispatch +# Other scripts +isapi.install +win32.scripts.* +win32.lib.netbios +win32.lib.sspi +win32.lib.win32pdhutil +win32.lib.win32rcparser +win32.lib.win32serviceutil +win32.lib.win32traceutil +win32.lib.verstamp +# Demos, tests and debugging +win32.lib.pywin32_testutil +win32.lib.rasutil +win32.lib.win32gui_struct +win32com.demos.* +win32com.servers.test_pycomtest +win32com.test.* +win32com(ext)?.axdebug.codecontainer +win32com(ext)?.axdebug.dump +win32com(ext)?.axdebug.debugger +win32com(ext)?.axscript.client.pydumper +win32com(ext)?.directsound.test.* +# Deprecated and obsolete +pythoncom.MakeIID +pythoncom.MakeTime +win32.lib.dbi +win32.lib.win32pdhquery.Query.addperfcounter +win32.win32gui.PyMakeBuffer +# Also a script +win32.lib.regcheck +# failed to import, ImportError: DLL load failed while importing axdebug: The specified module could not be found. +# https://github.com/python/mypy/issues/13822 +win32com.axdebug.axdebug +win32com(ext)?.axdebug.adb +win32com(ext)?.axdebug.codecontainer +# failed to import, SystemError: CoInternetCreateSecurityManager() method: bad call flags +win32com(ext)?.internet.internet +# failed to import, ModuleNotFoundError: No module named '...' +win32com(ext)?.axdebug.contexts +win32com(ext)?.axdebug.debugger +win32com(ext)?.axdebug.documents +win32com(ext)?.axdebug.expressions +win32com(ext)?.axdebug.stackframe +win32com(ext)?.axscript.client.debug diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt deleted file mode 100644 index a23964f4658c..000000000000 --- a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt +++ /dev/null @@ -1,21 +0,0 @@ -_win32typing -win32._wincerapi -win32com.axdebug.adb -win32com.axdebug.axdebug -win32com.axdebug.codecontainer -win32com.axdebug.contexts -win32com.axdebug.debugger -win32com.axdebug.documents -win32com.axdebug.expressions -win32com.axdebug.stackframe -win32com.internet.internet -win32com.mapi._exchdapi -win32comext.axdebug.adb -win32comext.axdebug.codecontainer -win32comext.axdebug.contexts -win32comext.axdebug.debugger -win32comext.axdebug.documents -win32comext.axdebug.expressions -win32comext.axdebug.stackframe -win32comext.internet.internet -win32comext.mapi._exchdapi From ac06a7c57bd1c0dd749e50cb118fd450fec104c3 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 24 Oct 2022 17:42:13 +0300 Subject: [PATCH 15/24] Fix CI --- stubs/pywin32/@tests/stubtest_allowlist.txt | 75 ------------------- .../@tests/stubtest_allowlist_win32.txt | 21 ++++++ 2 files changed, 21 insertions(+), 75 deletions(-) delete mode 100644 stubs/pywin32/@tests/stubtest_allowlist.txt create mode 100644 stubs/pywin32/@tests/stubtest_allowlist_win32.txt diff --git a/stubs/pywin32/@tests/stubtest_allowlist.txt b/stubs/pywin32/@tests/stubtest_allowlist.txt deleted file mode 100644 index 5579b37d9ec1..000000000000 --- a/stubs/pywin32/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,75 +0,0 @@ -# Not available at runtime. Contains type definitions that are otherwise not exposed -_win32typing -win32com(ext)?.mapi._exchdapi -win32._wincerapi -# PyWin tool / debugger -pythonwin.pywin.* -win32com.client.combrowse -win32com.client.tlbrowse -# Utilities to generate python bindings -win32com.client.build -win32com.client.CLSIDToClass -win32com.client.connect -# Necessary for mypy to not throw AssertionError -win32com.client.dynamic.* -win32com.client.gencache -win32com.client.genpy -win32com.client.makepy -win32com.client.selecttlb -win32com.client.util -win32com.makegw.* -# COM object servers scripts -win32com.server.factory -win32com.server.localserver -win32com.server.register -win32com.servers.* -# Active X Scripts -win32com(ext)?.axscript.client.framework -win32com(ext)?.axscript.client.pyscript_rexec -# Necessary for mypy to not fail -win32com(ext)?.axscript.client.pyscript.* -win32com(ext)?.axscript.client.scriptdispatch -# Other scripts -isapi.install -win32.scripts.* -win32.lib.netbios -win32.lib.sspi -win32.lib.win32pdhutil -win32.lib.win32rcparser -win32.lib.win32serviceutil -win32.lib.win32traceutil -win32.lib.verstamp -# Demos, tests and debugging -win32.lib.pywin32_testutil -win32.lib.rasutil -win32.lib.win32gui_struct -win32com.demos.* -win32com.servers.test_pycomtest -win32com.test.* -win32com(ext)?.axdebug.codecontainer -win32com(ext)?.axdebug.dump -win32com(ext)?.axdebug.debugger -win32com(ext)?.axscript.client.pydumper -win32com(ext)?.directsound.test.* -# Deprecated and obsolete -pythoncom.MakeIID -pythoncom.MakeTime -win32.lib.dbi -win32.lib.win32pdhquery.Query.addperfcounter -win32.win32gui.PyMakeBuffer -# Also a script -win32.lib.regcheck -# failed to import, ImportError: DLL load failed while importing axdebug: The specified module could not be found. -# https://github.com/python/mypy/issues/13822 -win32com.axdebug.axdebug -win32com(ext)?.axdebug.adb -win32com(ext)?.axdebug.codecontainer -# failed to import, SystemError: CoInternetCreateSecurityManager() method: bad call flags -win32com(ext)?.internet.internet -# failed to import, ModuleNotFoundError: No module named '...' -win32com(ext)?.axdebug.contexts -win32com(ext)?.axdebug.debugger -win32com(ext)?.axdebug.documents -win32com(ext)?.axdebug.expressions -win32com(ext)?.axdebug.stackframe -win32com(ext)?.axscript.client.debug diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt new file mode 100644 index 000000000000..a23964f4658c --- /dev/null +++ b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt @@ -0,0 +1,21 @@ +_win32typing +win32._wincerapi +win32com.axdebug.adb +win32com.axdebug.axdebug +win32com.axdebug.codecontainer +win32com.axdebug.contexts +win32com.axdebug.debugger +win32com.axdebug.documents +win32com.axdebug.expressions +win32com.axdebug.stackframe +win32com.internet.internet +win32com.mapi._exchdapi +win32comext.axdebug.adb +win32comext.axdebug.codecontainer +win32comext.axdebug.contexts +win32comext.axdebug.debugger +win32comext.axdebug.documents +win32comext.axdebug.expressions +win32comext.axdebug.stackframe +win32comext.internet.internet +win32comext.mapi._exchdapi From 0be8c9ba13e94527b21f1e5394f6eb440156e142 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 25 Oct 2022 12:08:57 +0300 Subject: [PATCH 16/24] Address review --- .github/workflows/stubtest_third_party.yml | 1 - CONTRIBUTING.md | 2 ++ tests/stubtest_third_party.py | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index e745de5aa1ec..437ea0d7c74a 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -63,7 +63,6 @@ jobs: fi if [ "${{ matrix.os }}" = "windows-latest" ]; then - # TODO: support windows python tests/stubtest_third_party.py $STUBS fi else diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71bd2a659e1f..a7ccf5ad102e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -195,6 +195,8 @@ This has the following keys: * `platforms` (default: `["linux"]`): A list of supported OSes. Can contain `win32`, `linux`, and `darwin` values. If not specified, only `linux` is considered supported. + Only add extra OSes to the test + if there is platform-specific code in a package. The format of all `METADATA.toml` files can be checked by running `python3 ./tests/check_consistent.py`. diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index bba6dba2fd7b..49892435b795 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -34,7 +34,6 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool: print(colored("skipping", "yellow")) return True - # TODO: enable for `win32` and `darwin` by default? platforms_to_test = stubtest_meta.get("platforms", ["linux"]) if sys.platform not in platforms_to_test: print(colored(f"skipping, unsupported platform: {sys.platform}, supported: {platforms_to_test}", "yellow")) From 3bb8296ec140e3324f43d0d14dfb1dbc0083e656 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 26 Oct 2022 17:38:20 +0300 Subject: [PATCH 17/24] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7ccf5ad102e..550ada9eeb7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -196,7 +196,7 @@ This has the following keys: Can contain `win32`, `linux`, and `darwin` values. If not specified, only `linux` is considered supported. Only add extra OSes to the test - if there is platform-specific code in a package. + if there are platform-specific branches in a stubs package. The format of all `METADATA.toml` files can be checked by running `python3 ./tests/check_consistent.py`. From c4f86da031675df5b7aa5d619d5249f28ba1a764 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 9 Nov 2022 17:36:36 +0300 Subject: [PATCH 18/24] Fix allowlist of win32 --- .../@tests/stubtest_allowlist_win32.txt | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt index 20fe05108d31..651ae0b500ac 100644 --- a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt @@ -32,16 +32,7 @@ win32com(ext)?.axscript.client.scriptdispatch # Other scripts isapi.install win32.scripts.* -win32.lib.netbios -win32.lib.sspi -win32.lib.win32pdhutil -win32.lib.win32rcparser -win32.lib.win32serviceutil -win32.lib.win32traceutil -win32.lib.verstamp # Demos, tests and debugging -win32.lib.pywin32_testutil -win32.lib.rasutil win32com.demos.* win32com.servers.test_pycomtest win32com.test.* @@ -53,12 +44,9 @@ win32com(ext)?.directsound.test.* # Deprecated and obsolete pythoncom.MakeIID pythoncom.MakeTime -win32.lib.dbi win32.lib.win32pdhquery.Query.addperfcounter # Deprecated and makes a buffer of random junk. Use something like `b"\x00" * bufferSize` instead win32.win32gui.PyMakeBuffer -# Also a script -win32.lib.regcheck # failed to import, ImportError: DLL load failed while importing axdebug: The specified module could not be found. # https://github.com/python/mypy/issues/13822 win32com.axdebug.axdebug @@ -73,3 +61,21 @@ win32com(ext)?.axdebug.documents win32com(ext)?.axdebug.expressions win32com(ext)?.axdebug.stackframe win32com(ext)?.axscript.client.debug + +# Errors from running stubtest on Windows machine: +pythoncom.internal_error +pythoncom.new +pywintypes.TimeType +pywintypes.WAVE_FORMAT_PCM +pywintypes.__import_pywin32_system_module__ +win32.lib.pywintypes.TimeType +win32.lib.pywintypes.WAVE_FORMAT_PCM +win32.lib.pywintypes.__import_pywin32_system_module__ +win32.winxpgui.GetConsoleWindow +win32.winxpgui.GetWindowRgnBox +win32.winxpgui.PyMakeBuffer +win32gui.PyMakeBuffer +win32pdhquery.Query.addperfcounter +winxpgui.GetConsoleWindow +winxpgui.GetWindowRgnBox +winxpgui.PyMakeBuffer From a6b1cab8ab62d735e7ce7a1096573395a3cd8d6d Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 9 Nov 2022 18:20:56 +0300 Subject: [PATCH 19/24] Update stubtest_allowlist_win32.txt --- stubs/pywin32/@tests/stubtest_allowlist_win32.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt index 651ae0b500ac..01c79a56e2c9 100644 --- a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt @@ -31,7 +31,6 @@ win32com(ext)?.axscript.client.pyscript.* win32com(ext)?.axscript.client.scriptdispatch # Other scripts isapi.install -win32.scripts.* # Demos, tests and debugging win32com.demos.* win32com.servers.test_pycomtest From bf2f10e998c54caeb1049455829d47851595311e Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 9 Nov 2022 18:25:40 +0300 Subject: [PATCH 20/24] Update tests/get_packages.py Co-authored-by: Alex Waygood --- tests/get_packages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/get_packages.py b/tests/get_packages.py index fad2b6365324..dcd33c606334 100755 --- a/tests/get_packages.py +++ b/tests/get_packages.py @@ -11,7 +11,7 @@ metadata_mapping = { "linux": "apt_dependencies", - # TODO: support others: + # We could add others here if we run into stubs that need it: # "darwin": "brew_dependencies", # "win32": "choco_dependencies", } From 7df5a1f81b2098dd667bf8f2db015e72361460fa Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 11 Nov 2022 00:11:14 +0000 Subject: [PATCH 21/24] Delete unused allowlist entries --- stubs/pywin32/@tests/stubtest_allowlist_win32.txt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt index bbe756888f19..071d21fa207e 100644 --- a/stubs/pywin32/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pywin32/@tests/stubtest_allowlist_win32.txt @@ -65,15 +65,3 @@ win32com(ext)?.axdebug.documents win32com(ext)?.axdebug.expressions # failed to import, ModuleNotFoundError: No module named 'expressions' win32com(ext)?.axdebug.stackframe - -# Errors from running stubtest on Windows machine: -pythoncom.internal_error -pythoncom.new -pywintypes.TimeType -pywintypes.WAVE_FORMAT_PCM -win32.lib.pywintypes.TimeType -win32.lib.pywintypes.WAVE_FORMAT_PCM -win32.winxpgui.GetConsoleWindow -win32.winxpgui.GetWindowRgnBox -winxpgui.GetConsoleWindow -winxpgui.GetWindowRgnBox From 949bf46fbab1ec2c518e9ff50b878f2c157d3505 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 11 Nov 2022 13:11:33 +0300 Subject: [PATCH 22/24] Update CONTRIBUTING.md Co-authored-by: Jelle Zijlstra --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 394219a47e6a..d06869484456 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,9 +192,9 @@ This has the following keys: * `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages that need to be installed for stubtest to run successfully. These are usually packages needed to pip install the implementation distribution. -* `platforms` (default: `["linux"]`): A list of supported OSes. +* `platforms` (default: `["linux"]`): A list of OSes on which to run stubtest. Can contain `win32`, `linux`, and `darwin` values. - If not specified, only `linux` is considered supported. + If not specified, tests are run only on `linux`. Only add extra OSes to the test if there are platform-specific branches in a stubs package. From faac1be5cc4b06b62b4f04c6c2b3875f03e7d2df Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 11 Nov 2022 16:05:24 +0300 Subject: [PATCH 23/24] Apply suggestions from code review Co-authored-by: Alex Waygood --- .github/workflows/stubtest_third_party.yml | 6 +++--- CONTRIBUTING.md | 2 +- stubs/D3DShot/METADATA.toml | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 437ea0d7c74a..29cac9b3f95f 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -40,8 +40,7 @@ jobs: run: | STUBS=$( git diff --name-only origin/${{ github.base_ref }} HEAD | - # Uncomment the following to (very slowly) run on all third party stubs: - # git ls-files | + # Use the daily.yml workflow to run stubtest on all third party stubs egrep ^stubs/ | cut -d "/" -f 2 | sort -u | (while read stub; do [ -d stubs/$stub ] && echo $stub || true; done) ) @@ -58,11 +57,12 @@ jobs: fi if [ "${{ matrix.os }}" = "macos-latest" ]; then - # TODO: install brew packages + # Could install brew packages here if we run into stubs that need it python tests/stubtest_third_party.py $STUBS fi if [ "${{ matrix.os }}" = "windows-latest" ]; then + # Could install choco packages here if we run into stubs that need it python tests/stubtest_third_party.py $STUBS fi else diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d06869484456..ceba9b87ab07 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -194,7 +194,7 @@ This has the following keys: usually packages needed to pip install the implementation distribution. * `platforms` (default: `["linux"]`): A list of OSes on which to run stubtest. Can contain `win32`, `linux`, and `darwin` values. - If not specified, tests are run only on `linux`. + If not specified, stubtest is run only on `linux`. Only add extra OSes to the test if there are platform-specific branches in a stubs package. diff --git a/stubs/D3DShot/METADATA.toml b/stubs/D3DShot/METADATA.toml index f60a451fc7ac..dcc04b9575b9 100644 --- a/stubs/D3DShot/METADATA.toml +++ b/stubs/D3DShot/METADATA.toml @@ -2,6 +2,5 @@ version = "0.1.*" requires = ["types-Pillow"] [tool.stubtest] -# TODO: re-enable skip = true platforms = ["win32"] From 94643356e47769748e149f98d56fad73ad3468fc Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 11 Nov 2022 13:22:53 +0000 Subject: [PATCH 24/24] Add TODO comment back --- stubs/D3DShot/METADATA.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/D3DShot/METADATA.toml b/stubs/D3DShot/METADATA.toml index dcc04b9575b9..b66c346f9a8b 100644 --- a/stubs/D3DShot/METADATA.toml +++ b/stubs/D3DShot/METADATA.toml @@ -2,5 +2,7 @@ version = "0.1.*" requires = ["types-Pillow"] [tool.stubtest] +# TODO: figure out how to run stubtest for this package +# (the package pins Pillow in a problematic way) skip = true platforms = ["win32"]