Im quit new to python coming from the JS world .
When installing a package in javascript all the subdependencies of that packge are not part of the package.json. dependencies section. For example:
npm init -y
npm install express
would produce
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
even though express.js has 31 dependencies
Reading about python dependencies. I did the following steps:
created virtual env:
python -m venv my-virutal-env
made sure no package is installed:
pip freeze > to-uninstall.txt
pip uninstall -r to-uninstall.txt
pip freeze > requirements.txt
Installed llamaIndex
pip install llama_index
producing requirements again using pip freeze > requirements.txt
produces:
...
llama-index==0.5.12
...
when ... are a lot of other packages
This is very undesirable. How Can I overcome this?
pip freezelists every third-party package installed in the current environment. All those other packages were installed when you ranpip install llama_index. You can manually editrequirements.txtto just have thellama-index==0.5.12line, and it'll install just fine. However, as MisterMiyagi said, you want to make sure all dependencies and their versions are listed for reproducibility.requirements.txt, you are saying to the end user that your package works in exactly this environment. It may work in others, it may not, but I know it works here. The user is of course free to update any of the [sub]dependencies as they wish, but if something breaks it's on them. The whole point of a package is that it is like a black box I disagree with that statement in several ways, but even if it is, you are programming that black box. You're responsible for the dependencies.requirements.txtisn't there to define the dependencies of your package. That is the job of the package distribution, commonly viapyproject.toml.requirements.txtis there to define the Python environment of a program for reproducibility.requirements.txt: specifying a set of environment package versions known to be good.