Skip to content

Commit 7ade192

Browse files
authored
Merge pull request #286 from plotly/andrew/roadmap
andrew/roadmap
2 parents 0627d14 + edf284c commit 7ade192

7 files changed

Lines changed: 48 additions & 46 deletions

File tree

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
v1.3.0rc1
2+
- We now look for old download path as well as new download path
13
v1.3.0rc0
24
- Change to process group for better killing of multi-process chrome
35
- Add argument to Session/Target `send_command(..., *, with_perf: bool)` to

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- [ ] What happens to the underlying task when we cancel a future in a
44
`protocol.devtools_async_helpers` timeout situation?
5-
- [ ] Extract local download check to chromium implementation class
5+
- [x] Extract local download check to chromium implementation class
66
- [x] Fix up browser deps error (eliminate in-package analysis)
77
- [x] Switch to process group and kill that to catch all chromium children
88
- [x] Add helpers for running javascript

src/choreographer/browsers/chromium.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
import msvcrt
1717

1818
from choreographer.channels import Pipe
19+
from choreographer.cli._cli_utils import (
20+
get_chrome_download_path,
21+
get_old_chrome_download_path,
22+
)
1923
from choreographer.utils import TmpDirectory, get_browser_path
2024

2125
from ._chrome_constants import chromium_based_browsers
@@ -75,13 +79,23 @@ def find_browser(
7579
*,
7680
skip_local: bool,
7781
skip_typical: bool = False,
82+
verify_local: bool = False,
7883
) -> str | None:
7984
"""Find a chromium based browser."""
85+
if not skip_local:
86+
if ((p := get_chrome_download_path(mkdir=False)) and p.exists()) or (
87+
(p := get_old_chrome_download_path()) and p.exists()
88+
):
89+
return str(p)
90+
elif verify_local:
91+
raise RuntimeError("verify_local set to True, local not found.")
92+
elif verify_local:
93+
raise ValueError("Cannot set both skip_local and verify_local.")
94+
8095
for name, browser_data in chromium_based_browsers.items():
8196
_logger.debug(f"Looking for a {name} browser.")
8297
path = get_browser_path(
8398
executable_names=browser_data.exe_names,
84-
skip_local=skip_local,
8599
ms_prog_id=browser_data.ms_prog_id,
86100
)
87101
if not path and not skip_typical:

src/choreographer/cli/_cli_utils.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logistro
1616

17-
from choreographer.cli.defaults import default_download_path
17+
from choreographer.cli.defaults import default_download_path, old_download_path
1818

1919
_logger = logistro.getLogger(__name__)
2020

@@ -42,36 +42,44 @@ def get_google_supported_platform_string() -> str | None:
4242
return platform_string
4343

4444

45-
def get_chrome_download_path() -> Path | None:
45+
def get_chrome_download_path(
46+
root=default_download_path,
47+
*,
48+
mkdir=True,
49+
) -> Path | None:
4650
_chrome_platform_detected = get_google_supported_platform_string()
4751

4852
if not _chrome_platform_detected:
4953
return None
5054

51-
_default_exe_path = default_download_path
52-
_default_exe_path.mkdir(parents=True, exist_ok=True)
55+
_default_exe_path = root
56+
if mkdir:
57+
_default_exe_path.mkdir(parents=True, exist_ok=True)
5358

5459
if platform.system().startswith("Linux"):
55-
_default_exe_path = (
56-
default_download_path / f"chrome-{_chrome_platform_detected}" / "chrome"
57-
)
60+
_default_exe_path /= f"chrome-{_chrome_platform_detected}/chrome"
5861
elif platform.system().startswith("Darwin"):
59-
_default_exe_path = (
60-
default_download_path
61-
/ f"chrome-{_chrome_platform_detected}"
62-
/ "Google Chrome for Testing.app"
63-
/ "Contents"
64-
/ "MacOS"
65-
/ "Google Chrome for Testing"
62+
_default_exe_path /= (
63+
f"chrome-{_chrome_platform_detected}"
64+
"/Google Chrome for Testing.app"
65+
"/Contents"
66+
"/MacOS"
67+
"/Google Chrome for Testing"
6668
)
6769
elif platform.system().startswith("Win"):
68-
_default_exe_path = (
69-
default_download_path / f"chrome-{_chrome_platform_detected}" / "chrome.exe"
70-
)
70+
_default_exe_path /= f"chrome-{_chrome_platform_detected}/chrome.exe"
7171

7272
return _default_exe_path
7373

7474

75+
# can remove this and it's default after some time - 2025/11/29
76+
def get_old_chrome_download_path():
77+
return get_chrome_download_path(
78+
root=old_download_path,
79+
mkdir=False,
80+
)
81+
82+
7583
# https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries
7684
class _ZipFilePermissions(zipfile.ZipFile):
7785
def _extract_member(self, member, targetpath, pwd): # type: ignore [no-untyped-def]

src/choreographer/cli/_cli_utils_no_qa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def diagnose() -> None:
5555
print("*".center(50, "*"))
5656
print("BROWSER:".center(50, "*"))
5757
try:
58-
local_path = browser_which([], verify_local=True)
59-
if local_path and not Path(local_path).exists():
58+
local_path = Chromium.find_browser(skip_local=False, verify_local=True)
59+
if not local_path or Path(local_path).exists():
6060
print(f"Local doesn't exist at {local_path}")
6161
else:
62-
print(f"Found local: {browser_which([], verify_local=True)}")
62+
print(f"Found local: {local_path}")
6363
except RuntimeError:
6464
print("Didn't find local.")
6565
browser_path = Chromium.find_browser(skip_local=True)

src/choreographer/cli/defaults.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
/ "deps"
1212
)
1313
"""The path where we download chrome if no path argument is supplied."""
14+
15+
old_download_path = Path(__file__).resolve().parent / "browser_exe"

src/choreographer/utils/_which.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import logistro
1010

11-
from choreographer.cli._cli_utils import get_chrome_download_path
12-
1311
_logger = logistro.getLogger()
1412

1513
if TYPE_CHECKING:
@@ -47,41 +45,19 @@ def _which_from_windows_reg(key: str) -> str | None:
4745
def browser_which(
4846
executable_names: Sequence[str],
4947
*,
50-
skip_local: bool = False,
5148
ms_prog_id: str | None = None,
52-
verify_local: bool = False,
5349
) -> str | None:
5450
"""
5551
Look for and return first name found in PATH.
5652
5753
Args:
5854
executable_names: the list of names to look for
59-
skip_local: (default False) don't look for a choreo download of anything.
6055
ms_prog_id: A windows registry ID string to lookup program paths
61-
verify_local: (default False) force using local install.
6256
6357
"""
64-
_logger.debug(f"Looking for browser, skipping local? {skip_local}")
65-
path = None
66-
6758
if isinstance(executable_names, str):
6859
executable_names = [executable_names]
6960

70-
if skip_local:
71-
_logger.debug("Skipping searching for local download of chrome.")
72-
if verify_local:
73-
raise ValueError("Cannot set both skip_local and verify_local.")
74-
else:
75-
local_chrome = get_chrome_download_path()
76-
_logger.debug(f"Looking for at local chrome download path: {local_chrome}")
77-
if local_chrome is not None and local_chrome.exists():
78-
_logger.debug("Returning local chrome.")
79-
return str(local_chrome)
80-
else:
81-
_logger.debug(f"Local chrome not found at path: {local_chrome}.")
82-
if verify_local:
83-
raise RuntimeError("verify_local set to True, local not found.")
84-
8561
if platform.system() == "Windows":
8662
os.environ["NoDefaultCurrentDirectoryInExePath"] = "0" # noqa: SIM112 var name set by windows
8763
if (

0 commit comments

Comments
 (0)