From 9f042eca1ce2f29b662b442d61462b1c5a87fdaf Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 16 Oct 2023 18:24:31 +0200 Subject: [PATCH] chore: support Python 3.12 (#2116) --- .github/workflows/ci.yml | 17 ++++++--- .github/workflows/publish_canary_docker.yml | 2 +- .github/workflows/publish_release_docker.yml | 2 +- CONTRIBUTING.md | 2 +- local-requirements.txt | 1 - meta.yaml | 2 +- pyproject.toml | 5 ++- scripts/__init__.py | 0 scripts/generate_async_api.py | 4 +- scripts/generate_sync_api.py | 4 +- setup.py | 17 +++++---- tests/test_generation_scripts.py | 39 -------------------- tests/test_installation.py | 7 ++-- 13 files changed, 37 insertions(+), 65 deletions(-) delete mode 100644 scripts/__init__.py delete mode 100644 tests/test_generation_scripts.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23f645890..a8e7c7cec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: python-version: "3.10" - name: Install dependencies & browsers run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip pip install -r local-requirements.txt pip install -e . python setup.py bdist_wheel @@ -68,6 +68,15 @@ jobs: - os: ubuntu-latest python-version: '3.11' browser: chromium + - os: windows-latest + python-version: '3.12' + browser: chromium + - os: macos-latest + python-version: '3.12' + browser: chromium + - os: ubuntu-latest + python-version: '3.12' + browser: chromium runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -77,7 +86,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies & browsers run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip pip install -r local-requirements.txt pip install -e . python setup.py bdist_wheel @@ -88,8 +97,6 @@ jobs: run: pytest tests/test_reference_count_async.py --browser=${{ matrix.browser }} - name: Test Wheel Installation run: pytest tests/test_installation.py --browser=${{ matrix.browser }} - - name: Test Generation Scripts - run: pytest tests/test_generation_scripts.py --browser=${{ matrix.browser }} - name: Test Sync API if: matrix.os != 'ubuntu-latest' run: pytest tests/sync --browser=${{ matrix.browser }} --timeout 90 @@ -125,7 +132,7 @@ jobs: python-version: "3.10" - name: Install dependencies & browsers run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip pip install -r local-requirements.txt pip install -e . python setup.py bdist_wheel diff --git a/.github/workflows/publish_canary_docker.yml b/.github/workflows/publish_canary_docker.yml index e5a962b49..757dee7b5 100644 --- a/.github/workflows/publish_canary_docker.yml +++ b/.github/workflows/publish_canary_docker.yml @@ -18,7 +18,7 @@ jobs: python-version: "3.10" - name: Install dependencies & browsers run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip pip install -r local-requirements.txt pip install -e . - uses: azure/docker-login@v1 diff --git a/.github/workflows/publish_release_docker.yml b/.github/workflows/publish_release_docker.yml index 9f255ad7a..8bb9c5c7b 100644 --- a/.github/workflows/publish_release_docker.yml +++ b/.github/workflows/publish_release_docker.yml @@ -33,7 +33,7 @@ jobs: platforms: arm64 - name: Install dependencies & browsers run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip pip install -r local-requirements.txt pip install -e . - run: ./utils/docker/publish_docker.sh stable diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 809b8e997..a5ab7d4bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ source ./env/bin/activate Install required dependencies: ```sh -python -m pip install --upgrade pip wheel +python -m pip install --upgrade pip pip install -r local-requirements.txt ``` diff --git a/local-requirements.txt b/local-requirements.txt index f8f6e524f..caffb929c 100644 --- a/local-requirements.txt +++ b/local-requirements.txt @@ -18,7 +18,6 @@ pytest-xdist==3.3.1 requests==2.31.0 service_identity==23.1.0 setuptools==68.2.2 -twine==4.0.2 twisted==23.8.0 types-pyOpenSSL==23.2.0.2 wheel==0.41.2 diff --git a/meta.yaml b/meta.yaml index 6d7246c53..32413e8c0 100644 --- a/meta.yaml +++ b/meta.yaml @@ -24,7 +24,7 @@ requirements: run: - python - greenlet ==3.0.0 - - pyee ==9.0.4 + - pyee ==11.0.1 - typing_extensions # [py<39] test: requires: diff --git a/pyproject.toml b/pyproject.toml index 43cd8c708..094ca8c81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,10 @@ [build-system] -requires = ["setuptools==60.9.3", "setuptools-scm==7.0.5", "wheel==0.38.1", "auditwheel==5.1.2"] +requires = ["setuptools==68.2.2", "setuptools-scm==8.0.4", "wheel==0.41.2", "auditwheel==5.4.0"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +version_file = "playwright/_repo_version.py" + [tool.pytest.ini_options] addopts = "-Wall -rsx -vv -s" markers = [ diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/scripts/generate_async_api.py b/scripts/generate_async_api.py index d3579a91c..ca52ef1a3 100755 --- a/scripts/generate_async_api.py +++ b/scripts/generate_async_api.py @@ -18,8 +18,8 @@ from types import FunctionType from typing import Any -from scripts.documentation_provider import DocumentationProvider -from scripts.generate_api import ( +from documentation_provider import DocumentationProvider +from generate_api import ( api_globals, arguments, generated_types, diff --git a/scripts/generate_sync_api.py b/scripts/generate_sync_api.py index a932fa8a4..01d6cb02b 100755 --- a/scripts/generate_sync_api.py +++ b/scripts/generate_sync_api.py @@ -19,8 +19,8 @@ from types import FunctionType from typing import Any -from scripts.documentation_provider import DocumentationProvider -from scripts.generate_api import ( +from documentation_provider import DocumentationProvider +from generate_api import ( api_globals, arguments, generated_types, diff --git a/setup.py b/setup.py index a6ea02104..1052b1a54 100644 --- a/setup.py +++ b/setup.py @@ -209,11 +209,17 @@ def _download_and_extract_local_driver( project_urls={ "Release notes": "https://github.com/microsoft/playwright-python/releases", }, - packages=["playwright"], + packages=[ + "playwright", + "playwright.async_api", + "playwright.sync_api", + "playwright._impl", + "playwright._impl.__pyinstaller", + ], include_package_data=True, install_requires=[ "greenlet==3.0.0", - "pyee==9.0.4", + "pyee==11.0.1", "typing-extensions;python_version<='3.8'", ], classifiers=[ @@ -225,17 +231,12 @@ def _download_and_extract_local_driver( "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ], python_requires=">=3.8", cmdclass={"bdist_wheel": PlaywrightBDistWheelCommand}, - use_scm_version={ - "version_scheme": "post-release", - "write_to": "playwright/_repo_version.py", - "write_to_template": 'version = "{version}"\n', - }, - setup_requires=["setuptools-scm==7.0.5", "wheel==0.38.1"], entry_points={ "console_scripts": [ "playwright=playwright.__main__:main", diff --git a/tests/test_generation_scripts.py b/tests/test_generation_scripts.py deleted file mode 100644 index 9a4f78293..000000000 --- a/tests/test_generation_scripts.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -from io import StringIO -from unittest.mock import patch - -import pytest - -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 9), reason="requires python3.9 or higher" -) - - -@patch("sys.stderr", new_callable=StringIO) -@patch("sys.stdout", new_callable=StringIO) -def test_generate_sync_api(stdout: StringIO, stderr: StringIO) -> None: - from scripts.generate_sync_api import main as generate_sync_api - - generate_sync_api() - - -@patch("sys.stderr", new_callable=StringIO) -@patch("sys.stdout", new_callable=StringIO) -def test_generate_async_api(stdout: StringIO, stderr: StringIO) -> None: - from scripts.generate_async_api import main as generate_async_api - - generate_async_api() diff --git a/tests/test_installation.py b/tests/test_installation.py index e0f9433ab..e002a477c 100644 --- a/tests/test_installation.py +++ b/tests/test_installation.py @@ -21,16 +21,17 @@ def test_install(tmp_path: Path, browser_name: str) -> None: + env_dir = tmp_path / "env" env = EnvBuilder(with_pip=True) - env.create(env_dir=tmp_path) - context = env.ensure_directories(tmp_path) + env.create(env_dir=env_dir) + context = env.ensure_directories(env_dir) root = Path(__file__).parent.parent.resolve() if sys.platform == "win32": wheelpath = list((root / "dist").glob("playwright*win_amd64*.whl"))[0] elif sys.platform == "linux": wheelpath = list((root / "dist").glob("playwright*manylinux1*.whl"))[0] elif sys.platform == "darwin": - wheelpath = list((root / "dist").glob("playwright*macosx_10_*.whl"))[0] + wheelpath = list((root / "dist").glob("playwright*macosx_*.whl"))[0] subprocess.check_output( [ context.env_exe,