Skip to content

Instantly share code, notes, and snippets.

@lmergner
Last active October 22, 2020 14:27
Show Gist options
  • Save lmergner/9871792f289d0a1264de1743bc39a603 to your computer and use it in GitHub Desktop.
Save lmergner/9871792f289d0a1264de1743bc39a603 to your computer and use it in GitHub Desktop.
A simple python script to read setup.cfg and install our requirements
"""
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