pipx icon indicating copy to clipboard operation
pipx copied to clipboard

pipx run --spec seem to do network request each time

Open gsemet opened this issue 1 year ago • 6 comments

Hello.

I quite like using pipx run --spec to run my command, especially with poetry for instance:

pipx run --spec='poetry==1.7.1' poetry run

It seems pretty slow, like it is was trying to connect to pypi each time to verify that the spec is up-to-date. In my case, I would like to have pipx to behave like this:

  • spec only reference fixed version for my tool
  • if the spec verifies locally, no network connection and execute the command directly
  • if the spec is not found locally, install the virtualenv like usual.

My use case if that I have tons of various python projects, all using a slightly different version of poetry (some are aligned, some old), but i want these different version of poetry on my machine. Same for other tools such as conan, gcovr, etc

Basically, I (and probably most of users) need a fast-mode to run as fast as possible several version of poetry on the same machine. May --spec is the generic interface that can still perform network connection, but we need a "fast-as-hell" command to "select" the version of poetry to run.

gsemet avatar Feb 29 '24 10:02 gsemet

Not sure what do you mean by "latest version". --spec='poetry==1.7.1' will never update poetry, as the version is "complete, and I guess it will not update any dependencies.

--spec='poetry==1.7' does not reference a "whole" version string, --spec='poetry>=1.7.1' neither, so in these case, the syntax actually tells "find the latest please". Even --spec='poetry<1.7' requires a network ping in order to find if new 1.6.x has been released.

But in the case of --spec='poetry==1.7.1', there is not a (safe) case that would involve a reinstall. I would be happy with a dedicated command to fix the version: pipx run --frozen='1.7.1' poetry run ... would implies pipx run --spec='poetry=1.7.1' poetry run ... + no network connection on run.

gsemet avatar Feb 29 '24 16:02 gsemet

Not sure what do you mean by "latest version". --spec='poetry==1.7.1' will never update poetry, as the version is "complete, and I guess it will not update any dependencies.

That's true, sorry for the unclear formulation. Actually, pipx should detect if the app is installed within the venv and run it directly if it is, have you run in verbose mode? The cache should be kept for 14 days, normally.

chrysle avatar Feb 29 '24 17:02 chrysle

Hello. I still see this issue, for example when my env is set up, when there is a connectivity issue or when our pypi mirror is down (corporates love proxies..), it fails instead of not trying to connect and work 100% offline.

My recommendation is for pipx to first check locally if the spec is respected BEFORE any connectivity attempt, and try to do it as fast as possible. and I think this might be tricky because --spec seems very broad that's why I would like a special option that restrict --spec to a specific version of the tool I need to run.

Same for the cache, 14 days seems pretty random. If the venv is already set up and already running, do not try to modify it unless explicitely allowed to.

gsemet avatar Apr 15 '24 14:04 gsemet

My recommendation is for pipx to first check locally if the spec is respected BEFORE any connectivity attempt, and try to do it as fast as possible. and I think this might be tricky because --spec seems very broad that's why I would like a special option that restrict --spec to a specific version of the tool I need to run.

I think it should be possible to determine whether a version matching the spec is installed rather fast. Currently, we're downloading the program to be run each time. I'd be inclined to make this functionality optional, however.

chrysle avatar Apr 28 '24 13:04 chrysle

I would agree with that been optional and require a fixed, full version, that would be ideal. It is just we often have network connection issues with our VPN at work, and this blocks the execution of the tool. I use more and more pipx run --spec in order to control which version of a particular tool is installed (ex: poetry, we often have several projects using several version of the tool).

gsemet avatar May 01 '24 08:05 gsemet

Pipx run is very slow. It's unnecessary to check the versions of packages every time, especially when the network connection is poor.

zcq100 avatar May 04 '24 22:05 zcq100