Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

Pyenv compiles python. This excludes it for pretty much every solution by default, as compiling can fail in so many weird ways.

Nobody wants to support something that can turn even the simplest ticket into a game of cluedo.


After 10 years using all of them, in about 50 companies (as a freelancer) with various constraints, contexts, systems and skillsets involved, here are my definitive conclusions:

- stick to regular python installers from python.org if you can. Don't use homebrew, pyenv, conda, the windows store, asdf, etc. They have subtle and least subtle variations that will bite you.

- always use "-m" when you run a python tool, even in venv. This will let you be explicit about which python you use. On windows, use the "py" command to create the venv. No need for pyenv.

- if you are in linux, research how to install python seriously. If the command is simple, you probably got it wrong. E.g: Ubuntu has 3 packages to install, not one. People giving you a one true way are lying to you. Pyenv is a trap.

- learn to use basic venv and pip. Never do something outside of a venv, even for small scripts. You can have one big venv for all your small scripts. Don't even install black outside of a venv. You can get very far with just that. Forget about pipx.

- if you want to have better tooling, use pip-tools. Not pipenv. Not poetry. Not flint. Not pdm. Not anything else. They will fail you. Pip-tools is just good enough and just reliable enough. Embrace manual venv handling. It's not a big deal. Automated tools will betray you.

- learn to be comfortable with the PATH and the PYTHONPATH. No matter what you do, something may need tinkering.

- tox is indeed the best tool to test several envs, but people that need it are rare. Don't bother for now.

- if you want to build a package, use hatch. But you probably don't.

- if you have to use conda, don't use pip or venv at all. Don't use piptool, poetry or anything. Stay on pure conda land. It sucks, but the alternative of mixing them is worse.


Couple of points/expansions

>if you are in linux, research how to install python seriously.

I.e, build from source, after installing necessary dependencies (https://devguide.python.org/getting-started/setup-building/#...). Use sudo make altinstall to install the specific version. Usually distro provided ones are pretty old anyways, so you want the faster 3.11 and on.

>Never do something outside of a venv. Not even install black. You can get very far with just that.

If you want to just write scripts to test things, working outside venv is fine as long as you manually install pip using get-pip.py, then invoke pip using python3.xx -m pip (make a bash alias for this command, and then delete the binaries in ~/.local/bin). This will install all the binaries to ~/.local/lib/python3.xx/site-packages, which keeps everything isolated.

>if you want to have better tooling, use pip-tools. Not pipenv. Not poetry. Not anything else.

Also, stick to setup.py for module installation definition. It keeps everything in one place and allows you to run custom workflows. For example, if you wanna run flake8 on install to check your code, with pyproject.toml, it requires pyproject.toml and setup.cfg. With setup.py, you can do this all in one file. Not only that, it gives you extra options to run certain commands.

>if you want to build a package, use hatch.

setuptools is fine for building a wheel - all you are doing is moving files around and zipping them.

As far as OS goes, if you are on Windows, use WSL2 and run python there. Don't even bother with Windows python. If you are on mac, use `asdf` for python installation.


I would advice against all of those recommandations. It would be very long to explain point by point, but in short, my experience is that if someone is asking OP's question, they don't have the experience to deal with the modes of failure of what you are proposing

There is not a lot of things I'm very adament about.

Yet when it comes to python env setup, I have a strong opinion on the matter, built from seing hundreds of people failing at it in a thousand ways.

Looking for the best solution will not work.

You have to go to the minimal one that does the job, which have the least possible ways to fail. And still work in 5 years.

Most people like you, giving advices on HN, know too much about it to realize you solve lots of problems without even thinking when you perform your workflow.

But the average python user don't have this knowledge. They just want to get things done and have something that works.

I am very confident in these claims, although a HN comment is not the best format to demonstrate it.

I should write an article on it honestly at this point because so many devs are suffering for this.

A new team has been put in place to work on packaging officially in python. But the fruits will take years to mature.


Can you give me at least one of the points that you disagree with and reasons why?


The first one, build from sources, is incredibly easy to get wrong.

You may end up with an incomplete python without proper tkinter, ssl or zip support. Sometimes it will look like it works, only to fail later down the line when you use some part of openssl that requests don't exercice often or when you install numpy/scipy wheels. Not to mention someone will do "make install" instead of "altinstall" and break their machine with a 3 letters mistake since apt or rpm python will get erased.

If you wonder how to setup a python venv, you should not compile anything (so no oyenv neiter). In the same way that if you wonder what oil to put in your car, you should not attempt to fix your breaks.

The fact you suggested it underlines my point that you are too experienced with the stack to give advices that would be useful for most confused devs in python. A C# dev that starts python just wants, and needs, one reliable happy path.

In fact, it's part of the problem. Paradox of choice, with too many solutions that won't fit the average user context.

Funnily, now that I get close to 20 years of python, I find myself going back to the beginner stuff.


What's with the push to encourage people not to learn? Get em started, let em figure the rest out as they run into it. You aren't gonna be here forever.

The test of a tool is learnability.


Of they will learn.

But instead of having to learn about how to setup python, they will spend the same time learning on how to solve their problem with python.

Given that days have only 24 hours, the latter is more attractive to a lot of people.


>You may end up with an incomplete python without proper tkinter, ssl or zip support.

I specifically said after installing dependencies, which is mentioned in the documentation.


The documentation doesn't, and cannot, mention how to install said dependencies for each distro and version. It is non trivial, and hand waving that is like the "draw the rest of the owl" meme.

Even if the 10 most popular distros were documented, with all their supported versions, and if it covered windows and mac versions as well, and dealt with people in corporation not having admin rights on their machine, you'd still have so many steps a human error will be more likely to be inserted than just use what I suggested.

Again showing that you are so good at dealing with complexity you are not even seing it.

The only way I could convince you at this point would be to make you train 10 different teams, of 10 different people in 10 different contexts and give you one million of dollar if after one year you come back to see that their department has this stuff streamlined.

But I can't do that so that will have to be the end of this thread.


The really insidious one is:

> If you want to just write scripts to test things ...

So often "just scripts" evolve into long term projects, and, due to time pressure etc. never free themselves of bad foundations.


How do you handle multiple python versions? I have found pyenv the simplest cross system approach


On mac and linux, python executables are suffixed, on windows, use the py command (hence using the official installer).

Once you have created the venv, it doesn't matter.


Similar experience, but disagree with almost everything you have said.

- stick to regular python installers. Don't use homebrew, pyenv, conda, the windows store, etc.

For me pyenv has been a lifesaver, easier to manage multiple versions. Are you manually managing multiple python versions?

- always use "-m" when you run a python tool, even in venv. This will let you be explicit about which python you use. On windows, use the "py" command to create the venv.

Unsure how I feel about this, I do normally point direct to the binary being used rather than using "-m", Although "-m" still requires you to be in the correct venv. How does it allow you to be specific about the python you use though?

- if you are in linux, research how to install python seriously. If the command is simple, you probably got it wrong. E.g: Ubuntu has 3 packages to install, not one. People giving you a one true way are lying to you. Pyenv is a trap.

poetry has been another lifesaver that removes the boring writing of a setup.{py,cfg}. Pretty much everything can be managed through it, and it feels like a legit build tool for python. No more broken requirements because of a differing versions in transitive dependencies.

- learn to use basic venv and pip. Never do something outside of a venv. Not even install black. You can get very far with just that.

Can't disagree with this, although poetry will manage your venvs for you. Understanding venv and pip is useful, but not fundamental. Greatest success for devs has been getting them away from manually managing things, by and large perm staff don't care about learning lots of tools well, it's just a job.

- if you want to have better tooling, use pip-tools. Not pipenv. Not poetry. Not flint. Not pdm. Not anything else. They will fail you. Pip-tools is just good enough and just reliable enough. Embrace manual venv handling. It's not a big deal. Automated tools will betray you.

lumping poetry in with pip-tools is weird. it's not a replacement, it's a tool with greater scope than pip-tools. pip-tools provides a subset of poetry functionality i.e. dependency management.

Manual handling is useful to learn, but is laborious after a while, hence tools such as poetry.

- learn to be comfortable with the PATH and the PYTHONPATH. No matter what you do, something may need tinkering.

This is a really interesting point, normally modifying PYTHONPATH is a smell in my experience, but yes is good to understand. Understanding the PATH in general is more useful as a dev than specific to python imo.

- tox is indeed the best tool to test several envs, but people that need it are rare. Don't bother for now.

Agreed, its a nice thing to do, but rarely do I see it unless you are building libs, and need to support multiple versions.

- if you want to build a package, use hatch. But you probably don't.

Why would you use hatch over a tool such as poetry, are they equivalent? I'm interested in exploring hatch, but the comparisons I have found seem to be fundamentally misinformed about poetry so its hard to take comparison seriously.

- if you have to use conda, don't use pip or venv at all. Don't use piptool, poetry or anything. Stay on pure conda land. It sucks, but the alternative of mixing them is worse.

This is a really good point, but is always a frustrating thing to try and solve time and time again, but still encounter problems.


If you recommend pyenv, it's game over, I will never been able to convince you otherwise.

Because it's a sure sign that you have not had to help a team of geographers in a school or quants in banks or small kids.

Your method will only work for a very small subset of python users, and you don't have met enough of them to even know what error they encounter.

It's ok, you are a skilled dev, you offer skilled devs advices.

But no, pyenv has too many ways to fail for the average python users. Espacially since the "py" command on windows and suffixed python on mac and linux works fine to deal with multiple versions.

If would be too long to debate each point so I won't. But I don't make those claims out of the will to be right or contradict people.

I worked with python since 2.4, in dozens in countries. In africa. In asia. In the silicon valley.

It gave me a huge sample to study.


Exactly. People keep telling how much ubuntu sucks and how they are now using x.

But eventually, my mother is still using it after 10 years.


If it's the case, then take the hint.

I can't believe how much BS we have to hear about consensual sex these days to the point people are suggesting contract before making love, and yet the virtual signalers in the valley can't still see the problem with forcing people to be spied upon even when told to piss off.

Maybe too many new web framework turn over also burnt out their common sense?


Silicon Valley still seems to have a huge problem with the concept of user consent and giving users meaningful choices. If "Silicon Valley" was a human being, it would be that creepy guy in the club hitting on everyone, saying "Do you want to be my girlfriend? [YES] [Ask Me Again Later]"


That would be a great short movie.

You could also show the same person, 10 minutes prior, telling their locksmith they should say "main-key" instead of "master-key" because that's inappropriate, otherwise they won't call them for more gigs.


> it would be that creepy guy in the club hitting on everyone, saying "Do you want to be my girlfriend? [YES] [Ask Me Again Later]"

And somehow the DJ is always playing "What is Love?" when it happens.


>people are suggesting contract before making love

I would unironically require this simply because the legal liability risks are too bloody high otherwise.

Not that I would get myself into such a situation in the first place. In this day and age there are many other avenues of entertaining oneself without the ridiculous liability risks.


How does that work in Europe where all tracking must be opt-in thanks to GPRD?


GDPR deals with user identifiable data or that can be tied to the identity of a user through partially anonymous data.

It should be fine to collect "telemetry" as long as the data itself isn't personal and that it also cannot be tied in any way to a particular user.

At least, this is how I've interpreted the GDPR rules.

On the other hand if you tie telemetry to a user ID, fingerprint, unique device identifier, etc, then all the data is personal, and since it's not obvious and necessary, you also cannot argue its a legitimate interest (note that most GDPR popups arguing legitimate interest are absolutely not valid).


My motto is, All data gathered from my device is user identifiable until proven otherwise.


Unfortunately that's the conclusion that most managers will draw, without asking more questions.

But knowing that only 1% of users use this feature is not enough to make that decision:

- maybe 1% of your users only use it, but they are the ones that pay the most money

- or it's the most prolific users so it generates half of your content

- or it's a niche feature used by power users, but those users are the ones bringing other users, introducing you to companies and doing free support

- or it needs to be used by only 1% of the users by design, and it's enough to be useful (E.G: bug report form)

- or your report it wrong, it's one percent of all accounts, but 10% of actually active users

etc.

Most telemetry will not tell you that of course.


Well, tracking users by cookies or fingerprinting or whatever can tell you that by combining data from different sources. Now we've looped back around to being in favor of the most intrusive methods.


That's my point, if you want really useful information, you need identifiable users, and for that, you need consent.

So ask for it.

All data will be biased and incomplete anyway, so at least acquire it in an ethical manner.


As I said that is a "piece of information", not the whole story. Making an axing decision with ONLY that information would be outright idiotic.

Telemetry has to be designed as well, to piece as much as you can, and then you complete the full picture with other sources. Maybe not everybody does this, but I don't think that this practice should be "shocking" for anybody.


yea you sound like someone who is competent and will actually thing things through and make a rational decision. Many people are not and will latch on to the information "only 1% of people use it!" and refuse to listen to why that may not matter"


> Most telemetry will not tell you that of course.

Why...? If that's the case, it sounds like the problem is too little telemetry, not too much.


Well, in Europe, if you want to know how much a user pays, you need to tie telemetry to their account containing personal information, which is forbidden by GPRD unless they give their explicit consent and they have a process to delete/rectify/download all of it.

Since most telemetry are optout and don't bother about giving users access to their data, they can't legally do it.

That's my point really: useful telemetry is really, really invasive. So just ask consent, and accept most users will tell you no.

If you chose what's convenient instead, you will not only have a mixed bag of data, but also you have decide to basically force yourself on people, in an age where a part of your userbase is getting upset over things like using the wrong pronoun on them.

I tell yes to Firefox and VLC to report on my usage. It tell no to Google and Microsoft. They want their cake and it it: behave badly, and then have we trust them.


> give their explicit consent

They already need to agree to Terms of Service when paying and starting to use the software.


And that is not explicit consent.

Explicit consent needs to be standalone and refusing it cannot stop the user from doing anything that doesn't actually really require said consent.


Right. A mention in the ToS does not equal real consent. I would only add that it also has to be informed consent. Saying something like "can we collect data from you to improve our products and services?" is also not soliciting real consent, because it tells the user basically nothing about what is being asked of them and how it will be used.


You think that keeping track of "This paying user uses this and that feature, and is thus on the correct price plan" is a violation of the GDPR, assuming it's mentioned in the privacy police and maybe ToS?


I don't know what does or does not violate the GDPR, and I'm not talking about metering services. I'm talking about telemetry for installed software.

I'm not even talking about what the law says, because the law is very inadequate on these matters (in the US, anyway). I'm talking about, from a common-sense point of view, what "consent" is.

In my view, it can only be counted as "consent" if I have been informed exactly what it is that I'm consenting to, and I am asked for that consent.

ToS don't count for a number of reasons, starting with the fact that nobody reads them, it's unrealistic to expect people to read them (because everything comes with lengthy ToS documents and if you really read them all, little time would be left to do anything else), they are generally difficult to properly understand if you're not a lawyer, and they are are usually intentionally vague of this issue -- which means the "informed" part of "informed consent" isn't satisfied even if you do read them.

I think the Principle of Least Surprise should apply here. If software is going to do something that users won't notice happening, is intrusive, and isn't pretty obvious from the nature of the software, the right thing to do is to tell the user about it and ask for permission.

Software that doesn't do this is adversarial to the user.


That seems interesting, when thinking about pro rated subscription fees -- if a feature isn't being used, it'd cost nothing. But with telemetry disabled by default, the company couldn't detect that the feature wasn't being used, and thus the customer would pay more. And if opting in to telemetry, the customer pays less and the company gets telemetry.


Jancovici's conference about how ecology and economy eventually boil down to fundamentals such as energy is eye opening:

https://www.youtube.com/watch?v=KtQBPhKSWu0&list=PLMDQXkItOZ...

The punchlines are wonderful. E.G: "The first law of thermodynamics will always win over political promises".

Highly recommended.


Some of his conferences and courses (in particular the École des Mines 20h course) are available with English subtitles.


Do you have a link?


Here you go:

Dubbed videos (mostly English but also Russian and maybe other languages): https://www.youtube.com/playlist?list=PLMDQXkItOZ4JcKrdHyRaA...

Videos with English subtitles: https://www.youtube.com/playlist?list=PLMDQXkItOZ4II_sYvh0Be...


Thanks.

The first one is French dubbed in russian. If you speak russian, I would recommend it as it as the slides clearly in view.

However, the second one, in English doesn't show most of the slides, and they are really necessary to get the full picture. However, it's a playlist, and there are better ones in there.

If you don't mind, I will update my comment to include one of them.


It's been the case for python for a while and nothing bad happened. Nobody started to use accentuated variables. But I finally could put my name in comments without having to put a # coding header, which is nice.


Yes, and it's a good thing. I want them to have a business model, because I want them to survive.

Not every project can be as amazing as debian and run strong for so many years on volonteers alone.


Debian definitely isn't volunteers alone, lots of companies pay people to work on Debian.


Genepi production is pretty limited itself because of the heavy restrictions on the plant harvest, espacially since it grows mainly in the Alps. And the Mercantour rangers are not tolerant of people picking more than their share.

Source, I live there.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: