From f5902b70a3dba2e3550f7a8c14cf109e5c95c436 Mon Sep 17 00:00:00 2001 From: Andrew Pikul Date: Tue, 15 Oct 2024 15:05:12 -0400 Subject: [PATCH 1/4] Change name of devtools to choreographer --- README.md | 10 +++++----- {devtools => choreographer}/__init__.py | 0 {devtools => choreographer}/browser.py | 0 {devtools => choreographer}/chrome_wrapper.py | 0 {devtools => choreographer}/pipe.py | 0 {devtools => choreographer}/protocol.py | 0 {devtools => choreographer}/session.py | 0 {devtools => choreographer}/system.py | 0 {devtools => choreographer}/tab.py | 0 {devtools => choreographer}/target.py | 0 pyproject.toml | 6 +++--- tests/conftest.py | 6 +++--- tests/test_process.py | 10 +++++----- 13 files changed, 16 insertions(+), 16 deletions(-) rename {devtools => choreographer}/__init__.py (100%) rename {devtools => choreographer}/browser.py (100%) rename {devtools => choreographer}/chrome_wrapper.py (100%) rename {devtools => choreographer}/pipe.py (100%) rename {devtools => choreographer}/protocol.py (100%) rename {devtools => choreographer}/session.py (100%) rename {devtools => choreographer}/system.py (100%) rename {devtools => choreographer}/tab.py (100%) rename {devtools => choreographer}/target.py (100%) diff --git a/README.md b/README.md index 1b7807e1..5a188aef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Devtools Protocol -`devtools` allows remote control of browsers from Python. +`choreographer` allows remote control of browsers from Python. It is a work in progress: only Chrome-ish browsers are supported at the moment, and the name will change before the first release to PyPI. @@ -49,11 +49,11 @@ Save the following code to `example-01.py` and run with Python. ``` import asyncio -import devtools +import choreographer as choreo async def example(): - browser = await devtools.Browser(headless=False) + browser = await choreo.Browser(headless=False) tab = await browser.create_tab("https://google.com") await asyncio.sleep(3) await tab.send_command("Page.navigate", params={"url": "https://github.com"}) @@ -69,7 +69,7 @@ Step by step, this example: 1. Imports the required libraries. 1. Defines an `async` function (because `await` can only be used inside `async` functions). -1. Asks `devtools` to create a browser. +1. Asks `choreographer` to create a browser. `headless=False` tells it to display the browser on the screen; the default is no display. 1. Wait three seconds for the browser to be created. @@ -113,7 +113,7 @@ Try adding the following to the example shown above: You can use this library without `asyncio`, ``` -my_browser = devtools.Browser() # blocking until open +my_browser = choreo.Browser() # blocking until open ``` However, diff --git a/devtools/__init__.py b/choreographer/__init__.py similarity index 100% rename from devtools/__init__.py rename to choreographer/__init__.py diff --git a/devtools/browser.py b/choreographer/browser.py similarity index 100% rename from devtools/browser.py rename to choreographer/browser.py diff --git a/devtools/chrome_wrapper.py b/choreographer/chrome_wrapper.py similarity index 100% rename from devtools/chrome_wrapper.py rename to choreographer/chrome_wrapper.py diff --git a/devtools/pipe.py b/choreographer/pipe.py similarity index 100% rename from devtools/pipe.py rename to choreographer/pipe.py diff --git a/devtools/protocol.py b/choreographer/protocol.py similarity index 100% rename from devtools/protocol.py rename to choreographer/protocol.py diff --git a/devtools/session.py b/choreographer/session.py similarity index 100% rename from devtools/session.py rename to choreographer/session.py diff --git a/devtools/system.py b/choreographer/system.py similarity index 100% rename from devtools/system.py rename to choreographer/system.py diff --git a/devtools/tab.py b/choreographer/tab.py similarity index 100% rename from devtools/tab.py rename to choreographer/tab.py diff --git a/devtools/target.py b/choreographer/target.py similarity index 100% rename from devtools/target.py rename to choreographer/target.py diff --git a/pyproject.toml b/pyproject.toml index d263bb64..8779757a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,8 @@ build-backend = "setuptools.build_meta" find = {namespaces = false} [project] -name = "devtools" -description = "Devtools protocol" +name = "choreographer" +description = "Devtools Protocol implementation for chrome" requires-python = ">=3.9" dynamic = ["version"] @@ -20,7 +20,7 @@ dev = [ ] [project.scripts] -dtdoctor = "devtools.browser:diagnose" +dtdoctor = "choreographer.browser:diagnose" [tool.ruff.lint] ignore = ["E701"] diff --git a/tests/conftest.py b/tests/conftest.py index 161809bd..eaeb2edb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import asyncio import pytest import pytest_asyncio -import devtools +import choreographer as choreo @pytest.fixture(params=[True, False], ids=["headless", ""]) def headless(request): @@ -28,7 +28,7 @@ async def browser(request): headless = request.config.getoption("--headless") debug = request.config.get_verbosity() > 2 - browser = await devtools.Browser( + browser = await choreo.Browser( headless=headless, debug=debug, debug_browser=debug ) yield browser @@ -36,7 +36,7 @@ async def browser(request): @pytest_asyncio.fixture(scope="function", loop_scope="function") async def browser_verbose(): - browser = await devtools.Browser(debug=True, debug_browser=True) + browser = await choreo.Browser(debug=True, debug_browser=True) yield browser await browser.close() diff --git a/tests/test_process.py b/tests/test_process.py index fd14004e..c2ccde43 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1,6 +1,6 @@ import asyncio -import devtools +import choreographer as choreo import pytest from async_timeout import timeout @@ -8,7 +8,7 @@ @pytest.mark.asyncio(loop_scope="function") async def test_context(capteesys, headless, debug, debug_browser): - async with devtools.Browser( + async with choreo.Browser( headless=headless, debug=debug, debug_browser=debug_browser, @@ -17,7 +17,7 @@ async def test_context(capteesys, headless, debug, debug_browser): assert "result" in response and "targetInfos" in response["result"] assert (len(response["result"]["targetInfos"]) != 0) != headless if not headless: - assert isinstance(browser.get_tab(), devtools.tab.Tab) + assert isinstance(browser.get_tab(), choreo.tab.Tab) assert len(browser.get_tab().sessions) == 1 print("") # this makes sure that capturing is working # stdout should be empty, but not because capsys is broken, because nothing was print @@ -27,7 +27,7 @@ async def test_context(capteesys, headless, debug, debug_browser): @pytest.mark.asyncio(loop_scope="function") async def test_no_context(capteesys, headless, debug, debug_browser): - browser = await devtools.Browser( + browser = await choreo.Browser( headless=headless, debug=debug, debug_browser=debug_browser, @@ -38,7 +38,7 @@ async def test_no_context(capteesys, headless, debug, debug_browser): assert "result" in response and "targetInfos" in response["result"] assert (len(response["result"]["targetInfos"]) != 0) != headless if not headless: - assert isinstance(browser.get_tab(), devtools.tab.Tab) + assert isinstance(browser.get_tab(), choreo.tab.Tab) assert len(browser.get_tab().sessions) == 1 finally: await browser.close() From 7e1b8f25016ec37bc1e6e971700ed3241f4c23b7 Mon Sep 17 00:00:00 2001 From: Andrew Pikul Date: Tue, 15 Oct 2024 15:07:50 -0400 Subject: [PATCH 2/4] Fix up GHA for new name --- .github/workflows/ruff.yml | 2 +- .github/workflows/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 13016a84..5563bc9a 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -10,4 +10,4 @@ jobs: src: './app' - uses: chartboost/ruff-action@v1 with: - src: './devtools' \ No newline at end of file + src: './choreographer' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05af74bf..0743d968 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: - name: Install Dependencies run: sudo apt-get update && sudo apt-get install chromium-browser xvfb #- uses: ./.github/actions/ # it would be nice but it doesn't support timeout-minutes - - name: Install devtools + - name: Install Choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run @@ -34,7 +34,7 @@ jobs: - name: Install Dependencies run: choco install googlechrome -y --ignore-checksums #- uses: ./.github/actions/ - - name: Install devtools + - name: Install Choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run @@ -58,7 +58,7 @@ jobs: - name: Install Dependencies run: brew install google-chrome #- uses: ./.github/actions/ - - name: Install devtools + - name: Install Choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run From 6fa08d1c39120f0554c5982104870ad8e40bdf81 Mon Sep 17 00:00:00 2001 From: Andrew Pikul Date: Tue, 15 Oct 2024 15:52:39 -0400 Subject: [PATCH 3/4] Add authors+versioning to toml --- .gitignore | 1 + pyproject.toml | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index ebd9bc2a..4aba6eff 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ __pycache__ # builds results/* !results/placeholder +dist/ diff --git a/pyproject.toml b/pyproject.toml index 8779757a..b92a2f59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,26 @@ [build-system] -requires = ["setuptools>=65.0.0", "wheel"] +requires = ["setuptools>=65.0.0", "wheel", "setuptools-git-versioning"] build-backend = "setuptools.build_meta" [tool.setuptools.packages] find = {namespaces = false} +[tool.setuptools-git-versioning] +enabled = true + [project] name = "choreographer" -description = "Devtools Protocol implementation for chrome" +description = "Devtools Protocol implementation for chrome." +readme = "README.md" requires-python = ">=3.9" dynamic = ["version"] +authors = [ + {name = "Andrew Pikul", email="ajpikul@gmail.com"}, + {name = "Neyberson Atencio", email="neyberatencio@gmail.com"} + ] +maintainers = [ + {name = "Andrew Pikul", email = "ajpikul@gmail.com"}, +] [project.optional-dependencies] dev = [ @@ -25,9 +36,6 @@ dtdoctor = "choreographer.browser:diagnose" [tool.ruff.lint] ignore = ["E701"] -[tool.setuptools-git-versioning] -enabled = true - [tool.pytest.ini_options] asyncio_default_fixture_loop_scope = "function" From 67634db308369323355ef5c6e3930f9f3e2ab777 Mon Sep 17 00:00:00 2001 From: Andrew Pikul Date: Tue, 15 Oct 2024 15:55:09 -0400 Subject: [PATCH 4/4] Decapitalize package names --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0743d968..232408a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: - name: Install Dependencies run: sudo apt-get update && sudo apt-get install chromium-browser xvfb #- uses: ./.github/actions/ # it would be nice but it doesn't support timeout-minutes - - name: Install Choreographer + - name: Install choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run @@ -34,7 +34,7 @@ jobs: - name: Install Dependencies run: choco install googlechrome -y --ignore-checksums #- uses: ./.github/actions/ - - name: Install Choreographer + - name: Install choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run @@ -58,7 +58,7 @@ jobs: - name: Install Dependencies run: brew install google-chrome #- uses: ./.github/actions/ - - name: Install Choreographer + - name: Install choreographer run: pip install .[dev] - name: DTDoctor run: dtdoctor --no-run