Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for filtering out satisfied requirements. #110

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
- ✓
-
Comment on lines -414 to -416
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On further consideration, this feature still exists and still distinguishes pip-run from pipx. Even though existing satisfied dependencies will be overlayed, the existing target environment will still be present, and unspecified dependencies will be available from that environment.

* - ephemeral environments
- ✓
- ✓
Expand Down
1 change: 1 addition & 0 deletions newsfragments/51.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped support for filtering out satisfied requirements.
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')
Loading