Live data from Hacker News

Python Practical Package Packing 2024

matt.sh

31–37 of 37 posts

Re: Python Practical Package Packing 2024

#31
Due to supply-chain attacks, for your cybersecurity, I strongly encourage everyone to use a container for each project for development purposes. I do this using devcontainer.json in VSCode which is free. PyCharm too offers devcontainer integration but not for free, so I moved away from PyCharm. You can alternatively use a plain docker container if your IDE integrates with it, but devcontainer is more suited for this purpose. All this is assuming that you don't use a web IDE which already offers project isolation.

Re: Python Practical Package Packing 2024

#34
post #17

For someone that is from the Ruby world and uses rbenv / bundler confortably, what would be the canonical way of using / managing Python in MacOS? There seems to be a sea of alternatives and I see every tutorial mention `pip install` while I don't even have that running in my CLI (only pip3). Do people assume an alias here of I have somehow messed up my environment?

Pixi [1]. A lot of people recommend UV, which pixi uses under the hood to install pip packages [2].

The difference between UV and pixi is that pixi is better tooling for working with Conda repositories, and UV focuses in working with pip packages. Pixi allows installing not only pip packages but anything that has been packaged for Conda, which includes a lot of non-python stuff (C/C++ libraries and more).

For instance, I use it to install the Go compiler per-project, since using a global installation tends to grow "polluted" with every single go package that you have ever installed. You could even use it to install Node, NPM or ruby per-project, it just works. It also supports lock files [3].

--

1: https://pixi.sh/latest/

2: https://prefix.dev/blog/uv_in_pixi

3: https://pixi.sh/latest/features/lockfile/#why-a-lock-file

Re: Python Practical Package Packing 2024

#35
post #17

For someone that is from the Ruby world and uses rbenv / bundler confortably, what would be the canonical way of using / managing Python in MacOS? There seems to be a sea of alternatives and I see every tutorial mention `pip install` while I don't even have that running in my CLI (only pip3). Do people assume an alias here of I have somehow messed up my environment?

Pixi [1]. A lot of people recommend UV, which pixi uses under the hood to install pip packages [2]. The difference between UV and pixi is that pixi is better tooling for working with Conda repositories, and UV focuses in working with pip packages. Pixi allows installing not only pip packages but anything that has been packaged for Conda, which includes a lot of non-python stuff (C/C++ libraries and more). For instanc…

Tangent: to run things with pixi, you need to either 1) `pixi run thing` 2) `pixi shell` to spawn a new shell with adjusted env or 3) `eval "$(pixi shell-hook -s bash)"` (or similar for other supported shells) to modify your current session.

I found that direnv [1] really improved the ergonomics for me. There's some misunderstanding that direnv requires Nix but that's not true. It does one thing and does it well: load .envrc files when you cd that path.

I have a lil `.envrc` that looks like this:

    # Load pixi shell settings.
    eval "$(pixi shell-hook -s bash)"

After that, you can just run `python` and it will run whatever python you asked it to install (`pixi add python` adds the latest python 3 in conda by default).

--

1: https://direnv.net/

Re: Python Practical Package Packing 2024

#36

Earlier quoted context omitted.

Yeah I gotta agree here, I'm not sure I've seen someone so opinionated with python. I tend to try to use things built into python or official recs until I hit an actual problem that needs to be solved.

This is why I'm not posting this article to my team's slack. There's some good stuff in the article, but my team also has some well-meaning over-optimizers that will see this and start throwing in orjson even though json (de)serialization is an insignificant impact to our execution time, or loguru even though our code base has stupidly simple logging requirements, and they'll do it because they'll see this article st…

> using loguru when you could be using structlog

Oof. Yikes. Outdated much? I kid, but it's way too easy to be dogmatic about stuff like libs.

Re: Python Practical Package Packing 2024

#37

Earlier quoted context omitted.

Is the UX comperable? Might try this

I haven't used uv but it looks like its trying to be a drop-in replacement for pip which would therefore lack everything that makes poetry great. Rye on the other hand seems to be extremely poetry-like while being written in rust for speed: https://rye.astral.sh/ But personally, I can't justify switching my employer to experimental python dependency management over something as inconsequential as taking a minute to i…

Same here... not gonna switch tools every 6 months for such a small benefit. I like that it downloads its own interpreters though, makes it easy to start a project.
Post reply on HN