flâneur — a map of the web's best reading

Do not use requirements.txt - quanttype

quanttype.net · 923 words · saved by 1 readers

To me, the first one is a no-brainer. The second one is more tentative: Poetry is a great option, but it’s hardly the only option worth considering. I’ll explain below. pip is a tool that you can use to install packages from The Python Package Index (PyPI). It comes with Python and if you’re a Python developer, you have probably used it many times. The traditional way to manage dependencies for a Python project was to list them in a file called requirements.txt and use pip install -r requirements.txt to install. However, pip was designed to be a package installer and not a full-fledged project workflow tool. pip lacks two essential features, dependency lockfiles and automatic management of virtualenvs. If you want to get same behavier in all environments - your laptop, CI, production - you need to pin the versions of your dependencies and their transitive dependencies. You can pin the versions of your direct dependencies in a requirements.txt by specifying for example requests==2.31.0

Are you developing a backend service in Python? I have two pieces of advice for you: Do not use pip and requirements.txt to manage Python dependencies. They lack crucial features that should be built-in. Use Poetry instead. To me, the first one is a no-brainer. The second one is more tentative: Poetry is a great option, but it's hardly the only option worth considering. I'll explain below. Nota bene: If you use Python for something else than building backend services, then the advice in this post may not apply to you. For example, if you're a library developer migrating off setup.py , it's not

Explore this link on the map →

related reading