From 3a80dae23e668c97065b46bcdaf5181875654f08 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 19 Mar 2025 09:29:22 +0100 Subject: [PATCH 1/3] ci test --- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 2 +- meta.yaml | 8 +++++++- scripts/example_async.py | 30 ++++++++++++++++++++++++++++++ scripts/example_sync.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 scripts/example_async.py create mode 100644 scripts/example_sync.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80dd92245..0a6d8fcd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,7 +169,7 @@ jobs: - name: Get conda uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.12 + python-version: 3.9 channels: conda-forge miniconda-version: latest - name: Prepare diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54c7ab80e..b682372fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,7 @@ jobs: - name: Get conda uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.12 + python-version: 3.9 channels: conda-forge miniconda-version: latest - name: Prepare diff --git a/meta.yaml b/meta.yaml index 803565ac6..9802d2ee4 100644 --- a/meta.yaml +++ b/meta.yaml @@ -7,7 +7,7 @@ source: build: noarch: python - number: 0 + numsber: 0 script: "{{ PYTHON }} -m pip install . --no-deps -vv" binary_relocation: False missing_dso_whitelist: "*" @@ -32,6 +32,9 @@ requirements: - pyee>=12,<13 test: # [build_platform == target_platform] + files: + - scripts/example_sync.py + - scripts/example_async.py requires: - pip imports: @@ -40,6 +43,9 @@ test: # [build_platform == target_platform] - playwright.async_api commands: - playwright --help + - playwright install + - python scripts/example_sync.py + - python scripts/example_async.py about: home: https://github.com/microsoft/playwright-python diff --git a/scripts/example_async.py b/scripts/example_async.py new file mode 100644 index 000000000..e8f9966c3 --- /dev/null +++ b/scripts/example_async.py @@ -0,0 +1,30 @@ +# 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.s +import asyncio + +from playwright.async_api import async_playwright + + +async def main() -> None: + async with async_playwright() as p: + for browser_type in [p.chromium, p.firefox, p.webkit]: + browser = await browser_type.launch() + page = await browser.new_page() + await page.goto("http://playwright.dev") + await page.screenshot(path=f"example-{browser_type.name}.png") + await browser.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/scripts/example_sync.py b/scripts/example_sync.py new file mode 100644 index 000000000..ede4106a0 --- /dev/null +++ b/scripts/example_sync.py @@ -0,0 +1,29 @@ +# 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. + +from playwright.sync_api import sync_playwright + + +def main() -> None: + with sync_playwright() as p: + for browser_type in [p.chromium, p.firefox, p.webkit]: + browser = browser_type.launch() + page = browser.new_page() + page.goto("http://playwright.dev") + page.screenshot(path=f"example-{browser_type.name}.png") + browser.close() + + +if __name__ == "__main__": + main() From 48baae5cbb518a5c6a45bd22fce01565fb5e5309 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 19 Mar 2025 09:31:46 +0100 Subject: [PATCH 2/3] nit --- meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta.yaml b/meta.yaml index 9802d2ee4..39f51f648 100644 --- a/meta.yaml +++ b/meta.yaml @@ -7,7 +7,7 @@ source: build: noarch: python - numsber: 0 + number: 0 script: "{{ PYTHON }} -m pip install . --no-deps -vv" binary_relocation: False missing_dso_whitelist: "*" From f40a688ec1d92c1e4dbfad1936781ef1eb2694e8 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 19 Mar 2025 09:50:33 +0100 Subject: [PATCH 3/3] Update playwright install command with dependencies --- meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta.yaml b/meta.yaml index 39f51f648..6f43610a9 100644 --- a/meta.yaml +++ b/meta.yaml @@ -43,7 +43,7 @@ test: # [build_platform == target_platform] - playwright.async_api commands: - playwright --help - - playwright install + - playwright install --with-deps - python scripts/example_sync.py - python scripts/example_async.py