this post was submitted on 13 Oct 2023
319 points (81.3% liked)

Programmer Humor

32495 readers
664 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

Sorry Python but it is what it is.

you are viewing a single comment's thread
view the rest of the comments
[–] SatyrSack@lemmy.one 7 points 1 year ago (5 children)

Would that just create a list of the current packages/versions without actually locking anything?

[–] bjorney@lemmy.ca 8 points 1 year ago* (last edited 1 year ago) (4 children)

Would that just create a list of the current packages/versions

Yes, and all downstream dependencies

without actually locking anything?

What do you mean? Nothing stops someone from manually installing an npm package that differs from package-lock.json - this behaves the same. If you pip install -r requirements.txt it installs the exact versions specified by the package maintainer, just like npm install the only difference is python requires you to specify the "lock file" instead of implicitly reading one from the CWD

[–] SatyrSack@lemmy.one 3 points 1 year ago* (last edited 1 year ago) (3 children)

As I understand, when you update npm packages, if a package/version is specified in package-lock.json, it will not get updated past that version. But running those pip commands you mentioned is only going to affect what version gets installed initially. From what I can tell, nothing about those commands is stopping pip from eventually updating a package past what you had specified in the requirements.txt that you installed from.

[–] rgalex@lemmy.world 3 points 1 year ago (1 children)

The behaviour you mention is from npm install, which will put the same exact version from the package-lock.json, if present. If not it will act as an npm update.

npm update will always update, and rewrite the package-lock.json file with the latest version available that complies with the restrictions defined on the package.json.

I may be wrong but, I think the difference may be that python only has the behaviour that package-lock.json offer, but not the package.json, which allows the developer to put constraints on which is the max/min version allowed to install.

[–] fushuan@lemm.ee 2 points 1 year ago

If you want min-max behaviours you need to use wrappers like pipenv or jump into conda/mamba. Pip offers basic functionality because there are more advanced tools that the community uses for the more advanced use cases.

load more comments (1 replies)
load more comments (1 replies)
load more comments (1 replies)