My question here may seem really naive but I never found any clue about it on web resources.
The question is, concerning install_requires
argument for setup()
function or setup.cfg
file, is it a good practice to mention every package used, even python built-in ones such as os
for example ?
One can assume that any python environment has those common packages, so is it problematic to explicitly mention them in the setup, making it potentially over-verbose ?
Thanks
install_requires
should include non-standard library requirements, and constraints on their versions (as needed).
For example, this would declare minimal versions for numpy
and scipy
, but allow any version of scikit-learn
:
setup(
# ...
install_requires=["numpy>=1.13.3", "scipy>=0.19.1", "scikit-learn"]
)
Packages such as os
, sys
are part of Python's standard library, so should not be included.
As @sinoroc mentioned, only direct 3rd party dependencies should be declared here. Dependencies-of-your-dependencies are handled automatically. (For example, scikit-learn
depends on joblib
; when the former is required, the latter will be installed).
I've found it helpful to read other packages and see how their setup.py
files are defined.
imbalanced-learn
pandas
You should list top-level 3rd party dependencies.
Don't list packages and modules from Python's standard library.
Do list 3rd party dependencies your code directly depends on, i.e. the projects containing:
Don't list dependencies of your dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With