Live data from Hacker News

My Python Development Environment, 2020 Edition

jacobian.org

131–140 of 241 posts

Re: My Python Development Environment, 2020 Edition

#131

Earlier quoted context omitted.

Sometimes scripts will want to invoke Python as ‘python’ and it’s easier to use pyenv to set $PATH overrides.

Why do you need pyenv to set PATH?

Maybe you don’t, but it’s a way of doing it.

Specifically, pyenv will dynamically and programmatically link the $PATH for the Python executables (python, pip, etc.) to the desired version as defined either by an environment variable or by the contents of a .python-version file in CWD or an ancestor thereof. The .python-version file can be checked into version control.

Re: My Python Development Environment, 2020 Edition

#132
post #107

Earlier quoted context omitted.

I understand how this was needed historically, when using the official installer might overwrite the Python you already had installed. But as far as I know, you can download an installer for a new version, run it, and it doesn't touch your previous installation. For example I've had 3.7 on my macOS system for a while, installed from the official installer, not through Homebrew. I just installed 3.8, which pointed my…

Sometimes scripts will want to invoke Python as ‘python’ and it’s easier to use pyenv to set $PATH overrides.

Thank you, that’s the first concrete reason I’ve heard. It also explains why I haven’t run into issues yet using my own aliases.

Re: My Python Development Environment, 2020 Edition

#133
post #31

Does anyone else think this reflects badly on Python? The fact that the author has to use a bunch of different tools to manage Python versions/projects is intimidating. I don't say this out of negativity for the sake of negativity. Earlier today, I was trying to resurrect an old Python project that was using pipenv. "pipenv install" gave me an error about accepting 1 argument, but 3 were provided. Then I switched to…

Granted, I'm just a scientific programmer, but my workplace has a full blown software team maintaining a multi million line codebase. That codebase is rebuilt every night, and as I understand it, you're not allowed to submit a change that breaks anything. And they have people whose job is to keep their tools working. What people casually think of as "Python" is really a huge dynamic ecosystem of packages. Imagine tha…

You should try Dockerizing your project. Then other people just have to type docker run and it’ll work everywhere.

Re: My Python Development Environment, 2020 Edition

#134
post #95

Earlier quoted context omitted.

I've worked on tons of small to medium-small Python projects over the years where I didn't fix dependency versions at all, not even major versions, just a requirements.txt with a list of package names (usually it's a list of maybe at most ten well-known libraries, resulting in at most twenty actual packages pulled from PyPI). Come back three years later, pull the latest versions of everything, code still works fine.…

I’ve only recently started working with Python, and I’ve already been bitten by TensorFlow v1 and v2 packages having different APIs, so the viability of that approach will depend heavily on which packages you use. However in SemVer a major version number change is how breaking changes are documented, so seeing a v1 to v2 change coupled with having to do some work to fix breakage is just expected, something that may w…

ML, pydata etc. are really worlds apart from more traditional Python ecosystems; guido himself a couple years back admitted he had no idea about those silos and sat down with some leaders of those communities to hear their needs. Those communities tend to have their own recommendations and best practices.

My very brief exposure to TF seems to suggest that dev environments surrounding TF are way harder to set up than my “list of bare packages in a requirements.txt file” scenario which is sufficient for a lot of more traditional endeavors.

Re: My Python Development Environment, 2020 Edition

#136
> On Linux, the system Python is used by the OS itself, so if you hose your Python you can hose your system.

I never manged to hose the OS Python on Linux, by sticking to a very simple rule: DON'T BE ROOT. Don't work as root, don't run `sudo`.

On Linux, I use the system python + virtualenv. Good enough.

When I need a different python version, I use docker (or podman, which is an awesome docker replacement in context of development environments) + virtualenv in the container. (Why virtualenv in the container? Because I use them outside the container as well, and IMHO it can't hurt to be consistent).

Re: My Python Development Environment, 2020 Edition

#137
post #67

python -m venv venv source venv/bin/activate pip install -U pip pip install whatever # deactivate no need any third-party tools, venv is built-in the above steps always worked for me out of the box.

But how about replacing all of these commands with two words? poetry install

Re: My Python Development Environment, 2020 Edition

#138
post #43

I recommend asdf for version management if you use more than one programming language

Seconded. Just to be clear asdf manages interpreters, not project dependencies. It actually uses pyenv under the hood to manage Python versions. I use it to manage Elixir and Python versions and it works rather well. I also find its CLI interface well designed and consistent.

Re: My Python Development Environment, 2020 Edition

#139
post #96
post #39

I have never understood the need for all the different tools surrounding Python packaging, development environments, or things like Pipenv. For years, I have used Virtualenv and a script to create a virtual environment in my project folder. It's as simple as a node_modules folder, the confusion around it is puzzling to me. Nowadays, using setuptools to create packages is really easy too, there's a great tutorial on t…

Last time I looked, it was very tedious to set up `pip` to be secure and pin your dependencies to hashes. Without this, a compromise of a library's pypa account would allow them to execute arbitrary code on your system, assuming you didn't notice the change. You can use `pip-tools` to get something like a Gemfile/package.json, but there are a few restrictions that are suboptimal. So Pipenv/Poetry are the current best…

Conda does as well, and a hell of a lot more, not sure why it is so rarely mentioned.

Re: My Python Development Environment, 2020 Edition

#140
post #39

I have never understood the need for all the different tools surrounding Python packaging, development environments, or things like Pipenv. For years, I have used Virtualenv and a script to create a virtual environment in my project folder. It's as simple as a node_modules folder, the confusion around it is puzzling to me. Nowadays, using setuptools to create packages is really easy too, there's a great tutorial on t…

`poetry env` works just fine without pyenv.
Post reply on HN