by kbumsik · 4y ago · 0 comments
So I stick with this setup:
- Use pyenv to manage different Python versions and virtual environments.
- Use the standard PEP621 specification as a high-level dependency description: https://www.python.org/dev/peps/pep-0621/#example
- Use pip freeze > requirements.txt as a "lockfile".
$ poetry init
$ poetry add django
$ poetry shell
It's pretty simple. Check in the lock file, and then run $ poetry install
to replicate it.> - Use pip freeze > requirements.txt as a "lockfile".
There's lots of reasons to not do this anymore, and Dependency Hell is real, and has been for 25 years with RedHat RPM's, etc.
Even if you don't want to rely upon poetry for building in prod, poetry can still export a requirements.txt file for you, so you're not locked into using poetry, but you still get to specify the high level packages you want, and let it solve the dep graph for you.
If you want to be relaxed about dependencies, you can use "pip-chill".
pip install pip-chill
pip-chill > requirements.txt
And, if you are even more relaxed, pip-chill --no-version > requirements.txtThe pip docs also suggest using pip-tools to create lock files. Pip-tools is only for creating lock files (it’s not trying to fix virtualenvs like poetry is), and it works great.
the pip team has introduced strict performance checks to ensure the new resolver was not significantly slower than the old. they solicited requirements files to weed out situations exactly like the one you describe. for example https://github.com/pypa/pip/issues/8664
if you want it improved, please report it.
Putting that aside though: yes, 100% pip-tools or an equivalent (which pyenv is not). It's the only sane way to both freeze dependencies for reproducibility, and maintain upgradability. I've used pip-tools for years on many large, complex projects, and it has been a huge benefit every single time. And it routinely revealed significant library-incompatibility problems that teams had only luckily dodged due to not using feature X yet, because pip's resolver has been so braindead for forever.
Maybe I will just try first. pip-tools seems to acknowledging PEP621
https://pip-tools.readthedocs.io/en/latest/changelog/?highli...
This is not and has never ever been correct. It makes it infinitely harder to install an application vs the standard `pip install -e .` which works on every package manager and avoids PYTHONPATH issues, as well as being able to publish your application to PyPI for easy installation (as simple as pip install --user app or pipx install app).