logoalt Hacker News

greener_grasslast Tuesday at 1:04 PM2 repliesview on HN

If you write out `requirements.txt` by hand, do you also need to resolve deps and transitive deps by hand?

This is what pushed me to use Poetry.


Replies

cpburns2009last Tuesday at 2:14 PM

I write my high level dependencies by hand in a "requirements.in" for applications, and in "pyproject.toml" for libraries.

A simple "requirements.in" I did over this weekend was a single dependency:

    miniboss >=0.4, <0.5
And used pip-compile to pin all transitive dependencies:

    pip-compile -o requirements.txt requirements.in
This generated a "requirements.txt" with 14 dependencies with pinned versions:

    attrs==25.3.0
    ...13 more dependencies
    
It's then only a matter of running "pip install -r requirements.txt" in the venv for my "application" (wrapper scripts for Docker).

I've largely settled on this scheme for work and person projects because it's simple (only dev dependency is pip-tools or uv), and it doesn't tie me to a particular Python project management tool (pipenv, pdm, poetry, etc.).

jerrygenserlast Tuesday at 1:13 PM

You do not write requirements by hand. You write requirements.in and uv pip-compile to requirements.txt

show 1 reply