Live data from Hacker News

Ask HN: Simple but modern Python dev set-up?

news.ycombinator.com

11–20 of 26 posts

Re: Ask HN: Simple but modern Python dev set-up?

#11

Start out with just pyenv. It's not complicated and helps a lot if you don't want system-wide updates to mess with your virtual environments (you don't). Even though pip may not be ideal, it works well enough. So far, more advanced alternatives for me created at least as many problems as they supposedly solved. See for yourself what issues you'll have (if any) and then pick the tools that solve them best. The editor/…

Yep.

What was most important to me was predictable builds and you can roughly accomplish this by using pip-compile:

pip-compile -n --generate-hashes requirements.txt 2> requirements-compiled.txt

Update this and commit to your repository whenever you add a new project. It keeps track of the hashes that each package uses which isn't perfect but is a good stop-gap. Then install packages using requirements-compiled.txt only.

Other pure pip/python suggestion welcomed!

Re: Ask HN: Simple but modern Python dev set-up?

#13
Venv is the simplest - it comes in the Python standard library and gives you the basic tools to manage virtual environments. You can start with it and see how far it gets you. If you need to manage multiple versions of Python then try pyenv or conda.

Re: Ask HN: Simple but modern Python dev set-up?

#14
Pycharm when configured is a big productivity boost for me. I also make good use of Pydantic, NamedTuples and type hints so that the ide offers excellent hints.

Also check out the FastAPI project. A very expressive framework with smart defaults plays nicely with the tools above and I prefer to django and flask.

https://fastapi.tiangolo.com/

Re: Ask HN: Simple but modern Python dev set-up?

#15
pyenv, pyenv virtualenv (built-in to pyenv) and pip.

- Install pyenv (curl https://pyenv.run | bash)

- Install python version(s) with pyenv (pyenv install 3.7.3)

- Create virtualenv with pyenv virtualenv. (pyenv virtualenv )

- Create a directory with the same name (mkdir )

- cd into it and do pyenv local for auto activating virtualenvs.

- Install packages with pip.

This isn't the most elegant solution available, but it keeps everything nice and segregated.

edited to add clarity

Re: Ask HN: Simple but modern Python dev set-up?

#16
post #3

Has your current Python development setup failed you yet? Are Python versions preventing you from producing useful software? Are you looking to explore and experiment with setups, or is shipping useful software what counts? "The Hitchhiker’s Guide to Python"[^1] does a tour of the tools that would be very useful. Virtual environments, testing, frameworks, etc. [^1]: https://docs.python-guide.org/

That sounds like the ultimate salesman wanketeering & I love it.

Re: Ask HN: Simple but modern Python dev set-up?

#17
post #16
post #3

Has your current Python development setup failed you yet? Are Python versions preventing you from producing useful software? Are you looking to explore and experiment with setups, or is shipping useful software what counts? "The Hitchhiker’s Guide to Python"[^1] does a tour of the tools that would be very useful. Virtual environments, testing, frameworks, etc. [^1]: https://docs.python-guide.org/

That sounds like the ultimate salesman wanketeering & I love it.

There was a phrase after the questiona inviting OP not to solve problems they don't have, as worrying about setup before building is a dead giveaway for procrastination. Let me just spend two months figuring out the perfect standing desk, two months fingering oipeoof water cooled stations, and a year mastering an editor.

I couldn't leave it at that and added one resource recommendation. Then I removed the part in the middle, and the result of removing that is straight out of an infomercial.

Re: Ask HN: Simple but modern Python dev set-up?

#18
My $0.02

--

1. Download python3.8 (if you're on a Mac, just use brew install python3.8)

Now you have a virtualenv via `python3.8 -m venv`

Didn't have to install _any_ dependencies. This is clean.

From there just use your favorite editor (Sublime, VS Code, Vim, etc) and you're good to go.

A lot of other recommendations are saying install some other slightly more complicated things that you _absolutely do not need_. If you're doing standard Python dev, you literally just need a virtual environment and an editor.

Post reply on HN