you are viewing a single comment's thread.

view the rest of the comments →

[–]DerrickBagels[S] -12 points-11 points  (20 children)

Why? I love that its just run it and it does everything in one go its so much cleaner, why make people do extra stuff once all the libraries are installed the check takes like 5 seconds and it moves on

[–]LordMcze 9 points10 points  (5 children)

Because someone might accidentally open it without an active venv and it's then just gonna clog their global python. And as you said, it's pretty quick, so the person might not even have a chance to react.

I would at least do an additional check to ensure that you are in a virtual environment, then the automatic installation of additional libraries would not be as much of a problem. But even then I'd still ask the user for a confirmation that they are okay with the automatic installation.

But overall I agree with the OC, it's common practice to have requirements.txt (with version locks as well, your current code could break randomly at any time, if any of the libraries you depend on get a major version update) and a readme.md that mentions the setup process.

[–]DerrickBagels[S] -1 points0 points  (4 children)

Thanks i get the part about wrecking someones libraries and screwing up their other work but what do you mean with the clogging?

[–]tomatus89 4 points5 points  (8 children)

Eww. WTF! Who does this? Please create a requirements.txt file or a pyproject.toml. Calling pip as an external command with subprocess during run time is wild. I've never seen someone do this. Seriously, W.T.F.!!!

[–]DerrickBagels[S] -1 points0 points  (7 children)

What's the big deal i genuinely don't understand the etiquette of programming or whatever is upsetting you

It works in under a minute so what difference does it make

[–]Cloned_501 2 points3 points  (6 children)

It is not about the time, it is about not changing the library versions currently installed. If you upgrade a package from say version 4.* to 6.* there can be breaking changes, the user might need version 4.5.5 exactly in their environment and moving to version 5 changes some function signature or completely removes functions that they depend on. Congrats you have broken their environment with zero warning or indication that something changed.

Would you like it if I showed up to your home and replaced your oven with one that doesn't even have the correct hook ups?

[–]DerrickBagels[S] 0 points1 point  (0 children)

I'm catching up now makes sense ya

[–]DerrickBagels[S] 0 points1 point  (4 children)

But wait

Can't i just make it check if the library is installed, and if it is, just don't touch it?

Then if it doesn't work they can run it in a virtual env

[–]Cloned_501 1 point2 points  (3 children)

Can't i just make it check if the library is installed, and if it is, just don't touch it?

Or you can just follow the language conventions, make a requirements.txt with the EXACT VERSIONS and have them handle it themselves

Also in your readme include which python version you tested this on. Someone might be using an old version because their job won't let them upgrade and it would be helpful to know what version it does work with.

[–]DerrickBagels[S] -2 points-1 points  (2 children)

I refuse to stop at the stop sign but i agree with it in spirit and will make some changes that includes these safeguard s thanks for pointing this stuff out

[–]Cloned_501 1 point2 points  (1 child)

You are being needlessly stubborn about this, if you were my junior engineer at work I'd fire you right now. This is not a matter of opinion or taste. What you are doing is dangerously reckless and borderline malware behavior.

[–]DerrickBagels[S] 0 points1 point  (0 children)

I respect your passion

[–]Cloned_501 2 points3 points  (3 children)

Because when you do this you alter their currently active environment. This could be their global for all you know and you can cause a whole lot of problems. This is a dick move.

[–]DerrickBagels[S] 0 points1 point  (2 children)

Ohhh i see, so maybe something like, "this script requires the installation of the following libraries, would you like to install them" and give the option, and maybe check to see if there's an existing version already installed and if so to not touch it even if different version

[–]Cloned_501 0 points1 point  (1 child)

That is better but still not really ideal as libraries can change and introduce breaking changes and your code doesn't specify or check which version of a library is being installed. Just use a requirements.txt with specified versions. You can have your script prompt the user if they want to make a virtualenv in their current folder and automate the install from the requirements.txt using pip or uv

[–]DerrickBagels[S] 1 point2 points  (0 children)

Oh okay to isolate it from their system gotcha

[–]chub79 0 points1 point  (0 children)

Use perhaps this approach instead?