4 ms·
People always complain about pip and python packaging but it’s never been an issue for me. I create a requirements.base.txt that has the versions of things I wa
by aidos 3y ago
People always complain about pip and python packaging but it’s never been an issue for me. I create a requirements.base.txt that has the versions of things I want installed. I then:
pip freeze -r requirements.base.txt > requirements.txt
Install is then simply:
pip install -r requirements.txt
Updating / installing something new is a matter of adding to the base file and then refreezing.
- bluish29 3y agoThere are several problems with this approach, notably you don't get information about specific platform stuff. You don't get information on how these package are installed (conda, mamba..etc). And it does not account for dependincies version conflicts which life very hard.
- aidos 3y agoI don’t understand the platform thing, is that something to do with running on Windows? Why wouldn’t you just pip install? Why bring conda etc into the mix? If you have conflicts then you have to reconcile those at point of initial install - pip deals with that for you. I’ve never had a situation in 15 years of Python packages where there wasn’t a working combination of versions. These are genuine questions btw. I see these common complaints and wonder how I’ve not ever had issues with it.
- bluish29 3y agoI will try to summarize the complaints (mine at least) in obvious simple points 1- pip freeze will miss packages not installed by pip (i.e. Conda). 2- It does include all packages, even not used in the project. 3- It just dumps all packages, their dependencies and sub-dependencies. Even without conflicts, if you happen to change a package, then it is very hard to keep track of dependencies and sub-dependencies that need to be removed. At some point, your file will be a hot mess. 4. If you install specific platform package version then this information will not be tracked
- aidos 3y agoOk. I think that’s all handled by my workflow, but it does involve taking responsibility for requirements files. If I want to install something, I pip install and then add the explicit version to the base. I can then freeze the current state to requirements to lock in all the sub dependencies. It’s a bit manual (though you only need a couple of cli commands) but it’s simple and robust.
- bluish29 3y agoI don't think that manual handling of requirement.txt in a collaborative environment is a robust process. It will be a waste of time and resources to handle it like that. And I don't know about your workflow but it is obviously not standard and it does not address the first and forth points.
- aidos 3y agoHaha. Ok. I think that’s where we’re just going to have to agree to disagree.
- pastorhudson 3y agoThis is my workflow too. And it works fine. I think the disconnect here is that I grew up fighting dependencies when compiling other programs from source on Linux. I know how painful it can be and I’ve accepted the pain and when I came to python/venv I thought “This isn’t so bad!” But if someone is coming from data science and not dev-ops then no matter how much we say “all you have to do”. The response will be why do I have to do any of this?
- paddy_m 3y agoCan you name a package manager (any language) that handles #3 well? How does it handle the problem?
- d0mine 3y ago1/4- Ordinary `pip install` works for binary/platform-specific wheels (e.g., numpy) too and even non-Python utilities (e.g., shellcheck-py) 2/3- you need to track only the direct dependencies _manually_ but for reprodicible deployments you need fixed versions for all dependencies. The latter is easy to generate _automatically_ (`pip freeze`, pip-tools, pipenv/poetry/etc).
- ShamelessC 3y agoYes, there are more problems with Windows.
- bmitc 3y agoPoetry handles all of this properly.
- ShamelessC 3y agoJust not PyTorch apparently.
- 331c8c71 3y agoI regularly observe it stalling at dependency resolution stage upon changing version requirements for one of the packages (or python version requirements).
- actuallyalys 3y agoThe post you’re responding to said that there are many Python packaging options, not that they don’t work. Pip freeze works reasonably well for a lot of situations but that doesn’t necessarily mean it’s the best option for their notebook tool, especially if they want to attract users who are used to conda.
- n8henrie 3y agoI follow a similar approach -- top-level dependencies in pyproject.toml and then a pip freeze to get a reproducible set for applications. I know there are edge cases but this has worked really well for me for a decade without much churn in my process (other than migrating from setup.py to setup.cfg to pyproject.toml). After trying to migrate everything to pipenv and then getting burned, I went back to this and can't imagine I'll use another third-party packaging project (other than nix) for the foreseeable future.