pipx icon indicating copy to clipboard operation
pipx copied to clipboard

fix: install specified version of `--preinstall` dependency instead of latest version

Open davidpeckham opened this issue 1 year ago • 3 comments

  • [x] I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

Fixes #1377

chrysle found the problem -- commands/install.py calls package_name_from_spec when it shouldn't. I removed that call and passed the dependencies unmodified to venv.upgrade_package_no_metadata.

Test plan

I added this test case to tests/test_install.py:

def test_preinstall_specific_version(pipx_temp_env, caplog):
    assert not run_pipx_cli(["install", "--preinstall", "black==22.8.0", "nox"])
    assert "black==22.8.0" in caplog.text

Tested by running

pipx install --preinstall black==22.8.0 nox

davidpeckham avatar Apr 26 '24 19:04 davidpeckham

How about running pipx.package_specifier.parse_specifier_for_install over the deps instead?

chrysle avatar Apr 27 '24 05:04 chrysle

How about running pipx.package_specifier.parse_specifier_for_install over the deps instead?

Thanks, I added that.

davidpeckham avatar Apr 27 '24 12:04 davidpeckham

My bad, I've just seen the function is already called in pipx.venv.install_package. Could you revert the change?

chrysle avatar Apr 27 '24 17:04 chrysle

@davidpeckham https://github.com/pypa/pipx/pull/1379/commits/7339ae01045f2bece87dd7641305fa3db9b694c2 seems to be empty...

chrysle avatar Apr 28 '24 18:04 chrysle

@chrysle I think that last commit fixed it.

davidpeckham avatar Apr 28 '24 23:04 davidpeckham

Thanks!

chrysle avatar Apr 29 '24 13:04 chrysle