简体   繁体   中英

Python optional dependency in requirements file based on another package dependency

I know from https://docs.openstack.org/pbr/3.1.0/index.html#extra-requirements that I can add a package as a dependency based on the python version such as: argparse; python_version=='2.6' argparse; python_version=='2.6'

My question is can I do this based on another package like: argparse; my_package=='2.6' argparse; my_package=='2.6' ?

Generally it is better to pin all dependencies if you are worried about certain methods becoming deprecated or changing in the future, this will ensure that your package will always work. What I mean by this is to specify a version for all of your dependencies, not just one. For example, a dependable requirements file (or dependencies section) may look like:

argparse==2.6
pandas==1.4.0
tqdm==4.63.0

Later, when you update your package to use the latest versions of the dependencies, you can also update the versions of the dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM