rbanffy / pip-chill

A more relaxed `pip freeze`
Other
560 stars 25 forks source link

pip missging from top-level dependencies #78

Closed MarcinKonowalczyk closed 4 weeks ago

MarcinKonowalczyk commented 3 months ago

Environment

Description

This is a followup from PR #75.

Test fails if a package with pip as a dependency is installed in the test environment.

What I Did

Checkout head of PR #75.

git clone https://github.com/MarcinKonowalczyk/pip-chill
cd pip-chill
git checkout setuptools-req
# This commit does *NOT* have the fix anymore
git reset --hard e5f9e8e5885db617d5b0f23ed026ec9553fca707
# Make a venv and run test in
python -m venv venv
venv/bin/pip install -r requirements_dev.txt
venv/bin/pip install .
venv/bin/pytest # All good

Now let's install a package which depends on pip. I'm not picking on pip-autoremove here. It's just the package that i've noticed this behaviour with first.

venv/bin/pip install pip-autoremove
venv/bin/pytest # Fails

pytest output:

self = <tests.test_pip_chill.TestPip_chill testMethod=test_all>

    def test_all(self):
        packages, _ = pip_chill.chill(show_all=True)
        package_names = {package.name for package in packages}
        for package in ["pip-chill", "pip"]:
>           self.assertIn(package, package_names)
E           AssertionError: 'pip' not found in {'sphinx', 'ssort', 'nose', 'pip-autoremove', 'tox', 'coverage', 'watchdog', 'bumpversion', 'pip-chill', 'flake8', 'twine', 'bandit', 'pytest'}

tests/test_pip_chill.py:38: AssertionError

FAILED tests/test_pip_chill.py::TestPip_chill::test_all - AssertionError: 'pip' not found in {'sphinx', 'ssort', 'nose', 'pip-autoremove', 'tox', 'coverage', 'watchdog', 'bumpversion', 'pip-chill', 'flake8', 'twine', 'ba...

This happens because pip-autoremove depends on pip and so pip is put into dependencies. The fact that the test asks for pip to be present in dept makes me think it ought to be special and always show up in top level. I think either 1) the test should change, 2) the behaviour of pip-chill should change or 3) this 'sharp corner'(?) should be better documented.

For reference, in #75 i've originally implemented option 2. It can be tried with:

git reset --hard 79705e0662ad625dc1d241a9a1c379d75d1d54a3
rm -rf venv # lets try in a fresh venv, just to be sure
python -m venv venv
venv/bin/pip install -r requirements_dev.txt
venv/bin/pip install .
venv/bin/pip install pip-autoremove
venv/bin/pytest # Now works

Here is the diff.

MarcinKonowalczyk commented 3 months ago

I'm happy with this just really being a non-issue and closing it with #wont-fix or something along these lines btw. Mainly just wanted to document the behaviour and keep a reference to the relevant bit of code somewhere :))

github-actions[bot] commented 1 month ago

Stale issue message