Skip to content

Commit

Permalink
Switching from pip-tools to uv (#60)
Browse files Browse the repository at this point in the history
* Untested. Changing to pyproject.toml and migrating command from pip-tools to uv

* Removing setup.py file

* Using uv instead of pip-tools

* Updating documentation

* Changing bumpver configuration

* commit_message no longer needed for bumpver configuration

* Incrementing the version

* Looks like the installation with the locked requirements file is broken because we've introduced exclusive lower bounds between versions. Let's see if this works

* Fixing windows tests
  • Loading branch information
ak-gupta authored Aug 6, 2024
1 parent 0f10573 commit 3c35c77
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 189 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install .[dev]
- name: Check docstrings
run: python -m pydocstyle edgetest_pip_tools --convention=numpy
- name: Run ruff QA checks
run: python -m ruff check .
- name: Check formatting
run: python -m ruff format . --check
- name: Check static typing
run: python -m mypy edgetest_pip_tools
- name: Run flake8
run: python -m flake8 edgetest_pip_tools
- name: Run unit testing
run: python -m pytest tests --cov=edgetest_pip_tools --cov-fail-under=80
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pip-tools integration for edgetest

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/edgetest-pip-tools)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![PyPI version](https://badge.fury.io/py/edgetest-pip-tools.svg)](https://badge.fury.io/py/edgetest-pip-tools)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/edgetest-pip-tools/badges/version.svg)](https://anaconda.org/conda-forge/edgetest-pip-tools)

Expand Down Expand Up @@ -37,7 +37,7 @@ Getting Started
---------------

This `edgetest` plugin runs after the test execution. If the last environment successfully
passes, this plugin will refresh `requirements.txt` using `pip-tools`. To use this plugin,
passes, this plugin will refresh `requirements.txt` using `uv pip compile`. To use this plugin,
you must use the ``--export`` flag in your CLI call:

```console
Expand Down
3 changes: 1 addition & 2 deletions 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 All @@ -25,7 +24,7 @@
author = "Akshay Gupta"

# The short X.Y version
version = "2023.8.0"
version = "2024.8.0"
# The full version, including alpha/beta/rc tags
release = ""

Expand Down
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Getting Started
---------------

This `edgetest` plugin runs after the test execution. If the last environment successfully
passes, this plugin will refresh `requirements.txt` using `pip-tools`. To use this plugin,
passes, this plugin will refresh `requirements.txt` using `uv pip compile`. To use this plugin,
supply ``--export`` to your CLI call:


Expand Down Expand Up @@ -59,7 +59,7 @@ If you want to specify a PyPI index, supply `index_url` in your configuration:
index_url = "https://myindex.com"
If you want to include extra installations in your `pip-tools` call add a newline-separated list of
If you want to include extra installations in your `uv pip compile` call add a newline-separated list of
extras:


Expand Down
2 changes: 1 addition & 1 deletion edgetest_pip_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Package initialization."""

__version__ = "2023.8.0"
__version__ = "2024.8.0"

__title__ = "edgetest-pip-tools"
__description__ = "pip-tools integration for edgetest"
Expand Down
18 changes: 10 additions & 8 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 @@ -42,7 +42,7 @@ def addoption(schema: Schema):


def get_reqfile(ctx: click.Context) -> Path:
"""Get the requirements file to supply to ``pip-tools``.
"""Get the requirements file to supply to ``uv``.
Parameters
----------
Expand All @@ -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 ``pip-tools`` 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 All @@ -91,9 +94,8 @@ def post_run_hook(testers: List, conf: Dict):
options.append(f"--index-url={conf['pip_tools']['index_url']}")

_run_command(
testers[-1].python_path,
"-m",
"piptools",
"uv",
"pip",
"compile",
"-U",
*options,
Expand All @@ -103,4 +105,4 @@ def post_run_hook(testers: List, conf: Dict):
except RuntimeError:
LOG.info("Unable to update the locked requirements file")
else:
LOG.info("Skipping ``pip-tools`` refresh as the tests didn't pass.")
LOG.info("Skipping ``uv`` refresh as the tests didn't pass.")
169 changes: 169 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
[project]
name = "edgetest-pip-tools"
requires-python = ">=3.8.0"
description = "pip-tools integration for edgetest"
authors = [
{ name = "Akshay Gupta", email = "[email protected]" },
{ name = "Faisal Dosani", email = "[email protected]" },
{ name = "Jacob Dawang", email = "[email protected]" }
]
license = { text = "Apache Software License" }
classifiers = [
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = ["edgetest>2024.4.0"]
dynamic = ["readme", "version"]

[project.optional-dependencies]
docs = [
"furo",
"sphinx",
"sphinx-copybutton",
"sphinx-tabs",
]
tests = [
"coverage",
"pytest",
"pytest-cov",
]
qa = [
"mypy",
"pip-tools",
"pre-commit",
"ruff~=0.5",
"types-click",
]
build = [
"build",
"twine",
"wheel",
"bumpver",
]
dev = [
"edgetest-pip-tools[docs]",
"edgetest-pip-tools[tests]",
"edgetest-pip-tools[qa]",
"edgetest-pip-tools[build]",
]

[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"

[project.entry-points."edgetest"]
piptools = "edgetest_pip_tools.plugin"

# Build system
[build-system]
requires = ["setuptools>=64.0.0"]
build-backend = "setuptools.build_meta"

##############################################################################
# Setuptools configuration
##############################################################################

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.dynamic]
version = { attr = "edgetest_pip_tools.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }

##############################################################################
# Tooling
##############################################################################

# BUMPVER --------------------------------------------------------------------

[bumpver]
current_version = "2024.8.0"
version_pattern = "YYYY.MM.INC0"

[bumpver.file_patterns]
"docs/source/conf.py" = [
'version = "{version}"',
]
"pyproject.toml" = [
'current_version = "{version}"',
]
"edgetest_pip_tools/__init__.py" = [
'__version__ = "{version}"',
]

# MYPY -----------------------------------------------------------------------

[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
ignore_missing_imports = true
allow_redefinition = true
disable_error_code = "empty-body"

# PYTEST ---------------------------------------------------------------------

[tool.pytest.ini_options]
markers = [
"unit: mark unit tests that do not require external interfaces and use mocking",
"integration: mark test that interact with an external system",
]
addopts = "--verbose"

# RUFF -----------------------------------------------------------------------

[tool.ruff]
extend-include = ["*.ipynb"]
target-version = "py39"

[tool.ruff.lint]
preview = true
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"D", # pydocstyle
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"C", # flake8-comprehensions
"T20", # flake8-print
"TID252", # flake8-tidy-imports ban relative imports
"SIM", # flake8-simplify
"LOG", # flake8-logging
"RUF", # Ruff errors
]
ignore = [
"C901", # Add back in later
"E111", # Check indentation level. Using formatter instead.
"E114", # Check indentation level. Using formatter instead.
"E117", # Check indentation level. Using formatter instead.
"E203", # Check whitespace. Using formatter instead.
"E501", # Line too long. Using formatter instead.
"D206", # Docstring indentation. Using formatter instead.
"D300", # Use triple single quotes. Using formatter instead.
"SIM108", # Use ternary operator instead of if-else blocks.
"SIM105", # Use ``contextlib.suppress(FileNotFoundError)`` insetad of try - execpt - pass.
"UP035", # ``typing.x`` is deprecated, use ``x`` instead
"UP006", # ``typing.x`` is deprecated, use ``x`` instead
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402"]
"**/{tests,docs}/*" = ["E402", "D", "F841", "ARG"]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.lint.pydocstyle]
convention = "numpy"
Loading

0 comments on commit 3c35c77

Please sign in to comment.