diff --git a/README.rst b/README.rst index b0733a4..92cbf4a 100644 --- a/README.rst +++ b/README.rst @@ -73,12 +73,6 @@ Using `pip `__: normally expect in an activated virtualenv), but you can ask it to work within another environment using the ``--python`` option. -.. note:: - - ``pip-deepfreeze`` has experimental support for the `uv - `_ installer. To use it, install with ``pipx install - pip-deepfreeze[uv]`` and run ``pip-df sync --installer=uv``. - Quick start ----------- @@ -109,6 +103,12 @@ collaborating on the project can install the project and its known good dependencies using ``pip-df sync`` (or ``pip install -r requirements.txt -e .`` in a fresh virtualenv). +.. note:: + + ``pip-deepfreeze`` has experimental support for the `uv + `_ installer. To use it, run ``pip-df sync + --installer=uv``. + When you add or remove dependencies of your project, run ``pip-df sync`` again to update your environment and ``requirements.txt``. diff --git a/news/143.feature b/news/143.feature new file mode 100644 index 0000000..a950864 --- /dev/null +++ b/news/143.feature @@ -0,0 +1 @@ +Always install ``uv`` as a dependency. Consequently, the ``uv`` extra is removed. diff --git a/news/95.feature b/news/95.feature index 832bb34..da5d460 100644 --- a/news/95.feature +++ b/news/95.feature @@ -1,3 +1,3 @@ Declare minimum pip-deepfreeze version in ``pyproject.toml``. -pip-deepfreeze verifies its version according to `tool.pip-deepfreeze.min_version`, +pip-deepfreeze verifies its version according to ``tool.pip-deepfreeze.min_version``, so a project can ensure all contributors have the minmum required version. diff --git a/pyproject.toml b/pyproject.toml index ba5b7b5..1153974 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,16 +27,18 @@ classifiers = [ requires-python = ">=3.8" dependencies=[ "httpx", - "packaging>=23", - "pip>=22.2", - "tomli ; python_version<'3.11'", - "typer[all]>=0.3.2", + "packaging >=23", + "typer[all] >=0.3.2", + # installers + "pip >=22.2", + "uv", + # compat "importlib_resources>=1.3 ; python_version<'3.9'", + "tomli ; python_version<'3.11'", ] dynamic = ["version"] [project.optional-dependencies] -"uv" = ["uv"] "test" = ["pytest", "pytest-cov", "pytest-xdist", "virtualenv", "setuptools", "wheel"] "mypy" = ["mypy", "types-toml", "types-setuptools"] diff --git a/src/pip_deepfreeze/__main__.py b/src/pip_deepfreeze/__main__.py index a231435..f013023 100644 --- a/src/pip_deepfreeze/__main__.py +++ b/src/pip_deepfreeze/__main__.py @@ -9,7 +9,7 @@ from .pip import Installer from .pyproject_toml import load_pyproject_toml -from .sanity import check_env, get_python_version_info +from .sanity import check_env from .sync import sync as sync_operation from .tree import tree as tree_operation from .utils import comma_split, increase_verbosity, log_debug, log_error @@ -82,10 +82,6 @@ def sync( update of dependencies to to the latest version that matches constraints. Optionally uninstall unneeded dependencies. """ - if installer == Installer.uv and get_python_version_info(ctx.obj.python) < (3, 7): - log_error("The 'uv' installer requires Python 3.7 or later.") - raise typer.Exit(1) - sync_operation( ctx.obj.python, upgrade_all, diff --git a/src/pip_deepfreeze/pip.py b/src/pip_deepfreeze/pip.py index fe31a0e..e918e78 100644 --- a/src/pip_deepfreeze/pip.py +++ b/src/pip_deepfreeze/pip.py @@ -1,11 +1,9 @@ -import importlib.util import json import os import shlex import sys import textwrap from enum import Enum -from functools import lru_cache from pathlib import Path from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, TypedDict, cast @@ -30,7 +28,12 @@ parse as parse_req_file, ) from .req_parser import get_req_name -from .sanity import _get_env_info, get_pip_command, get_pip_version +from .sanity import ( + _get_env_info, + get_pip_command, + get_pip_version, + get_python_version_info, +) from .utils import ( check_call, check_output, @@ -54,11 +57,6 @@ class Installer(str, Enum): uv = "uv" -@lru_cache -def _has_uv() -> bool: - return bool(importlib.util.find_spec("uv")) - - def _pip_install_cmd_and_env(python: str) -> Tuple[List[str], Dict[str, str]]: return [*get_pip_command(python), "install"], {} @@ -77,11 +75,8 @@ def _install_cmd_and_env( if installer == Installer.pip: return _pip_install_cmd_and_env(python) elif installer == Installer.uv: - if not _has_uv(): - log_error( - "The 'uv' installer was requested but it is not available. " - "Please install pip-deepfreeze with the 'uv' extra to use it." - ) + if get_python_version_info(python) < (3, 7): + log_error("The 'uv' installer requires Python 3.7 or later.") raise typer.Exit(1) return _uv_install_cmd_and_env(python) raise NotImplementedError(f"Installer {installer} is not implemented.")