diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index c1575f366..9cac42fc7 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -69,12 +69,23 @@ jobs: - name: Run stubtest shell: bash run: | - if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then - sudo apt update - sudo apt install -y $(python tests/get_packages.py) + PACKAGES=$(python tests/get_packages.py) + + if [ "${{ runner.os }}" = "Linux" ]; then + if [ -n "$PACKAGES" ]; then + sudo apt update && sudo apt install -y $PACKAGES + fi xvfb-run python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }} else + if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then + NONINTERACTIVE=1 brew install $PACKAGES + fi + + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then + choco install -y $PACKAGES + fi + python tests/stubtest_third_party.py --specified-stubs-only --num-shards 4 --shard-index ${{ matrix.shard-index }} fi diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 1d71e7c56..d21e22690 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -58,21 +58,24 @@ jobs: echo "Testing $STUBS..." PACKAGES=$(python tests/get_packages.py $STUBS) - if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then + if [ "${{ runner.os }}" = "Linux" ]; then if [ -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 --specified-stubs-only $STUBS - fi + else + if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then + echo "Installing Homebrew packages: $PACKAGES" + NONINTERACTIVE=1 brew install $PACKAGES + fi - if [ "${{ matrix.os }}" = "macos-latest" ]; then - # Could install brew packages here if we run into stubs that need it - python tests/stubtest_third_party.py --specified-stubs-only $STUBS - fi + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then + echo "Installing Chocolatey packages: $PACKAGES" + choco install -y $PACKAGES + 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 --specified-stubs-only $STUBS fi else diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18dc1b6c0..baf4f10ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -196,14 +196,20 @@ This has the following keys: package. Please avoid setting this to `true`, and add a comment if you have to. * `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. + that need to be installed for stubtest to run successfully. +* `brew_dependencies` (default: `[]`): A list of MacOS Homebrew packages + that need to be installed for stubtest to run successfully +* `choco_dependencies` (default: `[]`): A list of Windows Chocolatey packages + that need to be installed for stubtest to run successfully * `platforms` (default: `["linux"]`): A list of OSes on which to run stubtest. Can contain `win32`, `linux`, and `darwin` values. 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. +`*_dependencies` are usually packages needed to `pip install` the implementation +distribution. + 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 eb0da9158..20062a169 100644 --- a/stubs/JACK-Client/METADATA.toml +++ b/stubs/JACK-Client/METADATA.toml @@ -2,5 +2,9 @@ version = "0.5.*" [tool.stubtest] ignore_missing_stub = false -platforms = ["linux"] +# darwin and win32 are equivalent +platforms = ["linux", "darwin"] apt_dependencies = ["libjack-dev"] +brew_dependencies = ["jack"] +# No need to install on the CI. Leaving here as information for Windows contributors. +# choco_dependencies = ["jack"] diff --git a/stubs/pyaudio/METADATA.toml b/stubs/pyaudio/METADATA.toml index 3188faeca..674d68822 100644 --- a/stubs/pyaudio/METADATA.toml +++ b/stubs/pyaudio/METADATA.toml @@ -2,5 +2,7 @@ version = "0.2.*" [tool.stubtest] ignore_missing_stub = false -platforms = ["linux"] +# linux and win32 are equivalent +platforms = ["linux", "darwin"] apt_dependencies = ["portaudio19-dev"] +brew_dependencies = ["portaudio"] diff --git a/stubs/pycurl/METADATA.toml b/stubs/pycurl/METADATA.toml index 6ab443af3..64189e702 100644 --- a/stubs/pycurl/METADATA.toml +++ b/stubs/pycurl/METADATA.toml @@ -2,5 +2,15 @@ version = "7.45.*" [tool.stubtest] ignore_missing_stub = false +# Install on Windows requires building PycURL from source +# +# Install on MacOS is too complicated for the CI and does not work with stubtest: +# % brew install openssl +# % export LDFLAGS="-L/usr/local/opt/openssl@3/lib" +# % export CPPFLAGS="-I/usr/local/opt/openssl@3/include" +# % pip install --compile --install-option="--with-openssl" pycurl +# TODO: Test on Windows and/or MacOS once wheels are available. platforms = ["linux"] apt_dependencies = ["libcurl4-openssl-dev"] +# No need to install on the CI. Leaving here as information for MacOS contributors. +# brew_dependencies = ["openssl"] diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 2a5e8d93a..2b70c9e2a 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -27,7 +27,17 @@ metadata_keys = { "upload", "tool", } -tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub", "platforms"}} +tool_keys = { + "stubtest": { + "skip", + "apt_dependencies", + "brew_dependencies", + "choco_dependencies", + "extras", + "ignore_missing_stub", + "platforms", + } +} extension_descriptions = {".pyi": "stub", ".py": ".py"} supported_stubtest_platforms = {"win32", "darwin", "linux"} diff --git a/tests/get_packages.py b/tests/get_packages.py index dcd33c606..b21f6b0fd 100755 --- a/tests/get_packages.py +++ b/tests/get_packages.py @@ -9,12 +9,7 @@ distributions = sys.argv[1:] if not distributions: distributions = os.listdir("stubs") -metadata_mapping = { - "linux": "apt_dependencies", - # We could add others here if we run into stubs that need it: - # "darwin": "brew_dependencies", - # "win32": "choco_dependencies", -} +metadata_mapping = {"linux": "apt_dependencies", "darwin": "brew_dependencies", "win32": "choco_dependencies"} if platform in metadata_mapping: for distribution in distributions: