Skip to content

Commit

Permalink
Drop support for filtering out satisfied requirements.
Browse files Browse the repository at this point in the history
This approach was a performance optimization and intended as a means to augment an existing environment and avoid re-installing packages that were already satisfied. This behavior contradicts the efforts in #104 to run independent of the environment in which pip-run is installed.

Closes #51.
  • Loading branch information
jaraco committed Jul 16, 2024
1 parent 52e7217 commit a6a3fdd
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 55 deletions.
6 changes: 0 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Features include
- Relies on pip to cache downloads of such packages for reuse.
- Leaves no trace of its invocation (except files in pip's cache).
- Supersedes installed packages when required.
- Relies on packages already satisfied [1]_.
- Re-uses the pip tool chain for package installation.

``pip-run`` is not intended to solve production dependency management, but does aim to address the other, one-off scenarios around dependency management:
Expand All @@ -62,8 +61,6 @@ Features include
``pip-run`` is a complement to Pip and Virtualenv, intended to more
readily address the on-demand needs.

.. [1] Except when a requirements file is used.
Installation
============

Expand Down Expand Up @@ -411,9 +408,6 @@ runpy scripts).
* - interactive interpreter with deps
- ✓
-
* - re-use existing environment
- ✓
-
* - ephemeral environments
- ✓
- ✓
Expand Down
2 changes: 1 addition & 1 deletion pip_run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ def run(args=sys.argv[1:]):
pip_args, run_args = commands.infer_ipython(commands.separate(args))
commands.intercept(pip_args)
pip_args.extend(scripts.DepsReader.search(run_args))
with deps.load(*deps.not_installed(pip_args)) as home:
with deps.load(*pip_args) as home:
raise SystemExit(launch.with_path(home, launch.infer_cmd(run_args)))
16 changes: 0 additions & 16 deletions pip_run/deps.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import argparse
import contextlib
import functools
import importlib
import itertools
import os
import pathlib
import subprocess
import sys
import types
import warnings
from importlib import metadata

import packaging.requirements
from jaraco.context import suppress

from .compat.py38 import subprocess_path as sp
Expand Down Expand Up @@ -108,15 +104,3 @@ def with_prereleases(spec):
"""
spec.prereleases = True
return spec


@suppress(
packaging.requirements.InvalidRequirement,
metadata.PackageNotFoundError, # type: ignore
)
def pkg_installed(spec):
req = packaging.requirements.Requirement(spec)
return not req.url and metadata.version(req.name) in with_prereleases(req.specifier)


not_installed = functools.partial(itertools.filterfalse, pkg_installed)
32 changes: 0 additions & 32 deletions tests/test_deps.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
import copy

import pytest

import pip_run.deps as deps


class TestInstallCheck:
def test_installed(self):
assert deps.pkg_installed('pip-run')

def test_not_installed(self):
assert not deps.pkg_installed('not_a_package')

def test_installed_version(self):
assert not deps.pkg_installed('pip-run==0.0')

def test_not_installed_args(self):
args = [
'-i',
'https://devpi.net',
'-r',
'requirements.txt',
'pip-run',
'not_a_package',
'pip-run==0.0',
]
expected = copy.copy(args)
expected.remove('pip-run')
filtered = deps.not_installed(args)
assert list(filtered) == expected


@pytest.mark.usefixtures('retention_strategy')
class TestLoad:
def test_no_args_passes(self):
Expand All @@ -55,7 +27,3 @@ def test_target_retention_context():
"""Verify a target exists or can be created."""
with deps.retention_strategy().context([]) as target:
target.mkdir(exist_ok=True)


def test_url_req_never_installed():
assert not deps.pkg_installed('pip_run @git+https://github.com/jaraco/pip-run')

0 comments on commit a6a3fdd

Please sign in to comment.