简体   繁体   中英

How to recheck setup.cfg after editing it in 'pip install -e .` mode

pip install -e. is a great feature. It allows you to work on your package without having to uninstall-reinstall constantly. It seemingly doesn't, however, keep track of your build files (eg your setup.cfg or setup.py). Say, you change these (eg add, subtract, change version for dependencies, or change which modules you include in the package). What is then the best way to have pip recheck these requirements?

Or more generally, what is the way you're supposed to handle changes in your setup.cfg or setup.py when using pip install -e. ?

What I usually end up doing is just doing pip install -e. in the root directory. This walks through your entire setup configuration again, install any new or changed dependencies and then uninstalls your package before reinstalling it again. Which definitely isn't always necessary, and does slow things down a lot.

While this certainly works, it feels against the idea of the 'editable' package.

Is there a proper way of doing this?


FYI, I know you can just install dependencies that aren't listed in your setup.cfg yourself by just pip install... , my question is aimed at learning a better way of doing things.

It is probably the best way of doing things. The reason pip install -e. reinstalls everything is because it is environment agnostic.

Let's say you have two dependencies numpy >= 1.7.2 and pandas==1.4.2 . Now, pandas 1.4.2 requires a minimum version of numpy==1.18.2, so when you do a pip install (editable or not), it would probably pick the greatest compatible version(1.22.3).

Let's say you now want to fix numpy at 1.20.2. The only way pip knows it is compatible with pandas is by walking through your whole list of requirements.

If you do end up wanting a "better" tool than pip, check out pipenv or poetry .

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