Live data from Hacker News

My Python Development Environment, 2018 Edition

jacobian.org

121–130 of 224 posts

Re: My Python Development Environment, 2018 Edition

#121
post #12

Every time I use Python I miss NPM and package.json.

Why? What NPM can achieve but pip cannot? You can export requirements.txt easily. NPM downloads some many seemingly useless stuff, makes the node_modules directory so bloated, pip is like a breeze in comparison to that.

Re: My Python Development Environment, 2018 Edition

#122
post #96

I don't understand this at all. It's 2018. My dev. env. for is some text editor that knows how to "jump to definition" and "find all usages" (this is sometimes referred to as "IDE"), and a bunch of Dockerfiles to build and run the tests.

So you're using Docker instead of virtual environments? I feel there is much more overhead with Docker, but I could be wrong. Maybe I need to try it out again!

No, it's pretty much the same as you remember it. Using docker instead of just a normal virtualenv is overkill.

Re: My Python Development Environment, 2018 Edition

#124
post #55

Earlier quoted context omitted.

This, me too. I never understood the need for virtualenv and similar. Do people really encounter trouble with conflicting packages that often? I try to write scripts so they run on different versions of python anyway, unless there is a very specific reason why that is not possible; and even then you can run python versions in parallel on a Debian/Ubuntu box, with different pip installs for each of them. As for produc…

Do you just use one environment for every project? That gets messy. What if you want to setup a new machine? Or a new employee's machine? Etc.. It isn't only about conflicting packages.

Yes - but then again, I don't have that many projects and I tend to use the same libraries across them anyway.

Installing on another machine is just a matter of pip install -r requirements.txt, if it's for a dev. other wise it's just a docker run ....

I do know that most Python devs use virtualenv, I just never understood what all the fuss is about. Of course I don't mind if the others in team use it, I just never saw the appeal so I'm curious what other peoples' reasons are.

Maybe I don't see the need because I came to Python quite late, a little before Docker came around, and we were early adopters for Docker. So we solved testing and production with Docker (and thus never needed to support multiple Python versions in parallel). It's really one of those small mysteries I don't understand. :)

Re: My Python Development Environment, 2018 Edition

#125
post #91
post #57

Earlier quoted context omitted.

Nix is one of the most amazing things created lately. IMHO, it doesn't get the attention it deserves as it provides great solutions to really tough problems and it's ready for prime time. A purely functional package manager, distro, devops. And pretty soon, home directory management. Maintaining servers or doing aggressive changes becomes very easy. There's even a Darwin (macOS) implementation now, so you can manage…

Excuse me if this question is too basic but how does a purely functional package manager work with a side-effectful package installation? In Python (or basically any other language package manager) you can run arbitrary scripts (post-install etc) and so this doesn't lend itself nicely to a reproducible, functional approach.

A quick and overly simplistic explanation is that all inputs (source code, package dependencies or post-install scripts) used to build a package are employed to compute a unique hash.

Then the result of building a particular package is installed in /nix/store/hash-packagename. And this package links to other packages in the nix store using precise hashes. There is no dynamic linking. So the result is referentially transparent. A particular hash is guaranteed to correspond to the same package version, built in the same way and linked to the same dependencies. Furthermore, installing new package versions or modified versions of a package wont overwrite old ones, as hashes are different.

The same concept applies to a whole system setup, which is identified by a hash computed using all options that configure the system plus all packages available in your environment.

Re: My Python Development Environment, 2018 Edition

#126

Earlier quoted context omitted.

pipenv is like npm for python and Pipfile works similar to package.json. There's even a Pipfile.lock

pipenv is more like yarn (same version locking concept)

If I remember correctly the newest npm does the same though.

Re: My Python Development Environment, 2018 Edition

#127

I haven't had to write python in awhile but are there reasons to use virtualenv etc. instead of a docker container?

Docker is SLOW to build the image. Virtualenv is great for development.

But you do not have to build the image while developing (in Python). Just map your project into the image using `-v`.

Re: My Python Development Environment, 2018 Edition

#128
post #57

Earlier quoted context omitted.

Nix is one of the most amazing things created lately. IMHO, it doesn't get the attention it deserves as it provides great solutions to really tough problems and it's ready for prime time. A purely functional package manager, distro, devops. And pretty soon, home directory management. Maintaining servers or doing aggressive changes becomes very easy. There's even a Darwin (macOS) implementation now, so you can manage…

I'm a big fan apart from how they version. Depending on when you install the version will point at a different commit hash. In our case, all of our Haskell builds failed on all but 1 machine (day apart in resolutions). How nixos handles environments meant our large package builds would kill the entire os, or underlying lib linking just failed - never figured out why, but it wasn't worth investing more time.

This is one of the usability problems they have. There are some simple solutions to this, but it should be more straightforward.

Re: My Python Development Environment, 2018 Edition

#130

Since switching to nixos, my Python development environment couldn't be more satisfying. I use a default.nix file and a requirements.txt file and then with a single command I'm into a shell and virtual environment with all dependencies and packages installed, that I can easily transfer between machines. That is unless I want to use PyQt5.

I've been following nixos for a while. I think there is a 2.0 version worked on, I am waiting for it to be release then I'll dive into deeper.

On the surface from what I've seen it does all the things right and it is kind of what I expected Docker would before I used it.

Post reply on HN