-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: 2023-present Stéphane Bidoul <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
from pathlib import Path | ||
|
||
|
||
def clean_unpacked_wheel(path: Path) -> None: | ||
distinfo_path = next(path.glob("*.dist-info")) | ||
# remove metadata files that are not useful for diffing | ||
distinfo_path.joinpath("RECORD").unlink(missing_ok=True) | ||
distinfo_path.joinpath("direct_url.json").unlink(missing_ok=True) | ||
# rename dist-info to name without version for comparability | ||
name = distinfo_path.stem.split("-")[0] | ||
distinfo_path.rename(path / f"{name}.dist-info") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: 2023-present Stéphane Bidoul <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import shutil | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
def diff_tool(v1path: Path, v2path: Path): | ||
if shutil.which("meld"): | ||
cmd = ["meld", v1path, v2path] | ||
else: | ||
cmd = ["diff", "-r", v1path, v2path] | ||
subprocess.run(cmd, check=True) # noqa: S603 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# SPDX-FileCopyrightText: 2023-present Stéphane Bidoul <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import shutil | ||
import subprocess | ||
import tempfile | ||
import zipfile | ||
from pathlib import Path | ||
|
||
|
||
def has_pip() -> bool: | ||
return bool(shutil.which("pip")) | ||
|
||
|
||
def obtain_with_pip(spec: str, path: Path) -> None: | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
cmd = ["pip", "wheel", "--use-pep517", "--no-deps", spec, "--wheel-dir", tmpdir] | ||
subprocess.run(cmd, check=True) # noqa: S603 | ||
wheelfile = next(Path(tmpdir).glob("*.whl")) | ||
zipfile.ZipFile(wheelfile).extractall(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# SPDX-FileCopyrightText: 2024-present Stéphane Bidoul <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import shutil | ||
import subprocess | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from .clean import clean_unpacked_wheel | ||
from .diff_tool import diff_tool | ||
|
||
|
||
def has_uv() -> bool: | ||
return bool(shutil.which("uv")) | ||
|
||
|
||
def obtain_with_uv(spec: str, path: Path) -> None: | ||
cmd = ["uv", "pip", "install", "--no-deps", "--target", path, spec] | ||
subprocess.run(cmd, check=True) # noqa: S603 |