Skip to content

Commit 55be151

Browse files
authored
move regex as constant to top
1 parent 20eac8f commit 55be151

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builder/penv_setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
from platformio.package.version import pepver_to_semver
2424
from platformio.compat import IS_WINDOWS
2525

26+
PLATFORMIO_URL_VERSION_RE = re.compile(
27+
r'/v?(\d+\.\d+\.\d+(?:[.-]\w+)?(?:\.\d+)?)(?:\.(?:zip|tar\.gz|tar\.bz2))?$',
28+
re.IGNORECASE,
29+
)
30+
2631
# Python dependencies required for the build process
2732
python_deps = {
2833
"uv": ">=0.1.0",
@@ -101,7 +106,7 @@ def get_packages_to_install(deps, installed_packages):
101106
elif name == "platformio":
102107
# Enforce the version from the direct URL if it looks like one.
103108
# If version can't be parsed, fall back to accepting any installed version.
104-
m = re.search(r'/v?(\d+\.\d+\.\d+(?:[.-]\w+)?(?:\.\d+)?)(?:\.(?:zip|tar\.gz|tar\.bz2))?$', spec)
109+
m = PLATFORMIO_URL_VERSION_RE.search(spec)
105110
if m:
106111
expected_ver = pepver_to_semver(m.group(1))
107112
if installed_packages.get(name) != expected_ver:

0 commit comments

Comments
 (0)