Skip to content

Commit

Permalink
Using uv instead of pip-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-gupta committed Aug 6, 2024
1 parent 9f66e7e commit e13221b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down
9 changes: 6 additions & 3 deletions edgetest_pip_tools/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from configparser import ConfigParser
from pathlib import Path
from typing import Dict, List, Any
from typing import Any, Dict, List

import click
import pluggy
Expand Down Expand Up @@ -64,7 +64,8 @@ def get_reqfile(ctx: click.Context) -> Path:
else:
reqfile = Path(ctx.params["requirements"])
elif Path(ctx.params["config"]).name == "pyproject.toml":
parser = load(open(Path(ctx.params["config"])))
with open(Path(ctx.params["config"])) as buf:
parser = load(buf)
if "dependencies" in parser["project"]:
reqfile = Path(ctx.params["config"])
else:
Expand All @@ -80,7 +81,9 @@ def post_run_hook(testers: List, conf: Dict):
"""Refresh a locked requirements file based on the test output."""
ctx = click.get_current_context()
if not ctx.params["export"]:
LOG.info("Skipping ``uv pip compile`` as the requirements have not been updated.")
LOG.info(
"Skipping ``uv pip compile`` as the requirements have not been updated."
)
elif testers[-1].status:
reqfile = get_reqfile(ctx=ctx)
try:
Expand Down
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ qa = [
"mypy",
"pip-tools",
"pre-commit",
"ruff==0.5",
"ruff~=0.5",
"types-click",
]
build = [
Expand All @@ -56,9 +56,9 @@ dev = [
]

[project.urls]
"Documentation" = https://capitalone.github.io/edgetest-pip-tools/
"Bug Tracker" = https://github.com/capitalone/edgetest-pip-tools/issues
"Source Code" = https://github.com/capitalone/edgetest-pip-tools
"Documentation" = "https://capitalone.github.io/edgetest-pip-tools/"
"Bug Tracker" = "https://github.com/capitalone/edgetest-pip-tools/issues"
"Source Code" = "https://github.com/capitalone/edgetest-pip-tools"

[project.entry-points."edgetest"]
piptools = "edgetest_pip_tools.plugin"
Expand Down Expand Up @@ -90,7 +90,7 @@ readme = { file = ["README.md"], content-type = "text/markdown" }
current_version = "2023.8.0"
version_pattern = "YYYY.MM.INC0"
commit_message = "Bump {old_version} to {new_version}"
commit = True
commit = true

[bumpver.file_patterns]
"docs/source/conf.py" = [
Expand All @@ -106,7 +106,7 @@ commit = True
# MYPY -----------------------------------------------------------------------

[tool.mypy]
python_version = 3.10
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
ignore_missing_imports = true
Expand All @@ -130,7 +130,6 @@ target-version = "py39"

[tool.ruff.lint]
preview = true
ignore-init-module-imports = true
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
Expand Down
32 changes: 21 additions & 11 deletions tests/test_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,34 @@ def test_update_reqs_cfg(mock_popen, mock_cpopen, mock_builder):
assert result.exit_code == 0
assert mock_popen.call_args_list == [
call(
(f"{str(py_loc)}", "-m", "pip", "install", "."),
("uv", "pip", "install", f"--python={py_loc!s}", "."),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(
f"{str(py_loc)}",
"-m",
"uv",
"pip",
"install",
f"--python={py_loc!s}",
"myupgrade",
"--upgrade",
),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(f"{str(py_loc)}", "-m", "pip", "list", "--format", "json"),
("uv", "pip", "list", f"--python={py_loc!s}", "--format", "json"),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(f"{str(py_loc)}", "-m", "pip", "list", "--format", "json"),
("uv", "pip", "list", f"--python={py_loc!s}", "--format", "json"),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
Expand All @@ -199,6 +203,7 @@ def test_update_reqs_cfg(mock_popen, mock_cpopen, mock_builder):
"setup.cfg",
),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
]
Expand All @@ -219,7 +224,7 @@ def test_update_reqs_toml(mock_popen, mock_cpopen, mock_builder):
with runner.isolated_filesystem() as loc:
with open("pyproject.toml", "w") as outfile:
outfile.write(TOML_ART)
result = runner.invoke(cli, [f"--config=pyproject.toml", "--export"])
result = runner.invoke(cli, ["--config=pyproject.toml", "--export"])

env_loc = Path(loc) / ".edgetest" / "myenv"
if platform.system() == "Windows":
Expand All @@ -230,30 +235,34 @@ def test_update_reqs_toml(mock_popen, mock_cpopen, mock_builder):
assert result.exit_code == 0
assert mock_popen.call_args_list == [
call(
(f"{str(py_loc)}", "-m", "pip", "install", "."),
("uv", "pip", "install", f"--python={py_loc!s}", "."),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(
f"{str(py_loc)}",
"-m",
"uv",
"pip",
"install",
f"--python={py_loc!s}",
"myupgrade",
"--upgrade",
),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(f"{str(py_loc)}", "-m", "pip", "list", "--format", "json"),
("uv", "pip", "list", f"--python={py_loc!s}", "--format", "json"),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
(f"{str(py_loc)}", "-m", "pip", "list", "--format", "json"),
("uv", "pip", "list", f"--python={py_loc!s}", "--format", "json"),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
call(
Expand All @@ -268,6 +277,7 @@ def test_update_reqs_toml(mock_popen, mock_cpopen, mock_builder):
"pyproject.toml",
),
stdout=-1,
stderr=-1,
universal_newlines=True,
),
]

0 comments on commit e13221b

Please sign in to comment.