Last active
October 22, 2020 14:27
-
-
Save lmergner/9871792f289d0a1264de1743bc39a603 to your computer and use it in GitHub Desktop.
A simple python script to read setup.cfg and install our requirements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple python script to read setup.cfg and install our requirements | |
Why? Replace pip -r requirements in CI/CD or Docker environments. | |
""" | |
# using pip._internal.main | |
# https://stackoverflow.com/questions/12937533/use-pip-install-uninstall-inside-a-python-script | |
# using configparser | |
# https://stackoverflow.com/a/46573039/3736421 | |
import configparser | |
from pip._internal import main as pipmain | |
c = configparser.ConfigParser() | |
c.read('setup.cfg') | |
pkgs = [p for p in c['options']['install_requires'].split()] | |
pipmain([ | |
"install", | |
"--use-feature", "2020-resolver", | |
*pkgs | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment